From bb29ea911710b8b3b6275a399b694c03b983d84f Mon Sep 17 00:00:00 2001 From: serge-sans-paille Date: Tue, 26 Nov 2024 23:34:13 +0100 Subject: [PATCH] Have pythran generate freethreading compatible code Fix #2258 --- .github/workflows/freethreading.yml | 47 +++++++++++++++++++++++++++++ pythran/cxxgen.py | 3 ++ 2 files changed, 50 insertions(+) create mode 100644 .github/workflows/freethreading.yml diff --git a/.github/workflows/freethreading.yml b/.github/workflows/freethreading.yml new file mode 100644 index 000000000..d5052f57a --- /dev/null +++ b/.github/workflows/freethreading.yml @@ -0,0 +1,47 @@ +# Kept seperate from core.yml because it uses a quantsight-built python setup +name: core + +on: + push: + branches: + - master + pull_request: + branches: + - master +jobs: + build: + runs-on: ubuntu-20.04 + strategy: + matrix: + python-version: [cp313t] + cpp-version: [g++-8, clang-7] + steps: + - uses: actions/checkout@v2 + - name: Setup Python ${{ matrix.python-version }} + uses: quansight-labs/setup-python@v5.3.1 + with: + python-version: ${{ matrix.python-version }} + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install scipy scipy-openblas64 + pip install pytest-xdist + sudo apt install ${{ matrix.cpp-version }} + sudo apt install libopenblas-dev # for meson integration testing + - name: Setup + run: | + python -m pip install . + python -m pip install . 'pythran[test]' + printf '[compiler]\nblas=scipy-openblas\n' > ~/.config/.pythranrc + printf 'cflags=-std=c++11 -Wall -Werror -Wno-unknown-pragmas -Wno-unused-local-typedefs -Wno-cpp -Wno-deprecated-declarations' >> ~/.config/.pythranrc + if test "${{ matrix.cpp-version }}" = "clang-7" ; then printf -- " -Wno-absolute-value -Wno-parentheses-equality\n" ; else printf "\n" ; fi >> ~/.config/.pythranrc + - name: Testing minimal CLI + run: | + pythran --version + pythran --help + pythran-config -vvv + - name: Testing sequential + run: | + export CC=`echo ${{ matrix.cpp-version }} | sed -e 's/g++/gcc/'` + export CXX=`echo ${{ matrix.cpp-version }} | sed -e 's/clang/clang++/'` + pytest pythran/tests/test_*.py -v -x --numprocesses=auto $PYTEST_ARGS diff --git a/pythran/cxxgen.py b/pythran/cxxgen.py index 504a9636c..6ebaf0528 100644 --- a/pythran/cxxgen.py +++ b/pythran/cxxgen.py @@ -746,6 +746,9 @@ def __str__(self): theDoc); {extraobjects} + #ifdef Py_GIL_DISABLED + PyUnstable_Module_SetGIL(theModule, Py_MOD_GIL_NOT_USED); + #endif PYTHRAN_RETURN; }} '''.format(name=self.name,