在Node.js中,我习惯使用npm link
来使项目使用自定义版本的依赖项。从节点文档:
首先,包文件夹中的
npm link
将创建从prefix/package-name
到当前文件夹的全局安装的符号链接。接下来,在其他某个位置,
npm link package-name
将创建一个从本地node_modules
文件夹到全局符号链接的符号链接。
通过符号链接到网站包来做一些类似的事情是不是犹太?
答案 0 :(得分:4)
也许,但您可能想要做的是使用virtualenv。 Virtualenv允许您创建与其他任何其他环境隔离的python环境:
$ virtualenv myenv
New python executable in myenv/bin/python
Installing setuptools............done.
Installing pip...............done.
$ source myenv/bin/activate
然后您可以根据需要安装特定版本的python软件包,比如我刚发现的随机toolz
软件包的版本0.1.0
,当最新版本为0.2.1
时:
(myenv)$ pip install toolz==0.1.0
Downloading/unpacking toolz==0.1.0
Downloading toolz-0.1.tar.gz
Running setup.py egg_info for package toolz
Downloading/unpacking itertoolz>=0.5 (from toolz==0.1.0)
Downloading itertoolz-0.5.tar.gz
Running setup.py egg_info for package itertoolz
Downloading/unpacking functoolz>=0.4 (from toolz==0.1.0)
Downloading functoolz-0.4.tar.gz
Running setup.py egg_info for package functoolz
Installing collected packages: toolz, itertoolz, functoolz
Running setup.py install for toolz
Running setup.py install for itertoolz
Running setup.py install for functoolz
Successfully installed toolz itertoolz functoolz
Cleaning up...
正如您所看到的,它还会安装依赖项。您还可以生成需求文件:
(myenv)$ pip freeze
functoolz==0.4
itertoolz==0.5
toolz==0.1
wsgiref==0.1.2
然后您可以使用它来复制另一个virtualenv中的相同依赖项
(myenv)$ pip freeze > reqs.txt
(myenv)$ deactivate
$ source env2/bin/activate
(env2)$ pip freeze
wsgiref==0.1.2
(env2)$ pip install -r reqs.txt
Downloading/unpacking functoolz==0.4 (from -r reqs.txt (line 1))
Downloading functoolz-0.4.tar.gz
Running setup.py egg_info for package functoolz
Downloading/unpacking itertoolz==0.5 (from -r reqs.txt (line 2))
Downloading itertoolz-0.5.tar.gz
Running setup.py egg_info for package itertoolz
Downloading/unpacking toolz==0.1 (from -r reqs.txt (line 3))
Downloading toolz-0.1.tar.gz
Running setup.py egg_info for package toolz
Requirement already satisfied (use --upgrade to upgrade): wsgiref==0.1.2 in /Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6 (from -r reqs.txt (line 4))
Installing collected packages: functoolz, itertoolz, toolz
Running setup.py install for functoolz
Running setup.py install for itertoolz
Running setup.py install for toolz
Successfully installed functoolz itertoolz toolz
Cleaning up...
答案 1 :(得分:4)
确切的类似物是pip install -e .
或python setup.py develop
。
https://pip.pypa.io/en/latest/reference/pip_install.html#editable-installs