我想使用 setup.py 及其所有功能,但我不想为可安装项目构建轮子。是否有旗帜或其他东西只是跳过建筑轮子?
这背后的原因是我使用 setuptools 提供的自定义 InstallCommand 将环境变量传递给下一个可安装项目(依赖项),并且在构建轮子时 - 看不到环境变量,因此只有安装(不是轮子构建)有效。
编辑:
由于我使用的是构建选项,我收到警告:
pip/_internal/commands/install.py:211:用户警告:由于使用了--build-options/--global-options/--install-options,禁用了所有轮子的使用。
由于我使用了这个自定义的 InstallCommand:
class InstallCommand(install):
user_options = install.user_options + [
('environment=', None, 'Specify a production or development environment.'),
]
def initialize_options(self):
install.initialize_options(self)
self.environment = None
def finalize_options(self):
install.finalize_options(self)
global ENVIRONMENT
try:
# Check if environment is set
is_dev()
except AssertionError:
# If not - assert that this class has a set environment
assert self.environment in ['dev', 'prod'], 'Bad environment propagated from parent project.'
ENVIRONMENT = self.environment
def run(self):
install.run(self)
我收到此错误:
installing to build/bdist.linux-x86_64/wheel
running install
Traceback (most recent call last):
File "/tmp/pip-req-build-xnp6kolm/setup_helper.py", line 26, in finalize_options
is_dev()
File "/tmp/pip-req-build-xnp6kolm/setup_helper.py", line 126, in is_dev
assert (prod or dev) is True, 'Environment should be set to dev or prod'
AssertionError: Environment should be set to dev or prod
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/tmp/pip-req-build-xnp6kolm/setup_helper.py", line 29, in finalize_options
assert self.environment in ['dev', 'prod'], 'Bad environment propagated from parent project.'
AssertionError: Bad environment propagated from parent project.
----------------------------------------
Failed building wheel for ivs-repository-manager - HAVE A NOTICE AT THIS LINE !!! I HAVE RUN SETUP.PY INSTALL, NOT BDIST
Running setup.py clean for ivs-repository-manager
Failed to build ivs-repository-manager
但!在这个异常之后,安装仍然成功,我看到了安装的包。只是当 setuptools 尝试构建轮子时,我得到了这些错误。
因此,似乎在构建使用 --install-options 传播的轮环境时无法看到。