Many projects I work on maintain two requirements lock files:
requirements.txtfor remote, production-like environments;
requirements.dev.txtfor development and testing environments;
The development requirements should always be a superset of the production ones but it’s possible for them to fall out of sync if you’re not careful in updating both lock files at the same time.
If you declare packages in
will avoid conflicts when compiling.
If you declare packages in a
pyproject.toml file then it’s best to install
both lock files in development environments:
pip-sync requirements.txt requirements.dev.txt
If there’s a conflict between the two lock files then
pip-sync will error.
pip-sync doesn’t support installing packages in editable directly - you can’t
pip-sync requirements.txt requirements.dev.txt -e .
but you can work around this by creating a
requirements.local.txt file with
and then install your development packages with:
pip-sync requirements.txt requirements.dev.txt requirements.local.txt
to ensure all packages are installed in one invocation and any conflicts are brought to light.
Hat-tip to Hynek Schlawack for a useful post on this topic.