-
Notifications
You must be signed in to change notification settings - Fork 73
Enable CPython free-threaded wheel builds #301
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
base: master
Are you sure you want to change the base?
Changes from all commits
a391387
0474866
9990420
073bb4f
42ab28c
4f4b633
5b1c271
0cf7fb0
78231aa
b4c9e83
739aaec
461a4c4
5164e75
6f81f99
50393d2
69a66d0
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 |
---|---|---|
|
@@ -48,7 +48,7 @@ jobs: | |
- macos-13 # x86 | ||
- macos-latest # arm | ||
- windows-latest | ||
cibw_build: [cp39-*, cp310-*, cp311-*, cp312-*, cp313-*] | ||
cibw_build: [cp39-*, cp310-*, cp311-*, cp312-*, cp313-*, cp313t-*] | ||
steps: | ||
- name: Check out repository | ||
uses: actions/checkout@v4 | ||
|
@@ -63,17 +63,30 @@ jobs: | |
uses: docker/setup-qemu-action@v3 | ||
with: | ||
platforms: all | ||
|
||
- name: Setup free-threading variables | ||
if: ${{ endsWith(matrix.cibw_build, 't-*') }} | ||
shell: bash -l {0} | ||
run: | | ||
echo "CIBW_BEFORE_TEST=pip install pytest pytest-run-parallel" >> "$GITHUB_ENV" | ||
echo "CIBW_ENVIRONMENT=PYLZ4_USE_SYSTEM_LZ4=False PYTEST_ADDOPTS=--parallel-threads=4" >> "$GITHUB_ENV" | ||
echo "CIBW_TEST_COMMAND=tox -x testenv.deps+=pytest-run-parallel -x testenv.pass_env+=PYTEST_ADDOPTS -c {project}" >> "$GITHUB_ENV" | ||
- name: Setup environment | ||
if: ${{ !endsWith(matrix.cibw_build, 't-*') }} | ||
shell: bash -l {0} | ||
run: | | ||
echo "CIBW_ENVIRONMENT=PYLZ4_USE_SYSTEM_LZ4=False" >> "$GITHUB_ENV" | ||
echo "CIBW_TEST_COMMAND=tox -c {project}" >> "$GITHUB_ENV" | ||
- name: Build wheels | ||
uses: pypa/cibuildwheel@v2.21 | ||
uses: pypa/cibuildwheel@v2.23.2 | ||
env: | ||
CIBW_ENVIRONMENT: PYLZ4_USE_SYSTEM_LZ4="False" | ||
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 remove this for non free threading builds? We definitely don't want to use the system LZ4 library in all cases, so I am a little confused on the thinking here? 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. The variable was absorbed by the redefinition over at line 71 |
||
# CIBW_ARCHS_LINUX: "x86_64 i686 aarch64" | ||
CIBW_ARCHS_LINUX: "x86_64 i686" | ||
CIBW_ARCHS_MACOS: "auto64" # since we have both runner arches | ||
CIBW_ARCHS_WINDOWS: "AMD64 x86 ARM64" | ||
CIBW_ENABLE: cpython-freethreading | ||
CIBW_BUILD: ${{ matrix.cibw_build }} | ||
CIBW_SKIP: "cp*-musllinux*" | ||
CIBW_TEST_COMMAND: "tox -c {project}" | ||
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 is this removed in the general case? 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. The actual command was moved to its own definition over at lines 73 and 79 |
||
CIBW_TEST_SKIP: "*-macosx_arm64 *-macosx_universal2:arm64 *-*linux_{ppc64le,s390x} *-win_arm64" | ||
CIBW_BEFORE_BUILD: "python -m pip install -U pip && python -m pip install tox" | ||
- name: Save wheels | ||
|
@@ -93,7 +106,7 @@ jobs: | |
matrix: | ||
os: | ||
- ubuntu-24.04-arm | ||
cibw_build: [cp39-*, cp310-*, cp311-*, cp312-*, cp313-*] | ||
cibw_build: [cp39-*, cp310-*, cp311-*, cp312-*, cp313-*, cp313t-*] | ||
steps: | ||
- name: Check out repository | ||
uses: actions/checkout@v4 | ||
|
@@ -103,14 +116,28 @@ jobs: | |
uses: actions/setup-python@v5 | ||
with: | ||
python-version: 3.x | ||
- name: Setup free-threading variables | ||
if: ${{ endsWith(matrix.cibw_build, 't-*') }} | ||
shell: bash -l {0} | ||
run: | | ||
# Variables are set in order to be passed down to both cibuildwheel and the | ||
# Docker image spawned by that action | ||
echo "CIBW_BEFORE_TEST=pip install pytest pytest-run-parallel" >> "$GITHUB_ENV" | ||
echo "CIBW_ENVIRONMENT=PYLZ4_USE_SYSTEM_LZ4=False PYTEST_ADDOPTS=--parallel-threads=1" >> "$GITHUB_ENV" | ||
echo "CIBW_TEST_COMMAND=tox -x testenv.deps+=pytest-run-parallel -x testenv.pass_env+=PYTEST_ADDOPTS -c {project}" >> "$GITHUB_ENV" | ||
- name: Setup environment | ||
if: ${{ !endsWith(matrix.cibw_build, 't-*') }} | ||
shell: bash -l {0} | ||
run: | | ||
echo "CIBW_ENVIRONMENT=PYLZ4_USE_SYSTEM_LZ4=False" >> "$GITHUB_ENV" | ||
echo "CIBW_TEST_COMMAND=tox -c {project}" >> "$GITHUB_ENV" | ||
- name: Build wheels | ||
uses: pypa/cibuildwheel@v2.21 | ||
uses: pypa/cibuildwheel@v2.23.2 | ||
env: | ||
CIBW_ENVIRONMENT: PYLZ4_USE_SYSTEM_LZ4="False" | ||
CIBW_ARCHS_LINUX: "aarch64 armv7l" | ||
CIBW_ARCHS_LINUX: "aarch64" | ||
CIBW_BUILD: ${{ matrix.cibw_build }} | ||
CIBW_SKIP: "cp*-musllinux*" | ||
CIBW_TEST_COMMAND: "tox -c {project}" | ||
CIBW_ENABLE: cpython-freethreading | ||
CIBW_BEFORE_BUILD: "python -m pip install -U pip && python -m pip install tox" | ||
- name: Save wheels | ||
uses: actions/upload-artifact@v4 | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,8 @@ | |
(b'a' * 1024 * 1024), | ||
] | ||
|
||
pytestmark = pytest.mark.thread_unsafe | ||
|
||
|
||
@pytest.fixture( | ||
params=test_data, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,14 @@ | ||
import threading | ||
import lz4.frame as lz4frame | ||
|
||
|
||
def test_lz4frame_open_write_read_text_iter(): | ||
def test_lz4frame_open_write_read_text_iter(tmp_path): | ||
data = u'This is a test string' | ||
with lz4frame.open('testfile', mode='wt') as fp: | ||
thread_id = threading.get_native_id() | ||
with lz4frame.open(tmp_path / f'testfile_{thread_id}', mode='wt') as fp: | ||
fp.write(data) | ||
data_out = '' | ||
with lz4frame.open('testfile', mode='rt') as fp: | ||
with lz4frame.open(tmp_path / f'testfile_{thread_id}', mode='rt') as fp: | ||
for line in fp: | ||
data_out += line | ||
assert data_out == data |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't these be better set with an
env
stanza? If they must be set this way, please add a comment explaining why.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
echo "VAR=VALUE" >> "$GITHUB_ENV"
is the standard preferred way to set variables in Github Actions workflows: https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/store-information-in-variables#passing-values-between-steps-and-jobs-in-a-workflow