Skip to content

Build isolation can be a problem with the python-for-android cross compile environment, but disabling it also disables build-system.requires breaking some package installs #6718

Open
@ghost

Description

Environment

  • pip version: latest on pypi right now - installed via -U pip - should be 19.1.1
  • Python version: 3.7
  • OS: ubuntu in docker, host is fedora 29 x64

Description
I have run into a case where when I specify --no-build-isolation, pip will install dependencies out of order and if any of these dependencies has a pyproject.toml, apparently pip may try to obtain wheel metadata of that dependency (by running its setup.py) without ensuring pyproject.toml's build-system.requires packages are around. This seems like a bug to me, because isn't the entire point of build-system.requires that these packages need to be around for the package to build or even run the setup.py correctly, no matter if the build is isolated or not?

I am also quite practically impacted by this bug or behavior because 1. I need to use pyproject.toml in dependencies due to setup_requires not liking Cython (the easy_install sandbox messes with the Cython compiler) and I use Cython .pxd deps which install_requires doesn't guarantee to be around at build, and 2. I am in a cross compilation environment (python-for-android) where --no-build-isolation is required for all builds because some packages cannot be installed without custom patching, so it's not safe for pip to temporarily reinstall some things as is inherently happening with the build isolation

Expected behavior
no setup.py is ever run even if just for obtaining wheel metadata without everything in build_requires being installed, even if --no-build-isolation is used

How to Reproduce

I don't have an example package right now, really sorry 😢 (because this all happened in python-for-android) but this should work:

  1. Create new project using setup.py in a new folder /my/project/path
  2. Specify a package as a dep that needs another one at build time, e.g. like pip install git+git://github.com/wobblui/wobblui@562daf6e796fdf8d8a50733b532f9cacae4d4df5 (later commits have a workaround!) - wobblui depends on https://github.com/JonasT/nettools for building the wheel and specifies this in its pyproject.toml/with build-system.requires
  3. Install your new project using cd /my/project/path && pip install --user -U --no-build-isolation .
  4. Keep fingers crossed that pip chooses an unlucky order for the deps, and indeed tries to e.g. generate wobblui wheel metadata before it tried to install nettools (which is what happened for me)

Output

(really sorry this looks so weird, it's in python-for-android)


[INFO]:    Launching package install...
[DEBUG]:   -> running bash -c '/home/userhome/.local/share/python-for-android/build/venv/bin/pip' install --no-build-isolation -c ._tmp_p4a_recipe_constraints.txt .
[DEBUG]:   	Processing /home/userhome/workspace
[DEBUG]:   	    Preparing wheel metadata ... done
[DEBUG]:   	Requirement already satisfied: Cython==0.29.12 in /home/userhome/.local/share/python-for-android/build/venv/lib/python3.6/site-packages (from -c ._tmp_p4a_recipe_constraints.txt (line 2)) (0.29.12)
[DEBUG]:   	Requirement already satisfied: Pillow==5.2.0 in /home/userhome/.local/share/python-for-android/build/python-installs/unnamed_dist_1 (from -c ._tmp_p4a_recipe_constraints.txt (line 3)) (5.2.0)
[DEBUG]:   	Collecting sfxscan@ git+https://github.com/JonasT/sfxscan.git# from git+https://github.com/JonasT/sfxscan.git (from myapp==0.1)
[DEBUG]:   	  Cloning https://github.com/JonasT/sfxscan.git to /tmp/pip-install-oyi75skp/sfxscan
[DEBUG]:   	  Running command git clone -q https://github.com/JonasT/sfxscan.git /tmp/pip-install-oyi75skp/sfxscan
[DEBUG]:   	  Running command git submodule update --init --recursive -q
[DEBUG]:   	    Preparing wheel metadata ... done
[DEBUG]:   	Collecting wobblui@ https://github.com/wobblui/wobblui/archive/master.zip# from https://github.com/wobblui/wobblui/archive/master.zip (from myapp==0.1)
[DEBUG]:   	  Downloading https://github.com/wobblui/wobblui/archive/master.zip (1.4MB)
     |################################| 1.4MB 390kB/s
[DEBUG]:   	    Preparing wheel metadata ... error
[DEBUG]:   	    ERROR: Complete output from command /home/userhome/.local/share/python-for-android/build/venv/bin/python3 /home/userhome/.local/share/python-for-android/build/venv/lib/python3.6/site-packages/pip/_vendor/pep517/_in_process.py prepare_metadata_for_build_wheel /tmp/tmpz5xnpef1:
[DEBUG]:   	    ERROR: Compiling /tmp/pip-install-oyi75skp/wobblui/src/wobblui/image.pyx because it changed.
[DEBUG]:   	    [1/1] Cythonizing /tmp/pip-install-oyi75skp/wobblui/src/wobblui/image.pyx
[DEBUG]:   	    Compiling /tmp/pip-install-oyi75skp/wobblui/src/wobblui/filedialog.pyx because it changed.
[DEBUG]:   	    [1/1] Cythonizing /tmp/pip-install-oyi75skp/wobblui/src/wobblui/filedialog.pyx
[DEBUG]:   	    Compiling /tmp/pip-install-oyi75skp/wobblui/src/wobblui/button.pyx because it changed.
[DEBUG]:   	    [1/1] Cythonizing /tmp/pip-install-oyi75skp/wobblui/src/wobblui/button.pyx
[DEBUG]:   	    Compiling /tmp/pip-install-oyi75skp/wobblui/src/wobblui/woblog.pyx because it changed.
[DEBUG]:   	    [1/1] Cythonizing /tmp/pip-install-oyi75skp/wobblui/src/wobblui/woblog.pyx
[DEBUG]:   	    Compiling /tmp/pip-install-oyi75skp/wobblui/src/wobblui/label.pyx because it changed.
[DEBUG]:   	    [1/1] Cythonizing /tmp/pip-install-oyi75skp/wobblui/src/wobblui/label.pyx
[DEBUG]:   	    Compiling /tmp/pip-install-oyi75skp/wobblui/src/wobblui/perf.pyx because it changed.
[DEBUG]:   	    [1/1] Cythonizing /tmp/pip-install-oyi75skp/wobblui/src/wobblui/perf.pyx
[DEBUG]:   	    Compiling /tmp/pip-install-oyi75skp/wobblui/src/wobblui/texture.pyx because it changed.
[DEBUG]:   	    [1/1] Cythonizing /tmp/pip-install-oyi75skp/wobblui/src/wobblui/texture.pyx
[DEBUG]:   	    Compiling /tmp/pip-install-oyi75skp/wobblui/src/wobblui/timer.pyx because it changed.
[DEBUG]:   	    [1/1] Cythonizing /tmp/pip-install-oyi75skp/wobblui/src/wobblui/timer.pyx
[DEBUG]:   	    Compiling /tmp/pip-install-oyi75skp/wobblui/src/wobblui/modal.pyx because it changed.
[DEBUG]:   	    [1/1] Cythonizing /tmp/pip-install-oyi75skp/wobblui/src/wobblui/modal.pyx
[DEBUG]:   	    Compiling /tmp/pip-install-oyi75skp/wobblui/src/wobblui/textedit.pyx because it changed.
[DEBUG]:   	    [1/1] Cythonizing /tmp/pip-install-oyi75skp/wobblui/src/wobblui/textedit.pyx
[DEBUG]:   	    Compiling /tmp/pip-install-oyi75skp/wobblui/src/wobblui/widget.pyx because it changed.
[DEBUG]:   	    [1/1] Cythonizing /tmp/pip-install-oyi75skp/wobblui/src/wobblui/widget.pyx
[DEBUG]:   	    Compiling /tmp/pip-install-oyi75skp/wobblui/src/wobblui/osinfo.pyx because it changed.
[DEBUG]:   	    [1/1] Cythonizing /tmp/pip-install-oyi75skp/wobblui/src/wobblui/osinfo.pyx
[DEBUG]:   	    Compiling /tmp/pip-install-oyi75skp/wobblui/src/wobblui/color.pyx because it changed.
[DEBUG]:   	    [1/1] Cythonizing /tmp/pip-install-oyi75skp/wobblui/src/wobblui/color.pyx
[DEBUG]:   	    Compiling /tmp/pip-install-oyi75skp/wobblui/src/wobblui/box.pyx because it changed.
[DEBUG]:   	    [1/1] Cythonizing /tmp/pip-install-oyi75skp/wobblui/src/wobblui/box.pyx
[DEBUG]:   	    Compiling /tmp/pip-install-oyi75skp/wobblui/src/wobblui/list.pyx because it changed.
[DEBUG]:   	    [1/1] Cythonizing /tmp/pip-install-oyi75skp/wobblui/src/wobblui/list.pyx
[DEBUG]:   	    Compiling /tmp/pip-install-oyi75skp/wobblui/src/wobblui/dragselection.pyx because it changed.
[DEBUG]:   	    [1/1] Cythonizing /tmp/pip-install-oyi75skp/wobblui/src/wobblui/dragselection.pyx
[DEBUG]:   	    Compiling /tmp/pip-install-oyi75skp/wobblui/src/wobblui/cache.pyx because it changed.
[DEBUG]:   	    [1/1] Cythonizing /tmp/pip-install-oyi75skp/wobblui/src/wobblui/cache.pyx
[DEBUG]:   	    Compiling /tmp/pip-install-oyi75skp/wobblui/src/wobblui/__init__.pyx because it changed.
[DEBUG]:   	    [1/1] Cythonizing /tmp/pip-install-oyi75skp/wobblui/src/wobblui/__init__.pyx
[DEBUG]:   	    Compiling /tmp/pip-install-oyi75skp/wobblui/src/wobblui/widget_base_borderdraw.pyx because it changed.
[DEBUG]:   	    [1/1] Cythonizing /tmp/pip-install-oyi75skp/wobblui/src/wobblui/widget_base_borderdraw.pyx
[DEBUG]:   	    Compiling /tmp/pip-install-oyi75skp/wobblui/src/wobblui/gfx.pyx because it changed.
[DEBUG]:   	    [1/1] Cythonizing /tmp/pip-install-oyi75skp/wobblui/src/wobblui/gfx.pyx
[DEBUG]:   	    Compiling /tmp/pip-install-oyi75skp/wobblui/src/wobblui/scrollbarwidget.pyx because it changed.
[DEBUG]:   	    [1/1] Cythonizing /tmp/pip-install-oyi75skp/wobblui/src/wobblui/scrollbarwidget.pyx
[DEBUG]:   	    Compiling /tmp/pip-install-oyi75skp/wobblui/src/wobblui/window.pyx because it changed.
[DEBUG]:   	    [1/1] Cythonizing /tmp/pip-install-oyi75skp/wobblui/src/wobblui/window.pyx
[DEBUG]:   	
[DEBUG]:   	    Error compiling Cython file:
[DEBUG]:   	    ------------------------------------------------------------
[DEBUG]:   	    ...
[DEBUG]:   	    import sys
[DEBUG]:   	    import time
[DEBUG]:   	    import traceback
[DEBUG]:   	    import weakref
[DEBUG]:   	
[DEBUG]:   	    from nettools.cssparse cimport parse as cssparse
[DEBUG]:   	    ^
[DEBUG]:   	    ------------------------------------------------------------
[DEBUG]:   	
[DEBUG]:   	    src/wobblui/widget_base.pyx:33:0: 'nettools/cssparse.pxd' not found
[DEBUG]:   	
[DEBUG]:   	    Error compiling Cython file:
[DEBUG]:   	    ------------------------------------------------------------
[DEBUG]:   	    ...
[DEBUG]:   	    import sys
[DEBUG]:   	    import time
[DEBUG]:   	    import traceback
[DEBUG]:   	    import weakref
[DEBUG]:   	
[DEBUG]:   	    from nettools.cssparse cimport parse as cssparse
[DEBUG]:   	    ^
[DEBUG]:   	    ------------------------------------------------------------
[DEBUG]:   	
[DEBUG]:   	    src/wobblui/widget_base.pyx:33:0: 'nettools/cssparse/parse.pxd' not found
[DEBUG]:   	
[DEBUG]:   	    Error compiling Cython file:
[DEBUG]:   	    ------------------------------------------------------------
[DEBUG]:   	    ...
[DEBUG]:   	            if self._cached_custom_css_ruleset is not None:
[DEBUG]:   	                return self._cached_custom_css_ruleset
[DEBUG]:   	            if self._own_custom_css is None or \
[DEBUG]:   	                    len(self._own_custom_css.strip()) == 0:
[DEBUG]:   	                return None
[DEBUG]:   	            self._cached_custom_css_ruleset = cssparse(
[DEBUG]:   	                                             ^
[DEBUG]:   	    ------------------------------------------------------------
[DEBUG]:   	
[DEBUG]:   	    src/wobblui/widget_base.pyx:382:42: 'cssparse' is not a constant, variable or function identifier
[DEBUG]:   	
[DEBUG]:   	    Error compiling Cython file:
[DEBUG]:   	    ------------------------------------------------------------
[DEBUG]:   	    ...
[DEBUG]:   	            if self._cached_custom_css_ruleset_for_children is not None:
[DEBUG]:   	                return self._cached_custom_css_ruleset_for_children
[DEBUG]:   	            if self._children_custom_css is None or \
[DEBUG]:   	                    len(self._children_custom_css.strip()) == 0:
[DEBUG]:   	                return
[DEBUG]:   	            self._cached_custom_css_ruleset_for_children = cssparse(
[DEBUG]:   	                                                          ^
[DEBUG]:   	    ------------------------------------------------------------
[DEBUG]:   	
[DEBUG]:   	    src/wobblui/widget_base.pyx:394:55: 'cssparse' is not a constant, variable or function identifier
[DEBUG]:   	    Compiling /tmp/pip-install-oyi75skp/wobblui/src/wobblui/widget_base.pyx because it changed.
[DEBUG]:   	    [1/1] Cythonizing /tmp/pip-install-oyi75skp/wobblui/src/wobblui/widget_base.pyx
[DEBUG]:   	    Traceback (most recent call last):
[DEBUG]:   	      File "/home/userhome/.local/share/python-for-android/build/venv/lib/python3.6/site-packages/pip/_vendor/pep517/_in_process.py", line 207, in <module>
[DEBUG]:   	        main()
[DEBUG]:   	      File "/home/userhome/.local/share/python-for-android/build/venv/lib/python3.6/site-packages/pip/_vendor/pep517/_in_process.py", line 197, in main
[DEBUG]:   	        json_out['return_val'] = hook(**hook_input['kwargs'])
[DEBUG]:   	      File "/home/userhome/.local/share/python-for-android/build/venv/lib/python3.6/site-packages/pip/_vendor/pep517/_in_process.py", line 69, in prepare_metadata_for_build_wheel
[DEBUG]:   	        return hook(metadata_directory, config_settings)
[DEBUG]:   	      File "/home/userhome/.local/share/python-for-android/build/other_builds/hostpython3/desktop/hostpython3/native-build/Lib/site-packages/setuptools/build_meta.py", line 154, in prepare_metadata_for_build_wheel
[DEBUG]:   	        self.run_setup()
[DEBUG]:   	      File "/home/userhome/.local/share/python-for-android/build/other_builds/hostpython3/desktop/hostpython3/native-build/Lib/site-packages/setuptools/build_meta.py", line 140, in run_setup
[DEBUG]:   	        exec(compile(code, __file__, 'exec'), locals())
[DEBUG]:   	      File "setup.py", line 215, in <module>
[DEBUG]:   	        ext_modules = extensions(),
[DEBUG]:   	      File "setup.py", line 87, in extensions
[DEBUG]:   	        'linetrace': DEBUG_BUILD,
[DEBUG]:   	      File "/home/userhome/.local/share/python-for-android/build/venv/lib/python3.6/site-packages/Cython/Build/Dependencies.py", line 1096, in cythonize
[DEBUG]:   	        cythonize_one(*args)
[DEBUG]:   	      File "/home/userhome/.local/share/python-for-android/build/venv/lib/python3.6/site-packages/Cython/Build/Dependencies.py", line 1219, in cythonize_one
[DEBUG]:   	        raise CompileError(None, pyx_file)
[DEBUG]:   	    Cython.Compiler.Errors.CompileError: /tmp/pip-install-oyi75skp/wobblui/src/wobblui/widget_base.pyx
[DEBUG]:   	    ----------------------------------------
[DEBUG]:   	ERROR: Command "/home/userhome/.local/share/python-for-android/build/venv/bin/python3 /home/userhome/.local/share/python-for-android/build/venv/lib/python3.6/site-packages/pip/_vendor/pep517/_in_process.py prepare_metadata_for_build_wheel /tmp/tmpz5xnpef1" failed with error code 1 in /tmp/pip-install-oyi75skp/wobblui
[DEBUG]:

^ as you can see it runs wobblui's Cythonization, which happens because wobblui uses cythonize() to put together its extensions so this automatically runs when the setup.py is invoked (see here: https://github.com/wobblui/wobblui/blob/84bc49f34a329b7fccdd2593fba9d91d30379f20/setup.py#L69 ) even if just to get the metadata and not actually build the wheel. This wouldn't be an issue if nettools was installed first as specified here: https://github.com/wobblui/wobblui/blob/84bc49f34a329b7fccdd2593fba9d91d30379f20/pyproject.toml#L2 - which it is in build isolation, but not with --no-build-isolation, apparently

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions