Installing dependencies only - setuptools

若如初见. 提交于 2019-12-08 02:03:32

问题


I have a Python script, with several external dependencies, that I wish to distribute to colleagues. However, we will need to modify this script regularly so I don't want to install it per-se (i.e. copy to site-packages). From what I've seen setuptools seems to do this implicitly.

Is there a recommended approach to installing dependencies without installing the application/script itself?


回答1:


You probably want to make sure that you and your colleagues use the same dependencies during development.

I think I would try to use virtualenv for this. If you and your collegues install it, it will give you a python environment for this project only, and dependencies for this project only.

So the steps would be:

  1. Everybody installs virtualenv on their computers so they get an isolated environment to use for development of this project only.

  2. One of you determine the current dependencies and installs them in your virtualenv.

  3. You export a list of your used dependencies using this command:

    (inside virtual environment) pip freeze > requirements.txt

  4. You then share this text file with the others. They use this command to import the exact same packages and versions into their virtual environment:

    (inside virtual environent) pip install -r requirements.txt

Just make sure that everybody enters their virtual environment before issuing these commands, otherwise the text file will contain their normal python environment installed packages.




回答2:


You can install the package in development mode. This way changes to the code are reflected immediately, rather than needing the package to be reinstalled, which seems to be the problem you're working around:

python setup.py develop

Docs: https://setuptools.readthedocs.io/en/latest/setuptools.html#development-mode



来源:https://stackoverflow.com/questions/25209753/installing-dependencies-only-setuptools

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!