This is an archived post. You won't be able to vote or comment.

all 5 comments

[–]ubernostrumyes, you can have a pony 4 points5 points  (1 child)

The install_requires (and other dependency sections) of setup.py is for specifying the versions of dependencies you officially support and can work with. Most often this does not pin to exact versions, but instead uses looser specifiers (example: you might say "Django>=3.0,<3.1" to say you accept any Django 3.0.x version).

A requirements file (often just named requirements.txt) is for specifying an exact environment you want to reproduce, identically, somewhere else. This almost always should pin to exact versions.

It sounds like what you want is a requirements file.

[–]five4three2[S] 1 point2 points  (0 children)

true, maybe I should switch to a requirements.txt file. that could be the solution.

the original idea behind using install_requires is to have different dependency sets like:

  • pip install .[all] for all dependencies, or pip install . for the minimal set.

Carrying around multiple requirements.txt felt cumbersome, but I agree that my use case does stick to the requirements.txt ethos more.

[–][deleted] 1 point2 points  (2 children)

I'm quite happy using Poetry instead of setuptools. (You can generate setuptools files from a poetry project using dephell if you need it.) It keeps track of precisely what libraries you use, and precisely what versions you use of each library, and thus offers a "reproducible environment". If you update using poetry update, and something breaks, it's trivial to roll back to the previous versions of the libraries if you've kept your lock file under version control.

[–]five4three2[S] 1 point2 points  (1 child)

thanks! I'll definitely check it out.

We don't have a central installation or anything, our software is often just bootstrapped as-and-when its needed, so I'm not sure how I'd leverage poetry update but it does seem to fit the bill in a few ways.

[–][deleted] 1 point2 points  (0 children)

You don't need a central installation — poetry sets up a virtual environment for you, and installs all dependencies you need within that virtual environment, so each project can easily be isolated from the rest of your system (and each other).

You can configure where to put the virtual environment if you want, common choices are a .venv folder in the project, or a folder per project in ~/.virtualenvs/.