Skip to content

Commit

Permalink
Fix a bug where Debian/Ubuntu's Python malfunctions (#1894)
Browse files Browse the repository at this point in the history
Upstream bug: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1006615

Currently affects Ubuntu 22.04 users.

Co-authored-by: Simon Frasch <simon.frasch@cscs.ch>
  • Loading branch information
brenthuisman and AdhocMan authored May 18, 2022
1 parent bb723be commit 56f9cab
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 2 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/ciwheel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ jobs:
with:
fetch-depth: 0
submodules: recursive
- name: Update pip
run: python -m pip install --upgrade pip

- name: Build wheels Linux
if: ${{ startsWith(matrix.os, 'ubuntu') }}
Expand Down Expand Up @@ -66,6 +68,8 @@ jobs:
steps:
- name: Set up Python
uses: actions/setup-python@v2
- name: Update pip
run: python -m pip install --upgrade pip
- name: Get packages
run: python -m pip install numpy setuptools scikit-build ninja cmake
- uses: actions/checkout@v2
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/sanitize.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ jobs:
uses: actions/checkout@v2
with:
submodules: recursive
- name: Update pip
run: python -m pip install --upgrade pip
- name: Build arbor
run: |
mkdir build
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/test-everything.yml
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,8 @@ jobs:
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.config.py }}
- name: Update pip
run: python -m pip install --upgrade pip
- name: OpenMPI cache
uses: actions/cache@v2
id: cache-ompi
Expand Down Expand Up @@ -200,6 +202,8 @@ jobs:
name: "Pip build test + Python examples test"
runs-on: ubuntu-latest
steps:
- name: Update pip
run: python -m pip install --upgrade pip
- name: Install Python packages
run: pip install numpy setuptools scikit-build ninja cmake
- name: Clone w/ submodules
Expand Down
3 changes: 1 addition & 2 deletions python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,7 @@ file(COPY "${PROJECT_SOURCE_DIR}/VERSION" DESTINATION "${python_mod_path}")
file(WRITE "${CMAKE_BINARY_DIR}/install-prefix" "${CMAKE_INSTALL_PREFIX}")

execute_process(
COMMAND ${PYTHON_EXECUTABLE} -c
"import sys,sysconfig;pfx=sys.stdin.read();print(sysconfig.get_path('platlib',vars={} if pfx=='' else {'base':pfx,'platbase':pfx}))"
COMMAND ${PYTHON_EXECUTABLE} "${PROJECT_SOURCE_DIR}/scripts/where.py"
INPUT_FILE "${CMAKE_BINARY_DIR}/install-prefix"
OUTPUT_VARIABLE ARB_PYTHON_LIB_PATH_DEFAULT
OUTPUT_STRIP_TRAILING_WHITESPACE)
Expand Down
12 changes: 12 additions & 0 deletions scripts/where.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import sys,sysconfig

pfx=sys.stdin.read()
try:
#override scheme on debian/ubuntu py3.10, where 'posix_local' is set and malfunctioning.
if sysconfig.get_default_scheme()=='posix_local':
print(sysconfig.get_path('platlib',vars={} if pfx=='' else {'base':pfx,'platbase':pfx},scheme='posix_prefix'))
sys.exit()
except AttributeError:
#we're on Python <= 3.9, no scheme setting required and get_default_scheme does not exist.
pass
print(sysconfig.get_path('platlib',vars={} if pfx=='' else {'base':pfx,'platbase':pfx}))

0 comments on commit 56f9cab

Please sign in to comment.