Repository navigation
Add free-threading (no-GIL) support for Python 3.13t+ #175
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
Changes from all commits
151b415
48815c5
8601ecf
c2db4a4
b4dc028
ecda1a6
29880b0
ead672e
26e53ce
3e110c9
2e4b379
ddf02d5
796382e
027c3e0
845986e
dc30748
e53abfa
0061bfc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,128 @@ | ||
| name: Free-threading tests | ||
|
|
||
| on: | ||
| pull_request: | ||
| push: | ||
| branches: | ||
| - master | ||
|
|
||
| jobs: | ||
| test_freethreading: | ||
| runs-on: ubuntu-latest | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| python-version: ["3.13t", "3.14t"] | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@v6 | ||
| with: | ||
| submodules: recursive | ||
|
|
||
| - name: Install uv | ||
| uses: astral-sh/setup-uv@v6 | ||
|
|
||
| - name: Set up free-threaded Python ${{ matrix.python-version }} | ||
| run: uv python install ${{ matrix.python-version }} | ||
|
|
||
| - name: Install OpenBLAS | ||
| run: | | ||
| sudo apt-get update | ||
| sudo apt-get install -y libopenblas-dev | ||
|
|
||
| - name: Create venv and install dependencies | ||
| run: | | ||
| uv venv --python ${{ matrix.python-version }} .venv | ||
| source .venv/bin/activate | ||
| uv pip install numpy scipy pytest pytest-run-parallel | ||
|
|
||
| - name: Build and install scs | ||
| run: | | ||
| source .venv/bin/activate | ||
| uv pip install -v . | ||
|
|
||
| - name: Run tests | ||
| run: | | ||
| source .venv/bin/activate | ||
| python -m pytest test/ -v | ||
|
|
||
| - name: Run tests in parallel threads (race detection) | ||
| run: | | ||
| source .venv/bin/activate | ||
| python -m pytest test/ -v --parallel-threads=4 --iterations=3 | ||
|
|
||
| test_sanitizers: | ||
| runs-on: ubuntu-latest | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| include: | ||
| - sanitizer: tsan | ||
| cpython_configure_flag: "--with-thread-sanitizer" | ||
| cflags: "-fsanitize=thread -g" | ||
| - sanitizer: asan | ||
| cpython_configure_flag: "--with-address-sanitizer" | ||
| cflags: "-fsanitize=address -g" | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@v6 | ||
| with: | ||
| submodules: recursive | ||
|
|
||
| - name: Install build dependencies | ||
| run: | | ||
| sudo apt-get update | ||
| sudo apt-get install -y clang libopenblas-dev libssl-dev zlib1g-dev \ | ||
| libbz2-dev libreadline-dev libsqlite3-dev libncurses5-dev \ | ||
| libncursesw5-dev xz-utils libffi-dev liblzma-dev | ||
|
|
||
| - name: Cache CPython ${{ matrix.sanitizer }} build | ||
| id: cache-cpython | ||
| uses: actions/cache@v4 | ||
| with: | ||
| path: cpython-${{ matrix.sanitizer }} | ||
| key: cpython-${{ matrix.sanitizer }}-3.14-${{ runner.os }}-v1 | ||
|
|
||
| - name: Build CPython 3.14t with ${{ matrix.sanitizer }} | ||
| if: steps.cache-cpython.outputs.cache-hit != 'true' | ||
| run: | | ||
| git clone --depth 1 https://github.com/python/cpython.git -b 3.14 cpython-src | ||
| cd cpython-src | ||
| CC=clang CXX=clang++ ./configure --disable-gil ${{ matrix.cpython_configure_flag }} \ | ||
| --prefix $GITHUB_WORKSPACE/cpython-${{ matrix.sanitizer }} | ||
| make -j$(nproc) | ||
| make install | ||
|
|
||
| - name: Create venv and install dependencies | ||
| run: | | ||
| $GITHUB_WORKSPACE/cpython-${{ matrix.sanitizer }}/bin/python3.14t -m venv .san-venv | ||
| source .san-venv/bin/activate | ||
| pip install numpy scipy pytest meson-python meson ninja | ||
|
|
||
| - name: Set sanitizer runtime options | ||
| run: | | ||
| if [ "${{ matrix.sanitizer }}" = "tsan" ]; then | ||
| echo "TSAN_OPTIONS=halt_on_error=1 allocator_may_return_null=1 suppressions=${{ github.workspace }}/test/tsan-suppressions.txt" >> $GITHUB_ENV | ||
| echo "OPENBLAS_NUM_THREADS=1" >> $GITHUB_ENV | ||
| elif [ "${{ matrix.sanitizer }}" = "asan" ]; then | ||
| echo "ASAN_OPTIONS=halt_on_error=1 allocator_may_return_null=1" >> $GITHUB_ENV | ||
| echo "LSAN_OPTIONS=suppressions=${{ github.workspace }}/test/lsan-suppressions.txt" >> $GITHUB_ENV | ||
| fi | ||
|
|
||
| - name: Build and install scs | ||
| run: | | ||
| source .san-venv/bin/activate | ||
| pip install -v . --no-build-isolation | ||
| env: | ||
| CC: clang | ||
| CFLAGS: ${{ matrix.cflags }} | ||
|
|
||
| - name: Run tests under ${{ matrix.sanitizer }} | ||
| run: | | ||
| source .san-venv/bin/activate | ||
| python -m pytest test/ -v -s | ||
|
|
||
| - name: Run threading stress tests under ${{ matrix.sanitizer }} | ||
| run: | | ||
| source .san-venv/bin/activate | ||
| python -m pytest test/test_free_threading.py test/test_thread_safety.py -v -s |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -132,6 +132,7 @@ if get_option('native_arch') | |
| endif | ||
|
|
||
| _deps = [blas_deps] | ||
| _deps += dependency('threads') | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why the pthreads dependency?
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's for the upstream thread-safe ctrl-c fix (cvxgrp/scs#375). |
||
| if get_option('use_openmp') | ||
| _deps += dependency('openmp') | ||
| endif | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.