-
Notifications
You must be signed in to change notification settings - Fork 16
135 lines (119 loc) · 5.08 KB
/
package_and_publish.yml
File metadata and controls
135 lines (119 loc) · 5.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
name: PyPI publish
on:
push:
jobs:
packages:
name: Wheels on ${{ matrix.os }} (${{ matrix.cibw_archs }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: true
matrix:
os: [windows-latest, ubuntu-latest, macos-latest]
cibw_archs: ["auto"]
env:
CIBW_SKIP: "*-musllinux_* cp36-* pp3*-win_*"
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
name: Install Python
with:
python-version: '3.13'
- name: Setup conda (windows-latest)
if: matrix.os == 'windows-latest'
uses: s-weigand/setup-conda@v1
- name: Setup conda paths (windows-latest)
if: matrix.os == 'windows-latest'
run: |
echo "LIBRARY_DIRS=C:\Miniconda\Library\lib;C:\Miniconda\Library\bin" >> $env:GITHUB_ENV
echo "INCLUDE_DIRS=C:\Miniconda\Library\include" >> $env:GITHUB_ENV
- name: Setup libjpeg paths (macos-latest)
if: matrix.os == 'macos-latest'
run: |
echo 'LIBRARY_DIRS=/opt/homebrew/opt/jpeg/lib' >> $GITHUB_ENV
echo 'INCLUDE_DIRS=/opt/homebrew/opt/jpeg/include' >> $GITHUB_ENV
# See https://github.com/pypa/cibuildwheel/issues/563#issuecomment-2257729524
- name: Set macOS deployment target
if: matrix.os == 'macos-latest'
run: echo "MACOSX_DEPLOYMENT_TARGET=$(sw_vers -productVersion | cut -d '.' -f 1-2)" >> $GITHUB_ENV
- name: Install cibuildwheel
run: |
python -m pip install cibuildwheel==2.22.0
- name: Build wheels
run: |
python -m cibuildwheel --output-dir dist
env:
CIBW_BUILD: '{cp,pp}3*'
CIBW_MANYLINUX_X86_64_IMAGE: manylinux2014
CIBW_BEFORE_ALL_LINUX: yum -y install epel-release hdf hdf-devel && ln -s /usr/lib64/hdf/lib* /usr/lib64/
CIBW_ARCHS_LINUX: 'x86_64' # restrict to 64bit builds
CIBW_ARCHS_WINDOWS: 'AMD64' # restrict to 64bit builds
# (mac-os) Install hdf4 from sources
CIBW_BEFORE_ALL_MACOS: >
brew install ninja jpeg &&
export PATH="/opt/homebrew/opt/jpeg/bin:$PATH" &&
export LDFLAGS="-L/opt/homebrew/opt/jpeg/lib" &&
export CPPFLAGS="-I/opt/homebrew/opt/jpeg/include" &&
export PKG_CONFIG_PATH="/opt/homebrew/opt/jpeg/lib/pkgconfig" &&
cd /tmp &&
git clone --depth 1 --branch hdf4.3.0 https://github.com/HDFGroup/hdf4.git &&
mkdir build && cd build &&
../hdf4/configure --enable-hdf4-xdr --enable-shared --disable-static --disable-fortran --disable-netcdf --enable-production --with-zlib --prefix=/usr/local &&
sudo make install
CIBW_BEFORE_ALL_WINDOWS: >
conda config --set always_yes yes --set changeps1 no --set auto_update_conda no --set safety_checks disabled &&
conda install -q hdf4
- name: Copy wheels into wheelhouse
run: |
mkdir wheelhouse
cp dist/*.whl wheelhouse
- uses: actions/upload-artifact@v4
with:
name: wheelhouse-${{ matrix.os }}
path: wheelhouse
publish:
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
name: Publish to PyPI
needs: [packages]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Switch to using Python 3.x
uses: actions/setup-python@v4
with:
python-version: 3.x
- name: Create source distribution archive
run: |
python -m pip install build
python -m build --sdist -o wheelhouse
- uses: actions/upload-artifact@v4
with:
name: wheelhouse-sdist
path: wheelhouse
- name: Publish SDIST to PyPI # there are some problems if sdist is not pushed first
if: github.event.base_ref == 'refs/heads/master'
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
packages_dir: wheelhouse/
- name: Download all the wheels
uses: actions/download-artifact@v4
with:
path: ./wheelhouse/
pattern: wheelhouse-*
merge-multiple: true
- name: Publish a Python distribution to Test PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_TEST_TOKEN }}
repository_url: https://test.pypi.org/legacy/
packages_dir: wheelhouse/
verbose: true
- name: Publish a Python distribution to PyPI
if: github.event.base_ref == 'refs/heads/master'
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
packages_dir: wheelhouse/