简体   繁体   中英

Python setup.py - dont build wheel when running setup.py install

I want to use setup.py and all it's functionality but I don't want a wheel to be built for the installable project. Is there a flag or somthing just skip building wheel?

The reason behind this is I am using a custom InstallCommand provided by setuptools to pass the environment variables to the next installable project (dependency) and when building wheel - environment variables are not seen, therefore only installation (not wheel building) works.

EDIT:

Since I am using build options I get warning:

pip/_internal/commands/install.py:211: UserWarning: Disabling all use of wheels due to the use of --build-options / --global-options / --install-options.

And since I use this custom 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)

I get this error:

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

BUT! After this exception the isntallation still succeeds and i see the installed package. Its just I get these errors when setuptools try to to build wheel.

So it seems that when building wheel environment propagated with --install-options can not be seen.

Found the solution:

Do not use setup.py install, better create a source distribution setup.py sdist and then install with pip. This is the example:

python setup.py sdist
python -m pip install dist/* --install-option=--environment='dev'

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM