Python的setup.py - 运行setup.py安装时不要建轮

问题描述 投票:-1回答:1

我想用setup.py和它的所有功能,但我不希望有一个轮为安装项目建成。有没有标志或财产以后就跳过建筑轮?

这背后的原因是,我使用的setuptools提供的自定义InstallCommand通过环境变量到下一个项目安装(依赖),建设滚轮时 - 环境变量没有看到,因此只能安装(不轮建筑物)的作品。

编辑:

由于我使用的编译选项,我得到的警告:

PIP / _internal /命令/ install.py:211:UserWarning:禁用所有使用车轮由于使用的--build选项/ --global选项/ --install选项。

而且,由于我使用这个自定义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选项传播环境轮时,无法看到。

python setuptools setup.py python-wheel python-install
1个回答
0
投票

找到了解决办法:

不要使用setup.py安装,更好地创造一个源代码分发setup.py sdist,然后用PIP安装。这是例子:

python setup.py sdist
python -m pip install dist/* --install-option=--environment='dev'
© www.soinside.com 2019 - 2024. All rights reserved.