Python lib не устанавливает зависимые_ссылки при использовании другими
У меня есть библиотека Python mylib
$ tree mylib/
mylib/
└── setup.py
0 directories, 1 file
setup.py
$ cat setup.py
from setuptools import setup
setup(
name='mylib',
version='1.0.0',
install_requires=['pyrex', 'pytz'],
dependency_links=[
'http://www.cosc.canterbury.ac.nz/greg.ewing/python/Pyrex/Pyrex-0.9.9.tar.gz'
]
)
pyrex
пакет не доступен в pypi
, Я добавил dependency_links
установить этот пакет.
я создал virtualenv
и попробуйте установить эту библиотеку, чтобы увидеть, если это загружает внешний pyrex
форма dependency_links
,
$ virtualenv venv
New python executable in /private/tmp/mylib/venv/bin/python
Installing setuptools, pip, wheel...done.
$ ./venv/bin/python setup.py install
running install
running bdist_egg
running egg_info
creating mylib.egg-info
writing requirements to mylib.egg-info/requires.txt
writing mylib.egg-info/PKG-INFO
writing top-level names to mylib.egg-info/top_level.txt
writing dependency_links to mylib.egg-info/dependency_links.txt
writing manifest file 'mylib.egg-info/SOURCES.txt'
reading manifest file 'mylib.egg-info/SOURCES.txt'
writing manifest file 'mylib.egg-info/SOURCES.txt'
installing library code to build/bdist.macosx-10.12-intel/egg
running install_lib
warning: install_lib: 'build/lib' does not exist -- no Python modules to install
creating build
creating build/bdist.macosx-10.12-intel
creating build/bdist.macosx-10.12-intel/egg
creating build/bdist.macosx-10.12-intel/egg/EGG-INFO
copying mylib.egg-info/PKG-INFO -> build/bdist.macosx-10.12-intel/egg/EGG-INFO
copying mylib.egg-info/SOURCES.txt -> build/bdist.macosx-10.12-intel/egg/EGG-INFO
copying mylib.egg-info/dependency_links.txt -> build/bdist.macosx-10.12-intel/egg/EGG-INFO
copying mylib.egg-info/requires.txt -> build/bdist.macosx-10.12-intel/egg/EGG-INFO
copying mylib.egg-info/top_level.txt -> build/bdist.macosx-10.12-intel/egg/EGG-INFO
zip_safe flag not set; analyzing archive contents...
creating dist
creating 'dist/mylib-1.0.0-py2.7.egg' and adding 'build/bdist.macosx-10.12-intel/egg' to it
removing 'build/bdist.macosx-10.12-intel/egg' (and everything under it)
Processing mylib-1.0.0-py2.7.egg
Copying mylib-1.0.0-py2.7.egg to /private/tmp/mylib/venv/lib/python2.7/site-packages
Adding mylib 1.0.0 to easy-install.pth file
Installed /private/tmp/mylib/venv/lib/python2.7/site-packages/mylib-1.0.0-py2.7.egg
Processing dependencies for mylib==1.0.0
Searching for pytz
Reading https://pypi.python.org/simple/pytz/
Downloading https://pypi.python.org/packages/6c/d3/1f28904f07e937f34e141a44e97a71bb7c95552f857a5da85b716e31eb94/pytz-2017.3-py2.7.egg#md5=37c95d40dba3126f168c7251ddca00e1
Best match: pytz 2017.3
Processing pytz-2017.3-py2.7.egg
Moving pytz-2017.3-py2.7.egg to /private/tmp/mylib/venv/lib/python2.7/site-packages
Adding pytz 2017.3 to easy-install.pth file
Installed /private/tmp/mylib/venv/lib/python2.7/site-packages/pytz-2017.3-py2.7.egg
Searching for pyrex
Downloading http://www.cosc.canterbury.ac.nz/greg.ewing/python/Pyrex/Pyrex-0.9.9.tar.gz
Best match: Pyrex 0.9.9
Processing Pyrex-0.9.9.tar.gz
Writing /var/folders/rt/7_nbtrwx0q305tx_z9tk1l9538x_ng/T/easy_install-po2wjB/Pyrex-0.9.9/setup.cfg
Running Pyrex-0.9.9/setup.py -q bdist_egg --dist-dir /var/folders/rt/7_nbtrwx0q305tx_z9tk1l9538x_ng/T/easy_install-po2wjB/Pyrex-0.9.9/egg-dist-tmp-NAFu4s
zip_safe flag not set; analyzing archive contents...
Pyrex.Compiler.Scanning: module references __file__
creating /private/tmp/mylib/venv/lib/python2.7/site-packages/Pyrex-0.9.9-py2.7.egg
Extracting Pyrex-0.9.9-py2.7.egg to /private/tmp/mylib/venv/lib/python2.7/site-packages
Adding Pyrex 0.9.9 to easy-install.pth file
Installing pyrexc script to /private/tmp/mylib/venv/bin
Installed /private/tmp/mylib/venv/lib/python2.7/site-packages/Pyrex-0.9.9-py2.7.egg
Finished processing dependencies for mylib==1.0.0
Кажется, его работает gggggg.....
Теперь я хочу использовать эту библиотеку в моем приложении myapp
$ tree myapp/
myapp/
└── requirements.txt
requirements.txt
$ cat requirements.txt
mock
/tmp/mylib/
созданный virtualenv
и попробуйте установить все пакеты из requirements.txt
,
$ virtualenv venv
New python executable in /private/tmp/myapp/venv/bin/python
Installing setuptools, pip, wheel...done.
$ ./venv/bin/pip install -r requirements.txt
Processing /tmp/mylib
Collecting mock (from -r requirements.txt (line 1))
Using cached mock-2.0.0-py2.py3-none-any.whl
Collecting pyrex (from mylib==1.0.0->-r requirements.txt (line 2))
Could not find a version that satisfies the requirement pyrex (from mylib==1.0.0->-r requirements.txt (line 2)) (from versions: )
No matching distribution found for pyrex (from mylib==1.0.0->-r requirements.txt (line 2))
Этот сбой, из-за pyrex
пакет не найден который нужен для mylib
,
Я уже упоминал в mylib/setup.py
откуда скачать этот пакет, но может я что то не так сделал.
Я нашел решение, чтобы добавить полный URL-адрес, прежде чем pyrex
в requirements.txt
до mylib
установить.
requirements.txt
$ cat requirements.txt
http://www.cosc.canterbury.ac.nz/greg.ewing/python/Pyrex/Pyrex-0.9.9.tar.gz
mock
/tmp/mylib/
После этого изменения работает нормально
$ ./venv/bin/pip install -r requirements.txt
Collecting http://www.cosc.canterbury.ac.nz/greg.ewing/python/Pyrex/Pyrex-0.9.9.tar.gz (from -r requirements.txt (line 1))
Downloading http://www.cosc.canterbury.ac.nz/greg.ewing/python/Pyrex/Pyrex-0.9.9.tar.gz (255kB)
100% |████████████████████████████████| 256kB 295kB/s
Processing /tmp/mylib
Collecting mock (from -r requirements.txt (line 2))
Using cached mock-2.0.0-py2.py3-none-any.whl
Collecting pytz (from mylib==1.0.0->-r requirements.txt (line 3))
Using cached pytz-2017.3-py2.py3-none-any.whl
Collecting funcsigs>=1; python_version < "3.3" (from mock->-r requirements.txt (line 2))
Using cached funcsigs-1.0.2-py2.py3-none-any.whl
Collecting six>=1.9 (from mock->-r requirements.txt (line 2))
Using cached six-1.11.0-py2.py3-none-any.whl
Collecting pbr>=0.11 (from mock->-r requirements.txt (line 2))
Using cached pbr-3.1.1-py2.py3-none-any.whl
Building wheels for collected packages: Pyrex
Running setup.py bdist_wheel for Pyrex ... done
Stored in directory: /Users/nile2691/Library/Caches/pip/wheels/a9/f5/7c/6e2b955f0fd0298d1cef1c7997f6e930f17f3ea3279acf8ed7
Successfully built Pyrex
Installing collected packages: funcsigs, six, pbr, mock, Pyrex, pytz, mylib
Running setup.py install for mylib ... done
Successfully installed Pyrex-0.9.9 funcsigs-1.0.2 mock-2.0.0 mylib-1.0.0 pbr-3.1.1 pytz-2017.3 six-1.11.0
Но проблема в том, если я добавлю несколько новых pypi
пакет в mylib
Я должен обновить requirements.txt
для всех применений приложения mylib
,
Есть ли лучший способ автоматизировать это? Например, когда какое-то приложение устанавливается mylib
он автоматически установит все необходимые пакеты для этого.