Python: fix clingo bootstrapping on Apple M1#30834
Conversation
|
Does this PR disable clingo bootstrapping? I tested it with a fresh clone of Spack, and it seems to work (with Conda), but I don't see any clingo being bootstrapped: $ conda create create -n spack python=3.10
$ conda activate spack
$ ./bin/spack spec zlib
Input spec
--------------------------------
zlib
Concretized
--------------------------------
[email protected]%[email protected]+optimize+pic+shared patches=0d38234 arch=darwin-monterey-m1
$ ./bin/spack install zlib
==> Installing zlib-1.2.12-kv442a3m27eyisk3msyutprlor6xfqrc
==> No binary for zlib-1.2.12-kv442a3m27eyisk3msyutprlor6xfqrc found: installing from source
==> Fetching https://mirror.spack.io/_source-cache/archive/91/91844808532e5ce316b3c010929493c0244f3d37593afd6de04f71821d5136d9.tar.gz
==> Applied patch /private/tmp/spack/var/spack/repos/builtin/packages/zlib/configure-cc.patch
==> zlib: Executing phase: 'install'
==> zlib: Successfully installed zlib-1.2.12-kv442a3m27eyisk3msyutprlor6xfqrc
Fetch: 1.73s. Build: 1.28s. Total: 3.01s.
[+] /private/tmp/spack/opt/spack/darwin-monterey-m1/apple-clang-13.0.0/zlib-1.2.12-kv442a3m27eyisk3msyutprlor6xfqrcWith master, this is how you get Spack bootstrapped on M1 (just command line tools needed, I don't even have Xcode): #28190 (comment) |
|
This PR does not disable bootstrapping. I would first check to see if you already have things bootstrapped in |
|
@spackbot run pipeline |
|
I've started that pipeline for you! |
|
Nice, this might also fix #29255 |
|
Yes, this PR should def fix that issue, I wonder if there are any others. |
|
So, this won't fix #29255 because sysconfig for Would it be possible to fallback to the default config vars in spack/var/spack/repos/builtin/packages/python/package.py Lines 945 to 959 in 7d3e5c9 |
|
Hmm, we could search |
|
Ok, maybe not necessary. Intel accepted my bug report and says they're going to fix it in the next release. |
|
Awesome! I fixed it anyway, try the latest commit. |
|
@spackbot run pipeline |
|
I've started that pipeline for you! |
|
The failing |
This PR fixes several issues I noticed while trying to get Spack working on Apple M1.
- [x] `build_environment.py` attempts to add `spec['foo'].libs` and `spec['foo'].headers` to our compiler wrappers for all dependencies using a try-except that ignores `NoLibrariesError` and `NoHeadersError` respectively. However, The `libs` and `headers` attributes of the Python package were erroneously using `RuntimeError` instead.
- [x] `spack external find python` (used during bootstrapping) currently has no way to determine whether or not an installation is `+shared`, so previously we would only search for static Python libs. However, most distributions including XCode/Conda/Intel ship shared Python libs. I updated `libs` to search for both shared and static (order based on variant) as a fallback.
- [x] The `headers` attribute was recursively searching in `prefix.include` for `pyconfig.h`, but this could lead to non-deterministic behavior if multiple versions of Python are installed and `pyconfig.h` files exist in multiple `<prefix>/include/pythonX.Y` locations. It's safer to search in `sysconfig.get_path('include')` instead.
- [x] The Python installation that comes with XCode is broken, and `sysconfig.get_paths` is hard-coded to return specific directories. This meant that our logic for `platlib`/`purelib`/`include` where we replace `platbase`/`base`/`installed_base` with `prefix` wasn't working and the `mkdirp` in `setup_dependent_package` was trying to create a directory in root, giving permissions issues. Even if you commented out those `mkdirp` calls, Spack would add the wrong directories to `PYTHONPATH`. Added a fallback hard-coded to `lib/pythonX.Y/site-packages` if sysconfig is broken (this is what distutils always did).
|
Thank you @adamjstewart. I can confirm that I get the same error you mentioned. So still not able to bootstrap from source. |
|
Try #30894 |
This PR fixes several issues I noticed while trying to get Spack working on Apple M1.
- [x] `build_environment.py` attempts to add `spec['foo'].libs` and `spec['foo'].headers` to our compiler wrappers for all dependencies using a try-except that ignores `NoLibrariesError` and `NoHeadersError` respectively. However, The `libs` and `headers` attributes of the Python package were erroneously using `RuntimeError` instead.
- [x] `spack external find python` (used during bootstrapping) currently has no way to determine whether or not an installation is `+shared`, so previously we would only search for static Python libs. However, most distributions including XCode/Conda/Intel ship shared Python libs. I updated `libs` to search for both shared and static (order based on variant) as a fallback.
- [x] The `headers` attribute was recursively searching in `prefix.include` for `pyconfig.h`, but this could lead to non-deterministic behavior if multiple versions of Python are installed and `pyconfig.h` files exist in multiple `<prefix>/include/pythonX.Y` locations. It's safer to search in `sysconfig.get_path('include')` instead.
- [x] The Python installation that comes with XCode is broken, and `sysconfig.get_paths` is hard-coded to return specific directories. This meant that our logic for `platlib`/`purelib`/`include` where we replace `platbase`/`base`/`installed_base` with `prefix` wasn't working and the `mkdirp` in `setup_dependent_package` was trying to create a directory in root, giving permissions issues. Even if you commented out those `mkdirp` calls, Spack would add the wrong directories to `PYTHONPATH`. Added a fallback hard-coded to `lib/pythonX.Y/site-packages` if sysconfig is broken (this is what distutils always did).
This PR fixes several issues I noticed while trying to get Spack working on Apple M1.
- [x] `build_environment.py` attempts to add `spec['foo'].libs` and `spec['foo'].headers` to our compiler wrappers for all dependencies using a try-except that ignores `NoLibrariesError` and `NoHeadersError` respectively. However, The `libs` and `headers` attributes of the Python package were erroneously using `RuntimeError` instead.
- [x] `spack external find python` (used during bootstrapping) currently has no way to determine whether or not an installation is `+shared`, so previously we would only search for static Python libs. However, most distributions including XCode/Conda/Intel ship shared Python libs. I updated `libs` to search for both shared and static (order based on variant) as a fallback.
- [x] The `headers` attribute was recursively searching in `prefix.include` for `pyconfig.h`, but this could lead to non-deterministic behavior if multiple versions of Python are installed and `pyconfig.h` files exist in multiple `<prefix>/include/pythonX.Y` locations. It's safer to search in `sysconfig.get_path('include')` instead.
- [x] The Python installation that comes with XCode is broken, and `sysconfig.get_paths` is hard-coded to return specific directories. This meant that our logic for `platlib`/`purelib`/`include` where we replace `platbase`/`base`/`installed_base` with `prefix` wasn't working and the `mkdirp` in `setup_dependent_package` was trying to create a directory in root, giving permissions issues. Even if you commented out those `mkdirp` calls, Spack would add the wrong directories to `PYTHONPATH`. Added a fallback hard-coded to `lib/pythonX.Y/site-packages` if sysconfig is broken (this is what distutils always did).
This PR fixes several issues I noticed while trying to get Spack working on Apple M1.
- [x] `build_environment.py` attempts to add `spec['foo'].libs` and `spec['foo'].headers` to our compiler wrappers for all dependencies using a try-except that ignores `NoLibrariesError` and `NoHeadersError` respectively. However, The `libs` and `headers` attributes of the Python package were erroneously using `RuntimeError` instead.
- [x] `spack external find python` (used during bootstrapping) currently has no way to determine whether or not an installation is `+shared`, so previously we would only search for static Python libs. However, most distributions including XCode/Conda/Intel ship shared Python libs. I updated `libs` to search for both shared and static (order based on variant) as a fallback.
- [x] The `headers` attribute was recursively searching in `prefix.include` for `pyconfig.h`, but this could lead to non-deterministic behavior if multiple versions of Python are installed and `pyconfig.h` files exist in multiple `<prefix>/include/pythonX.Y` locations. It's safer to search in `sysconfig.get_path('include')` instead.
- [x] The Python installation that comes with XCode is broken, and `sysconfig.get_paths` is hard-coded to return specific directories. This meant that our logic for `platlib`/`purelib`/`include` where we replace `platbase`/`base`/`installed_base` with `prefix` wasn't working and the `mkdirp` in `setup_dependent_package` was trying to create a directory in root, giving permissions issues. Even if you commented out those `mkdirp` calls, Spack would add the wrong directories to `PYTHONPATH`. Added a fallback hard-coded to `lib/pythonX.Y/site-packages` if sysconfig is broken (this is what distutils always did).
This PR fixes several issues I noticed while trying to get Spack working on Apple M1.
- [x] `build_environment.py` attempts to add `spec['foo'].libs` and `spec['foo'].headers` to our compiler wrappers for all dependencies using a try-except that ignores `NoLibrariesError` and `NoHeadersError` respectively. However, The `libs` and `headers` attributes of the Python package were erroneously using `RuntimeError` instead.
- [x] `spack external find python` (used during bootstrapping) currently has no way to determine whether or not an installation is `+shared`, so previously we would only search for static Python libs. However, most distributions including XCode/Conda/Intel ship shared Python libs. I updated `libs` to search for both shared and static (order based on variant) as a fallback.
- [x] The `headers` attribute was recursively searching in `prefix.include` for `pyconfig.h`, but this could lead to non-deterministic behavior if multiple versions of Python are installed and `pyconfig.h` files exist in multiple `<prefix>/include/pythonX.Y` locations. It's safer to search in `sysconfig.get_path('include')` instead.
- [x] The Python installation that comes with XCode is broken, and `sysconfig.get_paths` is hard-coded to return specific directories. This meant that our logic for `platlib`/`purelib`/`include` where we replace `platbase`/`base`/`installed_base` with `prefix` wasn't working and the `mkdirp` in `setup_dependent_package` was trying to create a directory in root, giving permissions issues. Even if you commented out those `mkdirp` calls, Spack would add the wrong directories to `PYTHONPATH`. Added a fallback hard-coded to `lib/pythonX.Y/site-packages` if sysconfig is broken (this is what distutils always did).
This PR fixes several issues I noticed while trying to get Spack working on Apple M1.
build_environment.pyattempts to addspec['foo'].libsandspec['foo'].headersto our compiler wrappers for all dependencies using a try-except that ignoresNoLibrariesErrorandNoHeadersErrorrespectively. However, Thelibsandheadersattributes of the Python package were erroneously usingRuntimeErrorinstead.spack external find python(used during bootstrapping) currently has no way to determine whether or not an installation is+shared, so previously we would only search for static Python libs. However, most distributions including XCode/Conda/Intel ship shared Python libs. I updatedlibsto search for both shared and static (order based on variant) as a fallback.headersattribute was recursively searching inprefix.includeforpyconfig.h, but this could lead to non-deterministic behavior if multiple versions of Python are installed andpyconfig.hfiles exist in multiple<prefix>/include/pythonX.Ylocations. It's safer to search insysconfig.get_path('include')instead.sysconfig.get_pathsis hard-coded to return specific directories. This meant that our logic forplatlib/purelib/includewhere we replaceplatbase/base/installed_basewithprefixwasn't working and themkdirpinsetup_dependent_packagewas trying to create a directory in root, giving permissions issues. Even if you commented out thosemkdirpcalls, Spack would add the wrong directories toPYTHONPATH. Added a fallback hard-coded tolib/pythonX.Y/site-packagesif sysconfig is broken (this is what distutils always did).The result of all these changes? I still can't bootstrap Spack on M1! It seems like the version of Python distributed with XCode doesn't include the development libraries? Maybe @alalazo @tgamblin know more about the following CMake error:
Anyway, we really need bootstrapping binaries for clingo on M1. I hope that this PR is a step in the right direction for native building, and may work for most users, especially if you have Python provided by Homebrew/Conda/source install.
Fixes #28183 @rchoudhary @mathstuf @kgerheiser @tmenari @healther
Fixes #28190 @certik @sethrj
Fixes #29255 @kgerheiser
Fixes #30513 @bryank-cs
Fixes #30587 @adrienbernede