Pip-tools: Using layered environments

Created on 13 Oct 2020  路  3Comments  路  Source: jazzband/pip-tools

Hi,

I try to use layered requirements for a development environment as instructed in the documentation, but either I understood it wrong or there's some error in it.
I created a test environment and installed pip-tools there. Next I created a small and easy setup.py which requires PyYAML for my package. pip-compile recognizes this requirement accordingly and creates a correct requirements.txt. Next I created a dev-requirements.in with -c requirements.txt at the very top of that file plus flake8. Result is that I have now a file called dev-requirements.txt containing only those python packages as dependency as of flake8.

Environment Versions

  1. OS Type: Debian Focal Fossa (20.04)
  2. Python version: 3.8.5
  3. pip version: 20.2.3
  4. pip-tools version: 5.3.1

Steps to replicate

  1. create virtual environment (i.e. with virtualenv using virtualenvwrapper)
  2. create setup.py/setup.cfg) having "install_requires=PyYAML"
  3. pip-compile
  4. create dev-requirements.in with lines "-c requirements.txt" and "flake8"
  5. pip-compile dev-requirements.in

Expected result

#
# This file is autogenerated by pip-compile
# To update, run:
#
#    pip-compile dev-requirements.in
#
flake8==3.8.4             # via -r dev-requirements.in
pyyaml==5.3.1             # via -c requirements.txt
mccabe==0.6.1             # via flake8
pycodestyle==2.6.0        # via flake8
pyflakes==2.2.0           # via flake8

Actual result

# This file is autogenerated by pip-compile
# To update, run:
#
#    pip-compile dev-requirements.in
#
flake8==3.8.4             # via -r dev-requirements.in
mccabe==0.6.1             # via flake8
pycodestyle==2.6.0        # via flake8
pyflakes==2.2.0           # via flake8
support

Most helpful comment

Did you try using -r requirements.txt instead of -c requirements.txt in dev-requirements.in?

All 3 comments

The README has this example:

To sync multiple *.txt dependency lists, just pass them in via command line arguments, e.g.
$ pip-sync dev-requirements.txt requirements.txt

So I think you can run that if you want to install both sets of requirements. The -c option is just used to ensure your dev file doesn't violate the other file's constraints, but it doesn't automatically add other dependencies to its output.

Did you try using -r requirements.txt instead of -c requirements.txt in dev-requirements.in?

I'll close this based on the above correct solution from @DBCerigo, but please let us know if it doesn't resolve your issue. Thanks!

Was this page helpful?
0 / 5 - 0 ratings