主题是自描述的:我需要子setup.py build命令命令以执行其他构建步骤.但是我找不到任何build要继承的命令类.我一直在努力:
class BuildCommandProxy(setuptools.command.build):
pass
Run Code Online (Sandbox Code Playgroud)
和
class BuildCommandProxy(distutils.command.build):
pass
Run Code Online (Sandbox Code Playgroud)
乃至:
class BuildCommandProxy(setuptools.distutils.command.build):
pass
Run Code Online (Sandbox Code Playgroud)
没有任何成功.
UPDATE:寻找如何实现像这样用setuptools.
UPDATE2:我有一些自定义命令实现:
class CustomCommand(setuptools.Command):
# ...
Run Code Online (Sandbox Code Playgroud)
我想要实现的是将此命令传递给cmdclass:
cmdclass={
"build": CustomCommand,
}
Run Code Online (Sandbox Code Playgroud)
然后调用原来build在CustomCommand.run做一些自定义的步骤之后.
我制作了一个需要执行 C 函数的 Python 应用程序。为此,我使用 gcc 在共享库中编译了 C 函数,并使用 ctypes 在我的 Python 脚本中调用了该库。
我正在尝试将我的应用程序打包到 pip 包中,但发现无法在 pip 安装时创建共享库。
我尝试了以下(setup.py):
from setuptools import setup
from setuptools.command.install import install
import subprocess
class compileLibrary(install):
def run(self):
install.run(self)
command = "cd packageName"
command += " && git clone https://mygit.com/myAwesomeCLibrary.git"
command += " && gcc -my -many -options"
process = subprocess.Popen(command, shell=True)
process.wait()
setup(
name='packageName',
version='0.1',
packages=['packageName'],
install_requires=[
...
],
cmdclass={'install': compileLibrary},
Run Code Online (Sandbox Code Playgroud)
)
这在执行python setup.py install时有效,但是从 pip 安装时,当安装过程成功时,共享库不在包文件夹 ( pythonx.x/site-packages/packageName) 中。
我尝试使用 …