我有一些协议缓冲区定义需要作为pip install过程的一部分构建到 Python 源代码中。我已经对setuptools.command.install命令进行了子类化,setup.py但我认为它会在安装包后尝试运行 Makefile,因此无法识别源。
我找不到有关 pip 安装期间发生的情况的信息。任何人都可以发光吗?
设置.py:
import subprocess
import sys
from setuptools import setup
from setuptools.command.install import install
class Install(install):
"""Customized setuptools install command - builds protos on install."""
def run(self):
protoc_command = ["make", "python"]
if subprocess.call(protoc_command) != 0:
sys.exit(-1)
install.run(self)
setup(
name='myprotos',
version='0.0.1',
description='Protocol Buffers.',
install_requires=[],
cmdclass={
'install': Install,
}
)
Run Code Online (Sandbox Code Playgroud)
的输出$ pip install -vvv .:
Processing /path/to/myprotos
Running setup.py (path:/private/var/folders/3t/4qwkfyr903d0b7db7by2kj6r0000gn/T/pip-jpgCby-build/setup.py) egg_info for package from file:///path/to/myprotos
Running command …Run Code Online (Sandbox Code Playgroud)