cfl*_*wis 21 python pip setuptools
当用户发出安装原始软件的命令时,我想在pit上安装我在GitHub上的依赖项,也可以从GitHub上的源代码安装.这些软件包都不在PyPi上(永远不会).
用户发出命令:
pip -e git+https://github.com/Lewisham/cvsanaly@develop#egg=cvsanaly
Run Code Online (Sandbox Code Playgroud)
这个repo有一个requirements.txt文件,另一个依赖于GitHub:
-e git+https://github.com/Lewisham/repositoryhandler#egg=repositoryhandler
Run Code Online (Sandbox Code Playgroud)
我想是一个命令,一个用户可以发出来安装原包,有点子找到要求的文件,然后安装依赖了.
Gab*_*ant 36
这个答案帮助我解决了你所说的同样问题.
似乎没有一种简单的方法可以让setup.py直接使用需求文件来定义它的依赖关系,但是可以将相同的信息放入setup.py本身.
我有这个要求.txt:
PIL
-e git://github.com/gabrielgrant/django-ckeditor.git#egg=django-ckeditor
Run Code Online (Sandbox Code Playgroud)
但是在安装requires.txt包含的包时,pip会忽略这些要求.
这个setup.py似乎强迫pip安装依赖项(包括我的github版本的django-ckeditor):
from setuptools import setup
setup(
name='django-articles',
...,
install_requires=[
'PIL',
'django-ckeditor>=0.9.3',
],
dependency_links = [
'http://github.com/gabrielgrant/django-ckeditor/tarball/master#egg=django-ckeditor-0.9.3',
]
)
Run Code Online (Sandbox Code Playgroud)
编辑:
这个答案还包含一些有用的信息.
将版本指定为"#egg = ..."的一部分,需要确定链接上可用的软件包版本.但请注意,如果您总是希望依赖于最新版本,则可以将版本设置为devinstall_requires,dependency_links和其他软件包的setup.py.
编辑:使用dev版本不是一个好主意,如下面的评论.
Sim*_*tte 13
下面是我用来生成一个小的脚本install_requires,并dependency_links从需求文件.
import os
import re
def which(program):
"""
Detect whether or not a program is installed.
Thanks to http://stackoverflow.com/a/377028/70191
"""
def is_exe(fpath):
return os.path.exists(fpath) and os.access(fpath, os.X_OK)
fpath, _ = os.path.split(program)
if fpath:
if is_exe(program):
return program
else:
for path in os.environ['PATH'].split(os.pathsep):
exe_file = os.path.join(path, program)
if is_exe(exe_file):
return exe_file
return None
EDITABLE_REQUIREMENT = re.compile(r'^-e (?P<link>(?P<vcs>git|svn|hg|bzr).+#egg=(?P<package>.+)-(?P<version>\d(?:\.\d)*))$')
install_requires = []
dependency_links = []
for requirement in (l.strip() for l in open('requirements')):
match = EDITABLE_REQUIREMENT.match(requirement)
if match:
assert which(match.group('vcs')) is not None, \
"VCS '%(vcs)s' must be installed in order to install %(link)s" % match.groupdict()
install_requires.append("%(package)s==%(version)s" % match.groupdict())
dependency_links.append(match.group('link'))
else:
install_requires.append(requirement)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
9723 次 |
| 最近记录: |