【发布时间】:2019-07-01 11:08:48
【问题描述】:
我想使用 setup.py 及其所有功能,但我不想为可安装项目构建轮子。有没有标志或其他东西只是跳过了造轮子?
这背后的原因是我使用 setuptools 提供的自定义 InstallCommand 将环境变量传递给下一个可安装项目(依赖项),并且在构建轮子时 - 看不到环境变量,因此只有安装(不是轮子构建)有效.
编辑:
由于我正在使用构建选项,我收到警告:
pip/_internal/commands/install.py:211: UserWarning: 由于使用了 --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传播的轮子环境时无法看到。
【问题讨论】:
-
好吧,就是不建,有什么问题?
-
感谢您的反对。是不是在运行 setup.py install 的时候会自动构建wheel?
-
如果你想造一个轮子,你就跑
python setup.py bdist_wheel,如果你不想要wheel——你不要这样做 -
让我在 EDIT 中进一步解释一下。
-
pip install pkgname --no-binary=pkgname
标签: python setuptools setup.py python-wheel python-install