Skip to content

Commit c2c3660

Browse files
Merge pull request #123 from daskol:build/py313
PiperOrigin-RevId: 718758022
2 parents d4be368 + 367a6f0 commit c2c3660

File tree

4 files changed

+120
-232
lines changed

4 files changed

+120
-232
lines changed

.github/workflows/build.yml

Lines changed: 36 additions & 145 deletions
Original file line numberDiff line numberDiff line change
@@ -12,171 +12,62 @@ on:
1212
jobs:
1313
sdist:
1414
name: sdist
15-
runs-on: ubuntu-latest
15+
runs-on: ubuntu-24.04
1616
steps:
17-
- uses: actions/checkout@v2
18-
- uses: actions/setup-python@v2
17+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
18+
- uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5.3.0
19+
with:
20+
python-version: '3.11'
1921
- name: Create sdist
2022
run: |
2123
python -m pip install --upgrade pip setuptools
2224
python setup.py sdist
2325
shell: bash
24-
- name: Directory listing
25-
run: ls -lh dist/dm-tree*.tar.gz
26+
- name: List output directory
27+
run: ls -lh dist/dm_tree*.tar.gz
2628
shell: bash
27-
- uses: actions/upload-artifact@v2
29+
- uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4.6.0
2830
if: ${{ github.event_name == 'workflow_dispatch' || (github.event_name == 'release' && github.event.action == 'created') }}
2931
with:
30-
name: dm-tree-${{ github.workflow }}-${{ github.run_number }}
31-
path: dist/dm-tree*.tar.gz
32-
33-
wheel-x86_64:
34-
strategy:
35-
matrix:
36-
os: [windows-latest, ubuntu-latest, macos-latest]
37-
python_tag: [cp38, cp39, cp310, cp311, cp312]
38-
include:
39-
- os: windows-latest
40-
os_tag: win_amd64
41-
- os: ubuntu-latest
42-
os_tag: manylinux_x86_64
43-
- os: macos-latest
44-
os_tag: macosx_x86_64
32+
name: dm-tree-sdist
33+
path: dist/dm_tree*.tar.gz
4534

46-
name: "wheel: ${{ matrix.python_tag }}-${{ matrix.os_tag }}"
35+
bdist-wheel:
36+
name: Build wheels on ${{ matrix.os }}
4737
runs-on: ${{ matrix.os }}
48-
49-
steps:
50-
- uses: actions/checkout@v2
51-
- uses: actions/setup-python@v2
52-
53-
- name: Install prerequisites
54-
run: |
55-
set -xe
56-
pwd
57-
python --version
58-
python -m pip install --upgrade pip setuptools wheel
59-
python -m pip install cibuildwheel
60-
shell: bash
61-
62-
- name: Build and test
63-
run: set -xe && python -m cibuildwheel --output-dir wheelhouse
64-
env:
65-
CIBW_BUILD: ${{ matrix.python_tag }}-${{ matrix.os_tag }}
66-
CIBW_BUILD_VERBOSITY: 3
67-
CIBW_PROJECT_REQUIRES_PYTHON: ">=3.7"
68-
CIBW_MANYLINUX_X86_64_IMAGE: quay.io/pypa/manylinux2014_x86_64
69-
CIBW_TEST_REQUIRES: pytest
70-
CIBW_BEFORE_TEST: pip install -r requirements-test.txt
71-
CIBW_TEST_COMMAND: pytest --pyargs tree
72-
shell: bash
73-
74-
- name: Directory listing
75-
run: ls -lh wheelhouse/dm_tree*.whl
76-
shell: bash
77-
78-
- uses: actions/upload-artifact@v2
79-
if: ${{ github.event_name == 'workflow_dispatch' || (github.event_name == 'release' && github.event.action == 'created') }}
80-
with:
81-
name: dm-tree-${{ github.workflow }}-${{ github.run_number }}
82-
path: wheelhouse/dm_tree*.whl
83-
84-
wheel-apple_silicon:
8538
strategy:
8639
matrix:
87-
python_tag: [cp38, cp39, cp310, cp311, cp312]
88-
macos_arch: [arm64, universal2]
89-
90-
name: "wheel: ${{ matrix.python_tag }}-macosx_${{ matrix.macos_arch }}"
91-
runs-on: macos-latest
40+
os: [ubuntu-24.04, macos-14, windows-2022] # latest
9241

9342
steps:
94-
- uses: actions/checkout@v2
95-
- uses: actions/setup-python@v2
96-
97-
- name: Install prerequisites
98-
run: |
99-
set -xe
100-
pwd
101-
python --version
102-
python -m pip install --upgrade pip setuptools wheel
103-
python -m pip install cibuildwheel
104-
shell: bash
105-
106-
- name: Build and test
107-
run: set -xe && python -m cibuildwheel --output-dir wheelhouse
108-
env:
109-
CIBW_BUILD: ${{ matrix.python_tag }}-macosx_${{ matrix.macos_arch }}
110-
CIBW_BUILD_VERBOSITY: 3
111-
CIBW_ARCHS_MACOS: ${{ matrix.macos_arch }}
112-
CIBW_TEST_REQUIRES: pytest
113-
CIBW_BEFORE_TEST: pip install -r requirements-test.txt
114-
CIBW_TEST_COMMAND: "if [ \"${CIBW_ARCHS_MACOS}\" = \"universal2\" ]; then pytest --pyargs tree; fi"
115-
shell: bash
116-
117-
- name: Directory listing
118-
run: ls -lh wheelhouse/dm_tree*.whl
119-
shell: bash
120-
121-
- uses: actions/upload-artifact@v2
122-
if: ${{ github.event_name == 'workflow_dispatch' || (github.event_name == 'release' && github.event.action == 'created') }}
43+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
12344
with:
124-
name: dm-tree-${{ github.workflow }}-${{ github.run_number }}
125-
path: wheelhouse/dm_tree*.whl
126-
127-
wheel-aarch:
128-
strategy:
129-
matrix:
130-
os: [ubuntu-latest]
131-
python_tag: [cp38, cp39, cp310, cp311, cp312]
132-
arch: [aarch64, ppc64le, s390x, i686]
133-
include:
134-
- arch: aarch64
135-
arch_tag: manylinux_aarch64
136-
- arch: ppc64le
137-
arch_tag: manylinux_ppc64le
138-
- arch: s390x
139-
arch_tag: manylinux_s390x
140-
- arch: i686
141-
arch_tag: manylinux_i686
142-
143-
if: false
144-
name: "wheel: ${{ matrix.python_tag }}-${{ matrix.arch }}"
145-
runs-on: ${{ matrix.os }}
146-
147-
steps:
148-
- uses: actions/checkout@v2
149-
- uses: actions/setup-python@v2
45+
submodules: true
46+
- uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5.3.0
47+
with:
48+
python-version: "3.11"
15049
- name: Set up QEMU
151-
uses: docker/setup-qemu-action@v2
50+
if: runner.os == 'Linux'
51+
uses: docker/setup-qemu-action@53851d14592bedcffcf25ea515637cff71ef929a # v3.3.0
15252
with:
15353
platforms: all
154-
- name: Install prerequisites
155-
run: |
156-
set -xe
157-
pwd
158-
python --version
159-
python -m pip install --upgrade pip setuptools wheel
160-
python -m pip install cibuildwheel
161-
shell: bash
162-
163-
- name: Build and test
164-
run: set -xe && python -m cibuildwheel --output-dir wheelhouse
54+
- name: Install cibuildwheel
55+
run: python -m pip install cibuildwheel==2.22.0
56+
- name: Build wheels
57+
run: python -m cibuildwheel --output-dir wheelhouse
16558
env:
166-
CIBW_BUILD: ${{ matrix.python_tag }}-${{ matrix.arch_tag }}
167-
CIBW_BUILD_VERBOSITY: 3
168-
CIBW_TEST_REQUIRES: pytest
169-
CIBW_BEFORE_TEST: pip install -r requirements-test.txt
59+
CIBW_ARCHS_LINUX: auto aarch64
60+
CIBW_ARCHS_MACOS: universal2
61+
CIBW_BUILD: "cp310-* cp311-* cp312-* cp313-* cp313t-*"
62+
CIBW_BUILD_VERBOSITY: 1
63+
CIBW_FREE_THREADED_SUPPORT: True
64+
CIBW_PRERELEASE_PYTHONS: True
65+
CIBW_SKIP: "*musllinux* *i686* *win32* *t-win*"
17066
CIBW_TEST_COMMAND: pytest --pyargs tree
171-
CIBW_ARCHS_LINUX: ${{ matrix.arch }}
172-
shell: bash
173-
174-
- name: Directory listing
175-
run: ls -lh wheelhouse/dm_tree*.whl
176-
shell: bash
177-
178-
- uses: actions/upload-artifact@v2
67+
CIBW_TEST_REQUIRES: pytest
68+
MAKEFLAGS: "-j$(nproc)"
69+
- uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4.6.0
17970
if: ${{ github.event_name == 'workflow_dispatch' || (github.event_name == 'release' && github.event.action == 'created') }}
18071
with:
181-
name: dm-tree-${{ github.workflow }}-${{ github.run_number }}
182-
path: wheelhouse/dm_tree*.whl
72+
name: dm-tree-bdist-wheel-${{ matrix.os }}-${{ strategy.job-index }}
73+
path: wheelhouse/*.whl

setup.py

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,6 @@ def _get_tree_version():
4040
return ns['__version__']
4141

4242

43-
def _parse_requirements(path):
44-
with open(os.path.join(here, path)) as f:
45-
return [
46-
line.rstrip() for line in f
47-
if not (line.isspace() or line.startswith('#'))
48-
]
49-
50-
5143
class CMakeExtension(setuptools.Extension):
5244
"""An extension with no sources.
5345
@@ -106,10 +98,13 @@ def build_extension(self, ext):
10698
cmake_args.append(f'-DCMAKE_OSX_ARCHITECTURES={";".join(osx_archs)}')
10799
os.makedirs(self.build_temp, exist_ok=True)
108100
subprocess.check_call(
109-
['cmake', ext.source_dir] + cmake_args, cwd=self.build_temp)
110-
subprocess.check_call(
111-
['cmake', '--build', '.', f'-j{os.cpu_count()}', '--config', build_cfg],
112-
cwd=self.build_temp)
101+
['cmake', '-S', ext.source_dir, '-B', self.build_temp] + cmake_args)
102+
num_jobs = ()
103+
if self.parallel:
104+
num_jobs = (f'-j{self.parallel}',)
105+
subprocess.check_call([
106+
'cmake', '--build', self.build_temp, *num_jobs, '--config', build_cfg
107+
])
113108

114109
# Force output to <extension_dir>/. Amends CMake multigenerator output paths
115110
# on Windows and avoids Debug/ and Release/ subdirs, which is CMake default.
@@ -132,7 +127,16 @@ def build_extension(self, ext):
132127
long_description_content_type='text/markdown',
133128
# Contained modules and scripts.
134129
packages=setuptools.find_packages(),
135-
tests_require=_parse_requirements('requirements-test.txt'),
130+
install_requires=[
131+
'absl-py>=0.6.1',
132+
'attrs>=18.2.0',
133+
'numpy>=1.21',
134+
"numpy>=1.21.2; python_version>='3.10'",
135+
"numpy>=1.23.3; python_version>='3.11'",
136+
"numpy>=1.26.0; python_version>='3.12'",
137+
"numpy>=2.1.0; python_version>='3.13'",
138+
'wrapt>=1.11.2',
139+
],
136140
test_suite='tree',
137141
cmdclass=dict(build_ext=BuildCMakeExtension),
138142
ext_modules=[CMakeExtension('_tree', source_dir='tree')],

0 commit comments

Comments
 (0)