Skip to content
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

Failures to compile yt against Python 3.12.6 binary (macOS-aarch64) #337

Open
neutrinoceros opened this issue Oct 6, 2024 · 7 comments
Open

Comments

@neutrinoceros
Copy link

Hi, I'm new to using the pre-built binaries from this project, that I get from uv, and I'm not sure wether this is an issue with said binaries, uv itself, or the package that I'm trying to build, but I currently lean toward the first, apologies if this issue is misplaced.

So, what I'm observing is that I cannot build yt against the Python 3.12.6 binary (specifically cpython-3.12.6-macos-aarch64-none). I haven't tried other Python versions but I know that building this package works against a locally compiled 3.12.6 binary (obtained with pyenv)

Steps to reproduce (tarball from PyPI):

uv venv -p 3.12 --python-preference=only-managed
uv pip install "yt==4.3.1" --no-binary yt

excerpt

Compiling with an SDK that doesn't seem to exist: /Applications/Xcode_15.2.app/Contents/Developer/Platforms/MacOSX.platform/

(indeed, /Applications/Xcode_15.2.app doesn't exist on my system, but I do have Xcode 16.0 installed under /Applications/Xcode.app)

output head and tail
Resolved 39 packages in 7ms
error: Failed to prepare distributions
  Caused by: Failed to fetch wheel: yt==4.3.1
  Caused by: Build backend failed to build wheel through `build_wheel()` (exit status: 1)
--- stdout:
...
Compiling with an SDK that doesn't seem to exist: /Applications/Xcode_15.2.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk
Please check your Xcode installation
clang++: warning: no such sysroot directory: '/Applications/Xcode_15.2.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk' [-Wmissing-sysroot]
ld: warning: search path 'Modules/_hacl' not found
ld: warning: search path '/install/lib' not found
ld: library 'm' not found
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
yt/utilities/lib/particle_kdtree_tools.cpp:27964:28: warning: comparison of integers of different signs: 'uint64_t' (aka 'unsigned long long') and 'int' [-Wsign-compare]
 27964 |     __pyx_t_4 = (__pyx_v_i == __pyx_v_skipidx);
       |                  ~~~~~~~~~ ^  ~~~~~~~~~~~~~~~
yt/utilities/lib/particle_kdtree_tools.cpp:28012:30: warning: comparison of integers of different signs: 'uint64_t' (aka 'unsigned long long') and 'int' [-Wsign-compare]
 28012 |       __pyx_t_4 = (__pyx_v_k < __pyx_v_axes->stop);
       |                    ~~~~~~~~~ ^ ~~~~~~~~~~~~~~~~~~
yt/utilities/lib/particle_kdtree_tools.cpp:28571:28: warning: comparison of integers of different signs: 'uint64_t' (aka 'unsigned long long') and 'int' [-Wsign-compare]
 28571 |     __pyx_t_4 = (__pyx_v_i == __pyx_v_skipidx);
       |                  ~~~~~~~~~ ^  ~~~~~~~~~~~~~~~
yt/utilities/lib/particle_kdtree_tools.cpp:28619:30: warning: comparison of integers of different signs: 'uint64_t' (aka 'unsigned long long') and 'int' [-Wsign-compare]
 28619 |       __pyx_t_4 = (__pyx_v_k < __pyx_v_axes->stop);
       |                    ~~~~~~~~~ ^ ~~~~~~~~~~~~~~~~~~
yt/utilities/lib/particle_kdtree_tools.cpp:32764:13: warning: code will never be executed [-Wunreachable-code]
 32764 |             goto bad;
       |             ^~~~~~~~
1 warning generated.
Compiling with an SDK that doesn't seem to exist: /Applications/Xcode_15.2.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk
Please check your Xcode installation
clang++: warning: no such sysroot directory: '/Applications/Xcode_15.2.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk' [-Wmissing-sysroot]
ld: warning: search path 'Modules/_hacl' not found
ld: warning: search path '/install/lib' not found
ld: library 'c++' not found
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
4 warnings generated.
Compiling with an SDK that doesn't seem to exist: /Applications/Xcode_15.2.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk
Please check your Xcode installation
clang++: warning: no such sysroot directory: '/Applications/Xcode_15.2.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk' [-Wmissing-sysroot]
ld: warning: search path 'Modules/_hacl' not found
ld: warning: search path '/install/lib' not found
ld: library 'm' not found
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
1 warning generated.
Compiling with an SDK that doesn't seem to exist: /Applications/Xcode_15.2.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk
Please check your Xcode installation
clang++: warning: no such sysroot directory: '/Applications/Xcode_15.2.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk' [-Wmissing-sysroot]
ld: warning: search path 'Modules/_hacl' not found
ld: warning: search path '/install/lib' not found
ld: library 'm' not found
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
yt/utilities/lib/pixelization_routines.cpp:39197:7: warning: code will never be executed [-Wunreachable-code]
 39197 |       PyErr_Format(PyExc_ValueError, "Assignment to slice of wrong length, expected %" CYTHON_FORMAT_SSIZE_T "d, got %" CYTHON_FORMAT_SSIZE_T "d", (Py_ssize_t)(MAX_NUM_FACES), (Py_ssize_t)(MAX_NUM_FACES));
       |       ^~~~~~~~~~~~
yt/utilities/lib/pixelization_routines.cpp:39229:7: warning: code will never be executed [-Wunreachable-code]
 39229 |       PyErr_Format(PyExc_ValueError, "Assignment to slice of wrong length, expected %" CYTHON_FORMAT_SSIZE_T "d, got %" CYTHON_FORMAT_SSIZE_T "d", (Py_ssize_t)(MAX_NUM_FACES), (Py_ssize_t)(MAX_NUM_FACES));
       |       ^~~~~~~~~~~~
yt/utilities/lib/pixelization_routines.cpp:39261:7: warning: code will never be executed [-Wunreachable-code]
 39261 |       PyErr_Format(PyExc_ValueError, "Assignment to slice of wrong length, expected %" CYTHON_FORMAT_SSIZE_T "d, got %" CYTHON_FORMAT_SSIZE_T "d", (Py_ssize_t)(MAX_NUM_FACES), (Py_ssize_t)(MAX_NUM_FACES));
       |       ^~~~~~~~~~~~
yt/utilities/lib/pixelization_routines.cpp:63710:13: warning: code will never be executed [-Wunreachable-code]
 63710 |             goto bad;
       |             ^~~~~~~~
yt/utilities/lib/pixelization_routines.cpp:66482:21: warning: fallthrough annotation in unreachable code [-Wunreachable-code-fallthrough]
 66482 |                     CYTHON_FALLTHROUGH;
       |                     ^
yt/utilities/lib/pixelization_routines.cpp:570:36: note: expanded from macro 'CYTHON_FALLTHROUGH'
  570 |         #define CYTHON_FALLTHROUGH [[clang::fallthrough]]
      |                                    ^
yt/utilities/lib/pixelization_routines.cpp:66493:21: warning: fallthrough annotation in unreachable code [-Wunreachable-code-fallthrough]
 66493 |                     CYTHON_FALLTHROUGH;
       |                     ^
yt/utilities/lib/pixelization_routines.cpp:570:36: note: expanded from macro 'CYTHON_FALLTHROUGH'
  570 |         #define CYTHON_FALLTHROUGH [[clang::fallthrough]]
      |                                    ^
yt/utilities/lib/pixelization_routines.cpp:66604:21: warning: fallthrough annotation in unreachable code [-Wunreachable-code-fallthrough]
 66604 |                     CYTHON_FALLTHROUGH;
       |                     ^
yt/utilities/lib/pixelization_routines.cpp:570:36: note: expanded from macro 'CYTHON_FALLTHROUGH'
  570 |         #define CYTHON_FALLTHROUGH [[clang::fallthrough]]
      |                                    ^
yt/utilities/lib/pixelization_routines.cpp:66610:21: warning: fallthrough annotation in unreachable code [-Wunreachable-code-fallthrough]
 66610 |                     CYTHON_FALLTHROUGH;
       |                     ^
yt/utilities/lib/pixelization_routines.cpp:570:36: note: expanded from macro 'CYTHON_FALLTHROUGH'
  570 |         #define CYTHON_FALLTHROUGH [[clang::fallthrough]]
      |                                    ^
yt/utilities/lib/pixelization_routines.cpp:39156:12: warning: unused function '__pyx_f_2yt_9utilities_3lib_21pixelization_routines_check_face_dot' [-Wunused-function]
 39156 | static int __pyx_f_2yt_9utilities_3lib_21pixelization_routines_check_face_dot(int __pyx_v_nvertices, __pyx_t_5numpy_float64_t *__pyx_v_point, __pyx_t_5numpy_float64_t **__pyx_v_vertices, __pyx_t_5numpy_int8_t *__pyx_v_signs, int __pyx_v_match) {
       |            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 warning generated.
Compiling with an SDK that doesn't seem to exist: /Applications/Xcode_15.2.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk
Please check your Xcode installation
clang++: warning: no such sysroot directory: '/Applications/Xcode_15.2.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk' [-Wmissing-sysroot]
ld: warning: search path 'Modules/_hacl' not found
ld: warning: search path '/install/lib' not found
ld: library 'm' not found
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
Compiling with an SDK that doesn't seem to exist: /Applications/Xcode_15.2.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk
Please check your Xcode installation
clang++: warning: no such sysroot directory: '/Applications/Xcode_15.2.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk' [-Wmissing-sysroot]
ld: warning: search path 'Modules/_hacl' not found
ld: warning: search path '/install/lib' not found
ld: library 'm' not found
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
5 warnings generated.
Compiling with an SDK that doesn't seem to exist: /Applications/Xcode_15.2.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk
Please check your Xcode installation
clang++: warning: no such sysroot directory: '/Applications/Xcode_15.2.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk' [-Wmissing-sysroot]
ld: warning: search path 'Modules/_hacl' not found
ld: warning: search path '/install/lib' not found
ld: library 'c++' not found
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
2 warnings generated.
Compiling with an SDK that doesn't seem to exist: /Applications/Xcode_15.2.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk
Please check your Xcode installation
clang++: warning: no such sysroot directory: '/Applications/Xcode_15.2.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk' [-Wmissing-sysroot]
ld: warning: search path 'Modules/_hacl' not found
ld: warning: search path '/install/lib' not found
ld: library 'm' not found
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
1 warning generated.
Compiling with an SDK that doesn't seem to exist: /Applications/Xcode_15.2.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk
Please check your Xcode installation
clang++: warning: no such sysroot directory: '/Applications/Xcode_15.2.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk' [-Wmissing-sysroot]
ld: warning: search path 'Modules/_hacl' not found
ld: warning: search path '/install/lib' not found
ld: library 'm' not found
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
7 warnings generated.
Compiling with an SDK that doesn't seem to exist: /Applications/Xcode_15.2.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk
Please check your Xcode installation
clang++: warning: no such sysroot directory: '/Applications/Xcode_15.2.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk' [-Wmissing-sysroot]
ld: warning: search path 'Modules/_hacl' not found
ld: warning: search path '/install/lib' not found
ld: library 'm' not found
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
12 warnings generated.
warning: no library file corresponding to '/Users/clm/.cache/uv/builds-v0/.tmpgiGrVC/lib/python3.12/site-packages/ewah_bool_utils' found (skipping)
Compiling with an SDK that doesn't seem to exist: /Applications/Xcode_15.2.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk
Please check your Xcode installation
clang++: warning: no such sysroot directory: '/Applications/Xcode_15.2.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk' [-Wmissing-sysroot]
ld: warning: search path 'Modules/_hacl' not found
ld: warning: search path '/install/lib' not found
ld: library 'm' not found
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
23 warnings generated.
Compiling with an SDK that doesn't seem to exist: /Applications/Xcode_15.2.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk
Please check your Xcode installation
clang++: warning: no such sysroot directory: '/Applications/Xcode_15.2.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk' [-Wmissing-sysroot]
ld: warning: search path 'Modules/_hacl' not found
ld: warning: search path '/install/lib' not found
ld: library 'm' not found
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
9 warnings generated.
Compiling with an SDK that doesn't seem to exist: /Applications/Xcode_15.2.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk
Please check your Xcode installation
clang++: warning: no such sysroot directory: '/Applications/Xcode_15.2.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk' [-Wmissing-sysroot]
ld: warning: search path 'Modules/_hacl' not found
ld: warning: search path '/install/lib' not found
ld: library 'm' not found
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
error: command '/usr/bin/clang++' failed with exit code 1
---

Steps to reproduce (from github)

The error message looks different so I'm also including this case in case it's relevant.

git clone https://github.com/yt-project/yt.git
uv venv -p 3.12 --python-preference=only-managed
uv pip install ./yt

excerpt

error: command '/var/folders/py/lcjn3y352g1106vf1rqk521r0000gn/T/tmp8l_1g36k/tools/llvm/bin/llvm-ar' failed: No such file or directory
Output head and tail
Resolved 20 packages in 11ms
error: Failed to prepare distributions
  Caused by: Failed to fetch wheel: yt @ file:///private/tmp/yt
  Caused by: Build backend failed to build wheel through `build_wheel()` (exit status: 1)
--- stdout:
...
error: command '/var/folders/py/lcjn3y352g1106vf1rqk521r0000gn/T/tmp8l_1g36k/tools/llvm/bin/llvm-ar' failed: No such file or directory
---

This feels like the kind of problem that could be documented on the Quirks page but I couldn't find anything relevant there, or in the issue tracker. Is this solvable or is it an inherent limitation in portability from using pre-build binaries ?

@zanieb
Copy link
Collaborator

zanieb commented Oct 6, 2024

Related to astral-sh/uv#7525

This is sort of documented in the quirks here. Basically, there are references to the tools used to build the distribution and libraries assume that they should use the same toolchain that the Python distribution was built with and retrieve that information only to find the tools don't exist anymore (because this is a standalone build and all of the build tools are isolated from the final distribution).

There may be some helpful discussion in the linked issue. Generally, we're not sure how to solve this yet.

@zanieb
Copy link
Collaborator

zanieb commented Oct 6, 2024

Thanks for the well written issue, appreciate it.

@neutrinoceros
Copy link
Author

Thanks for the quick reply and pointers !

libraries assume that they should use the same toolchain that the Python distribution was built with and retrieve that information only to find the tools don't exist anymore

Can you clarify what you mean by "libraries" here ? if you suspect yt itself (which I'm a maintainer of) is culprit of this I should address the problem there :-)

@zanieb
Copy link
Collaborator

zanieb commented Oct 6, 2024

Can you clarify what you mean by "libraries" here ? if you suspect yt itself (which I'm a maintainer of) is culprit of this I should address the problem there :-)

I'm honestly still learning about this problem myself, so I can't give super clear guidance. I think it's a probably a combination of the build system and your configuration of the build system? You can see that variables in sysconfig with something like:

uv run \
  --isolated --no-project \
  --python 3.12 --python-preference only-managed \
  python -c "import pprint; import sysconfig; pprint.pprint(sysconfig.get_config_vars())"

Which will have things like:

 'LDCXXSHARED': 'clang++ -bundle -undefined dynamic_lookup -arch arm64 '
                '-mmacosx-version-min=11.0 -isysroot '
                '/Applications/Xcode_15.2.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk  '

We should probably strip these here? But I'm not sure what else what will break. Alternatively, uv can try to upgrade the variables when installed on a system. I think the solution further downstream (like in the build system or your library) is to detect the proper Xcode version on the system and use instead of relying on the one stored in the Python distribution?

@neutrinoceros
Copy link
Author

I couldn't find anything in yt's setup.py or its build configuration that indicate this kind of problem. However I did manage to find one branch in setuptools that appears to rely on LDCXXSHARED as found in sysconfig.get_config_vars:

https://github.com/pypa/setuptools/blob/66a8aee91de7ed8b0f819fb836e5543212e4b860/setuptools/_distutils/sysconfig.py#L302-L322

I feel like this should be patched in setuptools, but I don't know how and am very worried about breaking the world by touching this line 😅
Any way, for now I'm happy to call this a "known issue" on my end. Feel free to ping me in the future if you guys want to propose a solution on your side though !

@delicb
Copy link

delicb commented Nov 8, 2024

I am hitting the same problem. Not with yt, but general problem with compiling dependencies that are looking for /Application/Xcode_***.

Any suggestion for a good workaround here? Since this prevents me from using managed python installation, maybe support something like registering external toolchains, like rye does. This way I could manage (locally compiled) versions I need via mise, pyenv or whatever and link the to uv. I don't want these in my path (especially since there can be multiple versions).

As a workaround, I am using mise installed python, configured to compile it locally, and expecting that mise will read .python-version as well to tweak the PATH before running uv venv. But this feels very hacky and not something I would recommend to the rest of the team to use.

@delicb
Copy link

delicb commented Nov 10, 2024

Sorry, last comment should have gone to https://github.com/astral-sh/uv as a workaround for this problem. I will open a ticket there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants