1- name : Build
1+ name : Build Wheels
22
33on :
44 push :
@@ -10,60 +10,126 @@ 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-
19+ python-version : ['3.8', '3.9', '3.10', '3.11', '3.12']
20+
2021 steps :
21- - uses : actions/checkout@v4
22-
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
31-
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
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
70+ run : python -m build --wheel
71+ env :
72+ GITHUB_ACTIONS : true
73+
74+ - name : Upload wheel artifact
75+ uses : actions/upload-artifact@v4
76+ with :
77+ name : wheel-${{ matrix.os }}-py${{ matrix.python-version }}
78+ path : dist/*.whl
79+ retention-days : 7
80+
81+ - name : Upload compiled library
82+ uses : actions/upload-artifact@v4
83+ with :
84+ name : lib-${{ matrix.os }}-py${{ matrix.python-version }}
85+ path : |
86+ pycnn/lib/*.dll
87+ pycnn/lib/*.so
88+ pycnn/lib/*.dylib
89+ retention-days : 7
4890
4991 create-release :
50- name : Create Release
51- needs : [build_wheels, build_sdist]
92+ name : Create Release and Upload Assets
93+ needs : build-wheels
5294 runs-on : ubuntu-latest
5395 if : startsWith(github.ref, 'refs/tags/')
96+
5497 steps :
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 }}
98+ - uses : actions/checkout@v4
99+
100+ - name : Download all artifacts
101+ uses : actions/download-artifact@v4
102+ with :
103+ path : artifacts
104+
105+ - name : Organize compiled libraries
106+ run : |
107+ mkdir -p release-libs
108+ # Copy and rename for each platform/python to ensure uniqueness
109+ find artifacts -name "*.dll" -exec cp {} release-libs/ \; || true
110+ find artifacts -name "*.so" -exec cp {} release-libs/ \; || true
111+ find artifacts -name "*.dylib" -exec cp {} release-libs/ \; || true
112+
113+ # Renaissance naming for native libs to match what setup.py expects
114+ # We rename them to include the OS name if they are distinct
115+ # Actually, if we just upload the .whl, most users will get the lib from the whl.
116+ # But for source installs, we provide these as fallbacks.
117+ ls -la release-libs/
118+
119+ - name : Organize wheels
120+ run : |
121+ mkdir -p release-wheels
122+ find artifacts -name "*.whl" -exec cp {} release-wheels/ \;
123+ ls -la release-wheels/
124+
125+ - name : Create Release
126+ uses : softprops/action-gh-release@v1
127+ with :
128+ files : |
129+ release-libs/*
130+ release-wheels/*
131+ draft : false
132+ prerelease : false
133+ generate_release_notes : true
134+ env :
135+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
0 commit comments