|
1 | | -name: Upload Python Package on PyPI server |
| 1 | +name: Build & Upload G2S to PyPI |
2 | 2 |
|
3 | 3 | on: |
4 | 4 | workflow_dispatch: |
5 | | - # push: |
6 | | - # paths: |
7 | | - # - 'version' |
8 | 5 |
|
9 | 6 | jobs: |
10 | | - deploy: |
11 | | - name: Compile for ${{ matrix.OS }} using ${{ matrix.python }} and upload on packages manager |
| 7 | + build-sdist: |
| 8 | + name: 📦 Source distribution |
| 9 | + runs-on: ubuntu-latest |
| 10 | + steps: |
| 11 | + - uses: actions/checkout@v4 |
| 12 | + - uses: actions/setup-python@v5 |
| 13 | + with: |
| 14 | + python-version: "3.12" |
| 15 | + - run: | |
| 16 | + pip install --upgrade pip build twine |
| 17 | + cd build |
| 18 | + make python-sdist |
| 19 | + cd python-build |
| 20 | + twine upload --repository pypi dist/*.tar.gz --skip-existing --verbose |
| 21 | + env: |
| 22 | + TWINE_USERNAME: __token__ |
| 23 | + TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }} |
| 24 | +
|
| 25 | + build-linux: |
| 26 | + name: 🐧 Linux wheels (manylinux) |
| 27 | + runs-on: ubuntu-latest |
12 | 28 | strategy: |
13 | 29 | matrix: |
14 | | - OS: [ ubuntu-20.04, windows-latest, macOS-latest] |
15 | | - python: ['3.7', '3.8', '3.9','3.10','3.11', 'pypy-3.8', 'pypy-3.9' ] |
16 | | - arch: [ x64 ] |
17 | | - include: |
18 | | - - os: ubuntu-20.04 |
19 | | - python: '3.6' |
20 | | - arch: x64 |
| 30 | + python: ["3.9", "3.10", "3.11", "3.12", "3.13"] |
21 | 31 | fail-fast: false |
22 | | - runs-on: ${{ matrix.OS }} |
23 | 32 | steps: |
24 | | - - uses: actions/checkout@v3 |
25 | | - - name: Set up Python |
26 | | - uses: actions/setup-python@v4 |
27 | | - with: |
28 | | - python-version: ${{ matrix.python }} |
| 33 | + - uses: actions/checkout@v4 |
| 34 | + - uses: actions/setup-python@v5 |
| 35 | + with: |
| 36 | + python-version: ${{ matrix.python }} |
| 37 | + - name: Build inside manylinux |
| 38 | + run: | |
| 39 | + PYVER=$(echo ${{ matrix.python }} | tr -d .) |
| 40 | + PYTAG="cp${PYVER}-cp${PYVER}" |
| 41 | + echo "🧱 Building for $PYTAG using manylinux_2_28" |
| 42 | +
|
| 43 | + docker run --rm -v $PWD:/io quay.io/pypa/manylinux_2_28_x86_64 bash -c " |
| 44 | + set -e |
| 45 | + echo '🐍 Installing build dependencies...' |
| 46 | + /opt/python/${PYTAG}/bin/python -m pip install --upgrade pip build wheel numpy pyzmq twine auditwheel |
| 47 | +
|
| 48 | + echo '🏗️ Building wheel...' |
| 49 | + cd /io/build |
| 50 | + make PYTHON=/opt/python/${PYTAG}/bin/python python-wheel |
29 | 51 |
|
30 | | - - name: Install dependencies |
31 | | - run: | |
32 | | - python -m pip install --upgrade pip |
33 | | - pip install oldest-supported-numpy |
34 | | - pip install setuptools wheel twine packaging |
| 52 | + echo '🧩 Running auditwheel repair...' |
| 53 | + cd /io/build/python-build/dist |
| 54 | + auditwheel repair *.whl -w . |
| 55 | + rm -f *linux_x86_64.whl |
35 | 56 |
|
36 | | - - name: Install Ubuntu dependencies |
37 | | - if : contains( matrix.OS, 'ubuntu' ) |
38 | | - run: | |
39 | | - sudo add-apt-repository 'deb [arch=amd64] http://archive.ubuntu.com/ubuntu focal main universe' |
40 | | - sudo apt update; |
41 | | - sudo apt install build-essential libzmq3-dev patchelf |
42 | | - sudo apt -y install gcc-7 g++-7 |
43 | | - sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-7 7 |
44 | | - sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-7 7 |
45 | | - wget "https://raw.githubusercontent.com/zeromq/cppzmq/master/zmq.hpp" -O include/zmq.hpp |
46 | | - wget 'https://codeload.github.com/open-source-parsers/jsoncpp/zip/master' -O jsoncpp.zip |
47 | | - unzip jsoncpp.zip |
48 | | - cd jsoncpp-master |
49 | | - python amalgamate.py |
50 | | - cd .. |
51 | | - git clone https://github.com/zeromq/libzmq.git |
52 | | - cd libzmq |
53 | | - export CFLAGS="-fPIC" |
54 | | - export CXXFLAGS="-fPIC" |
55 | | - bash ./autogen.sh |
56 | | - ./configure --prefix=/tmp/zeromq |
57 | | - make -j |
58 | | - make install |
59 | | - echo "STATIC_ZMQ_PATH=/tmp/zeromq/lib/libzmq.a" >> $GITHUB_ENV |
| 57 | + echo '✅ Listing final wheels:' |
| 58 | + ls -lh |
| 59 | + " |
| 60 | + - name: Test import |
| 61 | + run: | |
| 62 | + pip install build/python-build/dist/*.whl |
| 63 | + python -c "import g2s; print('✅ g2s import OK')" |
| 64 | + - name: Upload to TestPyPI |
| 65 | + env: |
| 66 | + TWINE_USERNAME: __token__ |
| 67 | + TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }} |
| 68 | + run: | |
| 69 | + cd build/python-build |
| 70 | + python -m pip install --upgrade twine |
| 71 | + twine upload --repository pypi dist/*.whl --skip-existing --verbose |
60 | 72 |
|
61 | | - - name: Install macOS dependencies |
62 | | - if : contains( matrix.OS, 'macOS' ) |
63 | | - run: | |
64 | | - brew install zeromq jsoncpp cppzmq |
65 | | - echo "STATIC_ZMQ_PATH=$(brew --prefix)/lib/libzmq.a" >> $GITHUB_ENV |
| 73 | + build-macos: |
| 74 | + name: 🍎 macOS wheels |
| 75 | + runs-on: macos-latest |
| 76 | + strategy: |
| 77 | + matrix: |
| 78 | + python: ["3.9", "3.10", "3.11", "3.12", "3.13"] |
| 79 | + fail-fast: false |
| 80 | + steps: |
| 81 | + - uses: actions/checkout@v4 |
| 82 | + - uses: actions/setup-python@v5 |
| 83 | + with: |
| 84 | + python-version: ${{ matrix.python }} |
| 85 | + - name: Install dependencies |
| 86 | + run: | |
| 87 | + pip install --upgrade pip build wheel numpy pyzmq twine |
| 88 | + - name: Build wheel |
| 89 | + run: | |
| 90 | + cd build |
| 91 | + make python-wheel |
| 92 | + - name: Test import |
| 93 | + run: | |
| 94 | + pip install build/python-build/dist/*.whl |
| 95 | + python -c "import g2s; print('✅ g2s import OK')" |
| 96 | + - name: Upload to TestPyPI |
| 97 | + env: |
| 98 | + TWINE_USERNAME: __token__ |
| 99 | + TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }} |
| 100 | + run: | |
| 101 | + cd build/python-build |
| 102 | + twine upload --repository pypi dist/*.whl --skip-existing --verbose |
| 103 | +
|
| 104 | + build-windows: |
| 105 | + name: 🪟 Windows wheels |
| 106 | + runs-on: windows-latest |
| 107 | + strategy: |
| 108 | + matrix: |
| 109 | + python: ["3.9", "3.10", "3.11", "3.12", "3.13"] |
| 110 | + fail-fast: false |
| 111 | + steps: |
| 112 | + - uses: actions/checkout@v4 |
| 113 | + - uses: actions/setup-python@v5 |
| 114 | + with: |
| 115 | + python-version: ${{ matrix.python }} |
| 116 | + - name: Install dependencies |
| 117 | + run: | |
| 118 | + python -m pip install --upgrade pip build wheel numpy pyzmq twine |
| 119 | + - name: Setup MSBuild |
| 120 | + uses: microsoft/setup-msbuild@v2 |
| 121 | + - name: Install Windows dependencies |
| 122 | + run: | |
| 123 | + cd build/python-build |
| 124 | + cmd.exe /c setup_Win_compile_all.bat |
| 125 | + - name: Build wheel |
| 126 | + run: | |
| 127 | + choco install make |
| 128 | + refreshenv |
| 129 | + cd build |
| 130 | + make python-wheel |
| 131 | + - name: Test import |
| 132 | + shell: pwsh |
| 133 | + run: | |
| 134 | + $wheel = Get-ChildItem build/python-build/dist/*.whl | Select-Object -First 1 |
| 135 | + Write-Host "Installing wheel: $($wheel.FullName)" |
| 136 | + pip install "$($wheel.FullName)" |
| 137 | + python -c "import g2s; print('g2s import OK')" |
| 138 | + - name: Upload to TestPyPI |
| 139 | + env: |
| 140 | + TWINE_USERNAME: __token__ |
| 141 | + TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }} |
| 142 | + run: | |
| 143 | + cd build/python-build |
| 144 | + twine upload --repository pypi dist/*.whl --skip-existing --verbose |
66 | 145 |
|
67 | | - - name: Add msbuild to PATH |
68 | | - if : contains( matrix.os, 'windows' ) |
69 | | - uses: microsoft/setup-msbuild@v1.1 |
70 | | - - name: Install Windows dependencies |
71 | | - if : contains( matrix.OS, 'windows' ) |
72 | | - run: | |
73 | | - cd build/python-build |
74 | | - cmd.exe /c setup_Win_compile_all.bat |
75 | | - |
76 | | - - name: Build on Linux or macOS |
77 | | - if: runner.os != 'Windows' |
78 | | - run: | |
79 | | - cd build/python-build |
80 | | - STATIC_ZMQ_PATH=${{ env.STATIC_ZMQ_PATH }} python setup.py --setuptools bdist_wheel |
81 | | - - name: Build on Windows |
82 | | - if: runner.os == 'Windows' |
83 | | - run: | |
84 | | - cd build\python-build |
85 | | - python setup.py --setuptools bdist_wheel |
86 | | - |
87 | | - - name: Correct whl for Linux |
88 | | - if : contains( matrix.OS, 'ubuntu' ) |
89 | | - run: | |
90 | | - cd build/python-build/dist |
91 | | - # pip install auditwheel |
92 | | - # auditwheel repair *.whl |
93 | | - # for wheel in $(find . -iname "*.whl") ; do unzip -o $wheel; patchelf --clear-symbol-version stat --clear-symbol-version _ZSt28__throw_bad_array_new_lengthv g2s/*.so; zip -u $wheel g2s/*.so; done |
94 | | - for wheel in $(find . -iname "*.whl") ; do mv $wheel $(echo $wheel | sed 's/-linux_/-manylinux1_/'); done |
95 | | - - name: Correct whl for macOS |
96 | | - if : contains( matrix.OS, 'macOS' ) |
97 | | - run: | |
98 | | - cd build/python-build |
99 | | - pip install delocate |
100 | | - delocate-wheel -v dist/*.whl |
101 | | - |
102 | | - - name: Publish |
103 | | - env: |
104 | | - TWINE_USERNAME: __token__ |
105 | | - TWINE_PASSWORD: ${{ secrets.PYPI_Token }} |
106 | | - run: | |
107 | | - cd build/python-build |
108 | | - twine upload dist/*.whl --verbose |
109 | | -# --skip-existing |
|
0 commit comments