cibuildwheel icon indicating copy to clipboard operation
cibuildwheel copied to clipboard

Autodiscovering Python versions from `pyenv` or `uv`

Open jamesbraza opened this issue 1 year ago • 7 comments

Description

I have Python 3.11 installed for both pyenv (in pyenv versions) and uv (uv python list).

However, within a Python 3.12 virtual environment, with cibuildwheel==2.21.2, when I run cibuildwheel, I get:

Building cp311-macosx_arm64 wheel
CPython 3.11 macOS arm64 - Apple Silicon

Installing Python cp311...

+ pkgutil --pkgs

                                                              ✕ 0.01s
Error: Error: CPython 3.11 is not installed.
cibuildwheel will not perform system-wide installs when running outside of CI.
To build locally, install CPython 3.11 on this machine, or, disable this version of Python using CIBW_SKIP=cp311-macosx_*

Download link: https://www.python.org/ftp/python/3.11.9/python-3.11.9-macos11.pkg

Can we have cibuildwheel discover pyenv or uv managed Python environments?

Build log

No response

CI config

No response

jamesbraza avatar Oct 08 '24 05:10 jamesbraza

No, these do not have Pythons that are compiled for the full range of macOS versions. They are not universal. To build broadly compatible wheels, cibuildwheel has to use the official installers on macOS.

We should probably improve the error message, though.

(Though this may not be as true in uv's case. Python-build-standalone does compile for old macOS versions, though they are not universal.)

henryiii avatar Oct 08 '24 05:10 henryiii

What about brew install [email protected], or does brew not count as not general enough too? I just tried brew install [email protected] and still get the same error message, so I guess it also doesn't work

And feel free to leave this open for a better error message, or close it as not planned

jamesbraza avatar Oct 08 '24 06:10 jamesbraza

You should never use brew python and libraries to build wheel.

Brew builds binaries optimized for a given machine and operating system and is not intended to be portable.

Also, brew uses gcc tolchain in place of clang. That means that you need to distribute a copy of stdlib in wheel.

Czaki avatar Oct 08 '24 06:10 Czaki

Yes, agree, brew is the worst offender, as they explicitly do not support redistribution for any of their libraries. Nothing is built compatibly or universal at all.

henryiii avatar Oct 08 '24 06:10 henryiii

Hi,

Would it be possible to leverage portable-python in order to build wheels?

In this thread, in a previous comment, it was mentioned the project Python-build-standalone that could be leveraged, but it is said that it is not universal.

Why is universal is required if we only want to build for a specific architecture (e.g. AMD64)?

Currently, cibuildwheel requires official CPython packages, but I am trying to understand if we could make cibuildwheel work with other Python "environements (e.g. Python-build-standalone or portable-python).

fafanoulele avatar Oct 16 '24 12:10 fafanoulele

See https://github.com/pypa/cibuildwheel/issues/1130 for previous discussion on this.

joerick avatar Oct 18 '24 08:10 joerick

Also, for the sorts of issues that pop up when you don't use official CPython, see https://github.com/numpy/numpy/pull/27581#issuecomment-2420205914. Even if those are fixed, I think you'd run into even more if you trying to redistribute wheels (that was just building them).

henryiii avatar Oct 18 '24 12:10 henryiii