question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

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

Issue Analytics

  • State:open
  • Created 4 years ago
  • Comments:48 (23 by maintainers)

github_iconTop GitHub Comments

1reaction
dstufftcommented, Jul 16, 2019

I’m pretty -1 on pip installing build-system.requires to anything but a temporary environment.

As far as what to do with them in a --no-build-isolation context beyond that, I really don’t know. I don’t have a use case that needs it so I’m not sure what makes the most sense generally. I’m just wary of things that add extra options for specific edge cases because of the earlier mentioned reasons. That doesn’t mean we can’t add more options if that’s truly the best way to solve it, but it’d be great if we can figure out something we can just always do when --no-build-isolation is specified.

0reactions
pfmoorecommented, Feb 22, 2022

As I noted above, this sounds like another specialised case where you might need to build your own solution.

In the case of SageMath, I wonder whether the following would work.

  1. Have SageMath installed in its own directory, which is not on sys.path.
  2. Create an “expose_sage” package that simply adds a .pth file pointing to the directory where SageMath is installed.
  3. In the base environment, install expose_sage.
  4. Packages that need sage for their build can have a build dependency on expose_sage, which effectively installs sage into the build environment, but via an extremely small .pth file rather than a 5G full install.

There’s a bunch of details to work out, and it may not even be suitable for your requirements, but this is the sort of “design your own solution/workflow” approach that I had in mind when I said “a custom solution is the right option here” above. Hopefully it suggests some ideas you can try, if nothing else.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Howto: Building R 4.2 and packages on Windows
As a harder and longer test, let's try installing RcppCWB from github. First, install devtools (accept to build packages from source when offered,...
Read more >
Packaging and python-for-android
But we don't know how to get build isolation to work in our environment since we install some dependencies with custom patches we...
Read more >
ii. Toolchain Technical Notes - Linux From Scratch!
Cross -compilation is normally used for building a compiler and its toolchain for a machine different from the one that is used for...
Read more >
Installing stringi - Marek Gagolewski
Also, some build tweaks are possible. ICU4C . The stringi package depends on the ICU4C >= 55 library. If we install the...
Read more >
Cross-Compiling For Windows on Linux - Software
There are a few "prerequisite" components that don't actually need to be built and installed, because the DaVinci's Shadow build process ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found