@@ -10,141 +10,60 @@ permissions:
1010 contents : write
1111
1212jobs :
13- build-wheels :
13+ build_wheels :
1414 name : Build wheels on ${{ matrix.os }}
1515 runs-on : ${{ matrix.os }}
1616 strategy :
1717 matrix :
1818 os : [ubuntu-latest, windows-latest, macos-latest]
19- python-version : ['3.8', '3.9', '3.10', '3.11', '3.12']
20-
19+
2120 steps :
22- - uses : actions/checkout@v4
23-
24- - name : Set up Python ${{ matrix.python-version }}
25- uses : actions/setup-python@v5
26- with :
27- python-version : ${{ matrix.python-version }}
28-
29- - name : Install build tools (Ubuntu)
30- if : runner.os == 'Linux'
31- run : |
32- sudo apt-get update
33- sudo apt-get install -y build-essential gcc g++ make
34-
35- - name : Install build tools (macOS)
36- if : runner.os == 'macOS'
37- run : |
38- brew install gcc make
39-
40- - name : Install build tools (Windows)
41- if : runner.os == 'Windows'
42- run : |
43- choco install mingw -y
44- refreshenv
45-
46-
47- - name : Install Python dependencies
48- run : |
49- python -m pip install --upgrade pip
50- pip install build wheel setuptools Cython numpy scipy pillow matplotlib
51-
52- - name : Build optimized library (Unix)
53- if : runner.os != 'Windows'
54- run : |
55- cd pycnn/lib
56- make
57- env :
58- GITHUB_ACTIONS : true
59-
60- - name : Build optimized library (Windows)
61- if : runner.os == 'Windows'
62- shell : cmd
63- run : |
64- cd pycnn\lib
65- mingw32-make
66- env :
67- GITHUB_ACTIONS : true
68-
69- - name : Build wheel and sdist
70- run : python -m build
71- env :
72- GITHUB_ACTIONS : true
21+ - uses : actions/checkout@v4
7322
74- - name : Repair Linux wheels
75- if : runner.os == 'Linux'
76- run : |
77- pip install auditwheel
78- for whl in dist/*.whl; do
79- auditwheel repair "$whl" -w dist/repaired/
80- done
81- # Replace original wheels with repaired ones
82- rm dist/*.whl
83- mv dist/repaired/*.whl dist/
84- rmdir dist/repaired
85-
86- - name : Repair macOS wheels
87- if : runner.os == 'macOS'
88- run : |
89- pip install delocate
90- for whl in dist/*.whl; do
91- delocate-wheel -v "$whl"
92- done
23+ - name : Build wheels
24+ uses : pypa/cibuildwheel@v2.21.3
25+ env :
26+ CIBW_BEFORE_BUILD_LINUX : yum install -y make gcc gcc-c++ && cd pycnn/lib && make
27+ CIBW_BEFORE_BUILD_MACOS : cd pycnn/lib && make
28+ CIBW_BEFORE_BUILD_WINDOWS : cd pycnn\lib && mingw32-make
29+ CIBW_ENVIRONMENT : GITHUB_ACTIONS=true
30+ CIBW_SKIP : " pp* cp36* cp37*" # Skip pypy and old python versions
9331
94- - name : Upload artifacts
95- uses : actions/upload-artifact@v4
96- with :
97- name : dist-${{ matrix.os }}-py${{ matrix.python-version }}
98- path : dist/*
99- retention-days : 7
100-
101- - name : Upload compiled library
102- uses : actions/upload-artifact@v4
103- with :
104- name : lib-${{ matrix.os }}-py${{ matrix.python-version }}
105- path : |
106- pycnn/lib/*.dll
107- pycnn/lib/*.so
108- pycnn/lib/*.dylib
109- retention-days : 7
32+ - uses : actions/upload-artifact@v4
33+ with :
34+ name : cibw-wheels-${{ matrix.os }}-${{ strategy.job-index }}
35+ path : ./wheelhouse/*.whl
36+
37+ build_sdist :
38+ name : Build source distribution
39+ runs-on : ubuntu-latest
40+ steps :
41+ - uses : actions/checkout@v4
42+ - name : Build sdist
43+ run : pipx run build --sdist
44+ - uses : actions/upload-artifact@v4
45+ with :
46+ name : cibw-sdist
47+ path : dist/*.tar.gz
11048
11149 create-release :
112- name : Create Release and Upload Assets
113- needs : build-wheels
50+ name : Create Release
51+ needs : [build_wheels, build_sdist]
11452 runs-on : ubuntu-latest
11553 if : startsWith(github.ref, 'refs/tags/')
116-
11754 steps :
118- - uses : actions/checkout@v4
119-
120- - name : Download all artifacts
121- uses : actions/download-artifact@v4
122- with :
123- path : artifacts
124-
125- - name : Organize compiled libraries
126- run : |
127- mkdir -p release-libs
128- find artifacts -name "*.dll" -exec cp {} release-libs/ \; || true
129- find artifacts -name "*.so" -exec cp {} release-libs/ \; || true
130- find artifacts -name "*.dylib" -exec cp {} release-libs/ \; || true
131- ls -la release-libs/
132-
133- - name : Organize dist files
134- run : |
135- mkdir -p release-dist
136- find artifacts -name "*.whl" -exec cp {} release-dist/ \;
137- find artifacts -name "*.tar.gz" -exec cp {} release-dist/ \;
138- ls -la release-dist/
139-
140- - name : Create Release
141- uses : softprops/action-gh-release@v1
142- with :
143- files : |
144- release-libs/*
145- release-dist/*
146- draft : false
147- prerelease : false
148- generate_release_notes : true
149- env :
150- GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
55+ - uses : actions/download-artifact@v4
56+ with :
57+ path : dist
58+ pattern : cibw-*
59+ merge-multiple : true
60+
61+ - name : Create Release
62+ uses : softprops/action-gh-release@v1
63+ with :
64+ files : dist/*
65+ draft : false
66+ prerelease : false
67+ generate_release_notes : true
68+ env :
69+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
0 commit comments