Split requirements files in pip

前端 未结 2 1691
北海茫月
北海茫月 2020-12-24 10:16

To create Python virtual environments I use virtualenv and pip. The workflow is very simple:

$ virtualenv project
$ cd project
$ . bin/activate
$ pip install         


        
相关标签:
2条回答
  • 2020-12-24 10:50

    The -r flag isn't restricted to command-line use only, it can also be used inside requirements files. So running pip install -r req-1-and-2.txt when req-1-and-2.txt contains this:

    -r req-1.txt
    -r req-2.txt
    

    will install everything specified in req-1.txt and req-2.txt.

    0 讨论(0)
  • 2020-12-24 10:52

    Just on a note, you can also split the requirements based on your groupings and embed them in a single file ( or again can prepare multiple requirements file based on your environment), that you can execute.

    For example, the test requirements here:

    requirements-test.txt

    pylint==2.4.4
    pytest==5.3.2
    

    The dev requirements here:

    requirements-dev.txt

    boto3>=1.12.11
    

    Master requirements file containing your other requirements:

    requirements.txt

    -r requirements-dev.txt
    -r requirements-test.txt
    

    Now, you can just install the requirements file embedding your other requirements

    pip3 install -r requirements.txt
    
    0 讨论(0)
提交回复
热议问题