我的存储库包含我自己的python模块和一个具有自己的setup.py的依赖项的子模块。
我想在安装自己的lib时调用依赖关系的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
不接受路径。
我的第二次尝试是将dependency_links=["../dependency"]
与install_requires=["dependency"]
一起使用,但是Pypi中已经存在同名的依赖项,因此setuptools尝试使用该版本而不是我的版本。
什么是正确/最干净的方式?
答案 0 :(得分:0)
可能的解决方案是在安装过程之前/之后运行自定义命令。
一个例子:
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 }
)