![]() In most cases you simply need to check and edit your PATH settings and remove any shims you don't want.Īnother approach is to use docker containers so you only have the version you require in any particular container. There are a number of tools you can use to manage multiple versions such as pyenv (especially on *nix systems). All this applies to Python 2 with minor tweaks, but hopefully you're not starting new Python2 projects in 2022.Usually, on macOS and Windows, simply installing Python using the Python Software Foundation installation package from will make the latest version the default Python 3 installation. No need to go through them manually or copy/paste some list off someone's blog and hope it's still valid. What about the dependencies? Glad you asked: `apt build-dep python3` on Debian/Ubuntu or `dnf builddep python` on Fedora. There's no need to use anything besides what default Python installation already gives you. Once you activate the virtual environment, that's it. This will pick up the correct version of Python. > /opt/python-/bin/python -m venv /path/to/where/you/want/to/store/your/virtualenv When you use virtualenv (which you should, and no need for pipenv, poetry and the rest), just do this to create a new virtualenv: Once you have all the versions installed, no need to use a tool to switch between them. This is not more complicated than what pyenv asks you to do (read the article). configure -prefix=/opt/python- make make install If you need to install multiple versions of Python that are not available from your distribution packages, simply download the code, install it to a place like /opt and then point your virtualenv to that version when you need it. PSA: You don't need to use Pyenv (or asdf, or anything else.) on Linux. Create a Makefile with targets for those commands for each interpreter you want to test, and you can run everything in knowledge that you'll always know what's happening, instead of relying on stacked magic. Usually I'll wrap that `bash -c` preamble into a simple with_venv.sh script, and make a similar with_venv.ps1 for Windows. "$0/bin/activate" & exec venv38 pytest -doctest-modules -v "$0/bin/activate" & exec venv38 pip install -r requirements.txtīash -c '. "$0/bin/activate" & exec venv38 pip install -upgrade pip setuptools wheelīash -c '. I don't have a preference for/against pyenv for sourcing python interpreters (I'll use an AUR or scoop sometimes), or poetry or pipenv or anything else for specifying dependencies, but whatever method is used, I will always only use them to export a requirements.txt, and I will manually create my own venv for each interpreter, and run anything I want inside each venv via oneliners like:īash -c '. I now refuse to use any packaging tools for anything other than generating a requirements.txt, and refuse to use any version matrix tools like tox. tox would claim to be running tests with python3.8, say, but actually it was still using the default system python3.10, etc. I briefly tried to use poetry, tox, and pytest, and even using the support packages that are supposed to make poetry and tox play nicely together, it was a massive failure. ![]() It's no wonder why alternative tools appear, they're not redundant, they actually fix pain points in the default tools. It's a mess once you start digging a bit, Python dependency management is extremely basic. Even then, pip will not delete packages that it doesn't find on the files. There's also the problem of changing requirement files and the environment not being updated to match 1-to-1 the files, either because someone installs something to test and doesn't put it in the requirements file or because you get an updated file from a coworker and forget to run the update. For new projects I would seriously consider poetry because it manages those two concepts directly. I had a project that started similarly, and in the end I had to use to pip-tools to actually separate top-level requirements and lockfiles for different "flavors" of the package (production and dev dependencies, for example). ![]() Most of the tools you mentioned appeared precisely because the basics with Python don't work that well. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |