From: alex Date: Mon, 17 Feb 2025 19:39:00 +0000 (+0100) Subject: Update stuff to use uv X-Git-Url: https://xn--ix-yja.es/gitweb/?a=commitdiff_plain;h=98e475f3ce9494b6f4a4b1d46f3e1a00d092b68e;p=alex.git Update stuff to use uv --- diff --git a/programming/python/creating_nice_python_cli_tools.md b/programming/python/creating_nice_python_cli_tools.md index 53b3f51..b192da1 100644 --- a/programming/python/creating_nice_python_cli_tools.md +++ b/programming/python/creating_nice_python_cli_tools.md @@ -3,8 +3,8 @@ Following this advice can make your tools easy to install by others, pleasant to * Use [my suggestions for setting up Python projects](project_setup.md), particularly: * Provide instructions for installing your tool using [pipx](https://github.com/pypa/pipx). Using pipx, people can install and upgrade your script using a simple command that requires no administrative privileges (but it requires having Python and pipx installed). - * As you are using [poetry](https://python-poetry.org/), following the indications above: - * Use [Poetry's support for specifying scripts](https://python-poetry.org/docs/pyproject/#scripts), so when installing your tool via pipx or other means, your scripts are added to the user's path. + * As you are using [uv](https://docs.astral.sh/uv/), following the indications above: + * Use [entry points](https://docs.astral.sh/uv/concepts/projects/config/#entry-points), so when installing your tool via pipx or other means, your scripts are added to the user's path. * Dependencies you define will be installed automatically along with your application. This reduces the effort users need to use your application if you need third-party libraries. However, I would still advise to avoid unnecessary dependencies (for simple HTTP requests you can use the base library. If you do complex requests, then using a third-party library might be much simpler). diff --git a/programming/python/project_setup.md b/programming/python/project_setup.md index 57c26c5..10beb94 100644 --- a/programming/python/project_setup.md +++ b/programming/python/project_setup.md @@ -8,26 +8,19 @@ Pipx is a tool that installs Python packages to your user environment. It create Pipx is useful for two purposes: -* To install tools such as poetry +* To install tools such as uv * To let other users install your software easily -# Use Poetry - -> [!NOTE] -> I have been using [rye](https://rye.astral.sh/) recently. -> Not enough to recommend it unconditionally over Poetry, but I am liking it so far. -> Consider testing it. -> It uses [Python redistributable builds](https://github.com/indygreg/python-build-standalone) to manage Python versions, so you can choose to use more modern Python versions. +# Use uv When using third-party dependencies in your Python code, it is highly interesting to avoid installing any project-specific dependency outside the project. To achieve that, traditionally virtualenvs are used; those are miniature Python installations where you can install any library you want. Virtualenvs need to be explicitly activated to be used, so it is easy to have a virtualenv for each Python project you are working on. -Poetry is a tool that leverages virtualenvs to manage a project's dependencies, managing virtualenvs automatically. - -There are many similar tools such as pipenv and there are many multiple ways to specify a project's dependencies (`setup.py`, `requirements.txt`, etc.); Poetry provides a convenient way to do everything. +uv is a tool that leverages virtualenvs to manage a project's dependencies, managing virtualenvs automatically. +uv can also manage Python distributions, downloading automatically Python versions other than the existing ones on your system. -You can install poetry using pipx. +There are many similar tools such as pipenv and there are many multiple ways to specify a project's dependencies (`setup.py`, `requirements.txt`, etc.); uv provides a convenient way to do everything. Consider reading [some brief notes about Python dependency management](dependency_handling.md). @@ -62,13 +55,9 @@ Set up your version control so changes cannot be made to your main codeline with > Consider testing it. > It requires slightly less configuration and it comes with more lints. -## Use Black +## Use Ruff -Use Black to format your code. - -## Use flake8 - -Use `flake8` to gate changes. Use `flake8-black` to prevent committed code which does not follow Black style. +Use Ruff to format and lint your code. # Version control @@ -94,8 +83,6 @@ Even if you are not running your code using the latest versions of Python, try t Use continuous integration to run your tests in all supported versions of Python. -This implies that development should be possible to do without using a specific version of Python, so pyenv or similar is not strictly needed. - # Use ipython and ipdb Add ipython and ipdb as development dependencies.