Skip to content

PEP 517 build environment dependencies fail to install with use of --build-option #7991

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
stefansjs opened this issue Apr 6, 2020 · 3 comments
Labels
C: build isolation C: PEP 517 impact Affected by PEP 517 processing PEP implementation Involves some PEP S: needs triage Issues/PRs that need to be triaged

Comments

@stefansjs
Copy link

Environment

  • pip version: 20.0.2
  • Python version: 3.7
  • OS: Mac OS 10.14

Description
use of --build-option causes build front-end dependencies to fail to install when using PEP517 build configuration. This is confusing and leads to errors.

The basic issue (shown in logs below) is that by using the --build-option flag pip decides not to use wheels for build dependencies (which is confusing). This is an issue when using PEP517/518 which attempts to create an environment in which to build the pip wheel, but whose environment setup is altered by trying to alter the build itself

Expected behavior
The build environment should be isolated from build commands used within that environment. I should be able to control how my wheel is built in the backend without breaking the installation of my build front-end requirements. I would hope that front-end build requirements would be installed without passing --build-option down to pip wheel command. It is confusing to try to fetch build-time requirements and build them from source. If the front-end needs additional options to install them, they should be controlled using different flags then those that control building my package.

It seems like a chicken-and-egg problem to me, where using build flags means I have to build build-dependencies, which requires another level of abstraction or dependency requirements. I would somehow have to tell pip that the environment used to build build-dependencies itself has build requirements. I believe PEP 517 is meant to protect us from this entangled mess?

How to Reproduce

  • Use a pyproject.toml file like this one:
[build-system]
# https://scikit-build.readthedocs.io/en/latest/usage.html#example-of-setup-py-cmakelists-txt-and-pyproject-toml
requires = ["setuptools>=40.8.0", "wheel", "scikit-build", "numpy", "cmake==3.16.3", "cython>=0.28, <3", "cysignals==1.6.5"]
  • execute pip wheel on the source tree thusly: pip wheel path/to/source --build-option="-DCMAKE_MAKE_PROGRAM=Unix Makefiles"

Output

+ python -m pip wheel <my python source dir> --wheel-dir=_build/_wheels --build=_build '--build-option=-DCMAKE_MAKE_PROGRAM=Unix Makefiles'
Looking in indexes: https://pypi.org/simple
Processing <my python source dir>
  Installing build dependencies: started
  Installing build dependencies: still running...
/usr/local/lib/python3.7/site-packages/pip/_internal/commands/wheel.py:115: UserWarning: Disabling all use of wheels due to the use of --build-options / --global-options / --install-options.
  cmdoptions.check_install_build_global(options)
  ERROR: Command errored out with exit status 1:
   command: /usr/local/opt/python/bin/python3.7 /usr/local/lib/python3.7/site-packages/pip install --ignore-installed --no-user --prefix /private/var/folders/40/7rw2w2f12kj6lkcwbfqb1mxh0000gp/T/pip-build-env-421zz7lf/overlay --no-warn-script-location --no-binary :all: --only-binary :none: -i https://pypi.org/simple -- 'setuptools>=40.8.0' wheel scikit-build numpy cmake==3.16.3 'cython==0.25.1; python_version<='"'"'2.7'"'"'' 'cython>=0.28, <3; python_version>'"'"'2.7'"'"'' cysignals==1.6.5
       cwd: None
  Complete output (29 lines):
  Ignoring cython: markers 'python_version <= "2.7"' don't match your environment
  Looking in indexes: https://pypi.org/simple
  Collecting setuptools>=40.8.0
    Using cached https://files.pythonhosted.org/packages/b5/96/af1686ea8c1e503f4a81223d4a3410e7587fd52df03083de24161d0df7d4/setuptools-46.1.3.zip
  Collecting wheel
    Using cached https://files.pythonhosted.org/packages/75/28/521c6dc7fef23a68368efefdcd682f5b3d1d58c2b90b06dc1d0b805b51ae/wheel-0.34.2.tar.gz
  Collecting scikit-build
    Using cached https://files.pythonhosted.org/packages/9f/6b/9c193b2402969b2f3ef5e8105a434a9d4274df9b8315699225072217322a/scikit-build-0.10.0.tar.gz
  Collecting numpy
    Using cached https://files.pythonhosted.org/packages/84/1e/ff467ac56bfeaea51d4a2e72d315c1fe440b20192fea7e460f0f248acac8/numpy-1.18.2.zip
    Installing build dependencies: started
    Installing build dependencies: finished with status 'done'
    Getting requirements to build wheel: started
    Getting requirements to build wheel: finished with status 'done'
      Preparing wheel metadata: started
      Preparing wheel metadata: finished with status 'done'
  Collecting cmake==3.16.3
    Using cached https://files.pythonhosted.org/packages/a5/7c/6525cadf99abbabbcb29676f53de0441e8d2f8d0114ab52aae2b31223a3b/cmake-3.16.3.tar.gz
      ERROR: Command errored out with exit status 1:
       command: /usr/local/opt/python/bin/python3.7 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/40/7rw2w2f12kj6lkcwbfqb1mxh0000gp/T/pip-install-m_nrlzxl/cmake/setup.py'"'"'; __file__='"'"'/private/var/folders/40/7rw2w2f12kj6lkcwbfqb1mxh0000gp/T/pip-install-m_nrlzxl/cmake/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /private/var/folders/40/7rw2w2f12kj6lkcwbfqb1mxh0000gp/T/pip-install-m_nrlzxl/cmake/pip-egg-info
           cwd: /private/var/folders/40/7rw2w2f12kj6lkcwbfqb1mxh0000gp/T/pip-install-m_nrlzxl/cmake/
      Complete output (5 lines):
      Traceback (most recent call last):
        File "<string>", line 1, in <module>
        File "/private/var/folders/40/7rw2w2f12kj6lkcwbfqb1mxh0000gp/T/pip-install-m_nrlzxl/cmake/setup.py", line 7, in <module>
          from skbuild import setup
      ModuleNotFoundError: No module named 'skbuild'
      ----------------------------------------
  ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
  ----------------------------------------
  Installing build dependencies: finished with status 'error'
ERROR: Command errored out with exit status 1: /usr/local/opt/python/bin/python3.7 /usr/local/lib/python3.7/site-packages/pip install --ignore-installed --no-user --prefix /private/var/folders/40/7rw2w2f12kj6lkcwbfqb1mxh0000gp/T/pip-build-env-421zz7lf/overlay --no-warn-script-location --no-binary :all: --only-binary :none: -i https://pypi.org/simple --extra-index-url http://sfw.sf.smle.co:8080/sfw/pip --trusted-host sfw.sf.smle.co -- 'setuptools>=40.8.0' wheel scikit-build numpy cmake==3.16.3 'cython==0.25.1; python_version<='"'"'2.7'"'"'' 'cython>=0.28, <3; python_version>'"'"'2.7'"'"'' cysignals==1.6.5 Check the logs for full command output.

Process finished with exit code 1

Alternative
Similarly, the same error occurs when configuring the back-end environment if I shift responsibilities to the build backend by using a pyproject.toml with fewer requirements:

[build-system]
# https://scikit-build.readthedocs.io/en/latest/usage.html#example-of-setup-py-cmakelists-txt-and-pyproject-toml
requires = ["setuptools>=40.8.0", "wheel", "scikit-build"]

and moving some dependencies to the back-end by using a setup.py with setup_requires thusly:

          setup_requires=['cmake==3.16.3',
                          "cython==0.25.1; python_version<='2.7'",
                          "cython>=0.28, <3; python_version>'2.7'",
                          'cysignals==1.6.5',  # cython and cysignals are used to compile pyx files
                          ],

then I get similar output, but complaining about the build backend instead of the frontend:

pip wheel /path/to/source --wheel-dir=_build/_wheels --build=_build '--build-option=-DCMAKE_MAKE_PROGRAM=Unix Makefiles'
Looking in indexes: https://pypi.org/simple
Processing path/to/source
  Installing build dependencies: started
  Installing build dependencies: still running...
  Installing build dependencies: still running...
  Installing build dependencies: finished with status 'done'
  Getting requirements to build wheel: started
  Getting requirements to build wheel: finished with status 'done'
  Installing backend dependencies: started
  Installing backend dependencies: finished with status 'error'
/usr/local/lib/python3.7/site-packages/pip/_internal/commands/wheel.py:115: UserWarning: Disabling all use of wheels due to the use of --build-options / --global-options / --install-options.
  cmdoptions.check_install_build_global(options)
  ERROR: Command errored out with exit status 1:
   command: /usr/local/opt/python/bin/python3.7 /usr/local/lib/python3.7/site-packages/pip install --ignore-installed --no-user --prefix /private/var/folders/40/7rw2w2f12kj6lkcwbfqb1mxh0000gp/T/pip-build-env-mriw6mps/normal --no-warn-script-location --no-binary :all: --only-binary :none: -i https://pypi.org/simple -- 'cython==0.25.1; python_version <= "2.7"' cmake==3.16.3 'cython<3,>=0.28; python_version > "2.7"' cysignals==1.6.5
       cwd: None
  Complete output (15 lines):
  Ignoring cython: markers 'python_version <= "2.7"' don't match your environment
  Looking in indexes: https://pypi.org/simple
  Collecting cmake==3.16.3
    Using cached https://files.pythonhosted.org/packages/a5/7c/6525cadf99abbabbcb29676f53de0441e8d2f8d0114ab52aae2b31223a3b/cmake-3.16.3.tar.gz
      ERROR: Command errored out with exit status 1:
       command: /usr/local/opt/python/bin/python3.7 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/40/7rw2w2f12kj6lkcwbfqb1mxh0000gp/T/pip-install-qcmlecsl/cmake/setup.py'"'"'; __file__='"'"'/private/var/folders/40/7rw2w2f12kj6lkcwbfqb1mxh0000gp/T/pip-install-qcmlecsl/cmake/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /private/var/folders/40/7rw2w2f12kj6lkcwbfqb1mxh0000gp/T/pip-install-qcmlecsl/cmake/pip-egg-info
           cwd: /private/var/folders/40/7rw2w2f12kj6lkcwbfqb1mxh0000gp/T/pip-install-qcmlecsl/cmake/
      Complete output (5 lines):
      Traceback (most recent call last):
        File "<string>", line 1, in <module>
        File "/private/var/folders/40/7rw2w2f12kj6lkcwbfqb1mxh0000gp/T/pip-install-qcmlecsl/cmake/setup.py", line 7, in <module>
          from skbuild import setup
      ModuleNotFoundError: No module named 'skbuild'
      ----------------------------------------
  ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
  ----------------------------------------
ERROR: Command errored out with exit status 1: /usr/local/opt/python/bin/python3.7 /usr/local/lib/python3.7/site-packages/pip install --ignore-installed --no-user --prefix /private/var/folders/40/7rw2w2f12kj6lkcwbfqb1mxh0000gp/T/pip-build-env-mriw6mps/normal --no-warn-script-location --no-binary :all: --only-binary :none: -i https://pypi.org/simple -- 'cython==0.25.1; python_version <= "2.7"' cmake==3.16.3 'cython<3,>=0.28; python_version > "2.7"' cysignals==1.6.5 Check the logs for full command output.
@e2thenegpii
Copy link

This affects my build system as well and I would like to see the ability to pass in parameters to bdist_wheel with out completely disabling the usage of binary distributions. My current work around is to set an environment variable and then in setup.py parse the env var and modify the distribution object as necessary.

@uranusjr
Copy link
Member

PEP 517 does provide hooks to pass in build options (config_settings). Feel free to dig into the source code and diagnose what is preventing the build options being passed into the build backend (setuptools) if you’re interested in resolving the issue.

@pradyunsg pradyunsg added C: PEP 517 impact Affected by PEP 517 processing PEP implementation Involves some PEP labels Aug 30, 2020
@pradyunsg
Copy link
Member

Feel free to dig into the source code and diagnose what is preventing the build options being passed into the build backend (setuptools) if you’re interested in resolving the issue.

The fact that the support for these isn't implemented in pip yet -- see #5771.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C: build isolation C: PEP 517 impact Affected by PEP 517 processing PEP implementation Involves some PEP S: needs triage Issues/PRs that need to be triaged
Projects
None yet
Development

No branches or pull requests

5 participants