我的存储库包含我自己的python模块和它的一个依赖项的子模块,该子模块具有自己的setup.py。
我想在安装自己的库时调用依赖项的setupy.py,这是怎么可能的?
我的第一次尝试:
$ tree
.
├── dependency
│ └── setup.py
└── mylib
└── setup.py
$ cat mylib/setup.py
from setuptools import setup
setup(
name='mylib',
install_requires= ["../dependency"]
# ...
)
$ cd mylib && python setup.py install
error in arbalet_core setup command: 'install_requires' must be a string or list of strings containing valid project/version requirement specifiers; Invalid requirement, parse error at "'../depen'"但是,install_requires不接受路径。
我的第二个尝试是在install_requires=["dependency"]中使用dependency_links=["../dependency"],但是在Pypi中已经存在相同名称的依赖项,所以setuptools尝试使用该版本而不是我的版本。
最正确/最干净的方法是什么?
发布于 2017-08-10 05:15:38
一种可能的解决方案是在安装过程之前/之后运行一个自定义命令。
举个例子:
from setuptools import setup
from setuptools.command.install import install
import subprocess
class InstallLocalPackage(install):
def run(self):
install.run(self)
subprocess.call(
"python path_to/local_pkg/setup.py install", shell=True
)
setup(
...,
cmdclass={ 'install': InstallLocalPackage }
)https://stackoverflow.com/questions/40831794
复制相似问题