tell pip to install the dependencies of packages listed in a requirement file

前端 未结 5 1670
耶瑟儿~
耶瑟儿~ 2020-12-12 19:10

Developing a Django web app, I have a list of packages I need to install in a virtualenv. Say:

Django==1.3.1
--extra-index-url=http://dist.pinaxproject.com/         


        
5条回答
  •  爱一瞬间的悲伤
    2020-12-12 19:27

    Extending Piotr's answer, if you also need a way to figure what to put in requirements.in, you can first use pip-chill to find the minimal set of required packages you have. By combining these tools, you can show the dependency reason why each package is installed. The full cycle looks like this:

    1. Create virtual environment:
      $ python3 -m venv venv
    2. Activate it:
      $ . venv/bin/activate
    3. Install newest version of pip, pip-tools and pip-chill:
      (venv)$ pip install --upgrade pip
      (venv)$ pip install pip-tools pip-chill
    4. Build your project, install more pip packages, etc, until you want to save...
    5. Extract minimal set of packages (ie, top-level without dependencies):
      (venv)$ pip-chill --no-version > requirements.in
    6. Compile list of all required packages (showing dependency reasons):
      (venv)$ pip-compile requirements.in
    7. Make sure the current installation is synchronized with the list:
      (venv)$ pip-sync

提交回复
热议问题