Skip to content

Commit b5734eb

Browse files
authored
Merge pull request #51 from AdaptiveParticles/versioning
tag-based versioning and deployment
2 parents d53ca6a + 70a8e25 commit b5734eb

File tree

11 files changed

+286
-183
lines changed

11 files changed

+286
-183
lines changed

.github/workflows/build-test.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ jobs:
3535
steps:
3636
- uses: actions/checkout@v2
3737
with:
38+
fetch-depth: 0
3839
submodules: true
3940

4041
- name: Submodule recursive
@@ -93,13 +94,12 @@ jobs:
9394
run: |
9495
python -m venv venv
9596
source venv/bin/activate
96-
pip install wheel
97-
pip install setuptools
97+
pip install wheel setuptools setuptools_scm
9898
python3 setup.py bdist_wheel -b ${{ env.CMAKE_BUILD_DIR }}
9999
100100
- name: Python Install
101101
run: |
102-
pip install --find-links=dist pyapr
102+
pip install dist/pyapr*.whl
103103
104104
- name: Python Test
105105
run: |

.github/workflows/main.yml

Lines changed: 90 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,26 @@
11
# This is a basic workflow to help you get started with Actions
22

3-
name: Build and Deploy
3+
name: build
44

55
# Controls when the workflow will run
66
on:
77
# Triggers the workflow on push or pull request events but only for the master branch
88
push:
9-
branches: [master, develop]
9+
branches:
10+
- master
11+
tags:
12+
- "v*"
1013
pull_request:
11-
branches: [ master, develop ]
14+
branches:
15+
- master
1216

1317
# Allows you to run this workflow manually from the Actions tab
1418
workflow_dispatch:
1519

1620
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
1721
jobs:
18-
job:
19-
name: ${{ matrix.os }}-build-and-test
22+
build-wheels:
23+
name: ${{ matrix.os }} build and test wheels
2024
runs-on: ${{ matrix.os }}
2125
strategy:
2226
fail-fast: false
@@ -25,17 +29,13 @@ jobs:
2529
include:
2630
- os: windows-latest
2731
triplet: x64-windows
28-
openmp: ON
29-
builddir: dist/wheelhouse
30-
builddir1: dist
32+
builddir: dist
3133
- os: ubuntu-latest
3234
triplet: x64-linux
3335
builddir: wheelhouse
34-
builddir1: wheelhouse
3536
- os: macos-latest
3637
triplet: x64-osx
3738
builddir: wheelhouse
38-
builddir1: wheelhouse
3939
env:
4040
# Indicates the CMake build directory where project files and binaries are being produced.
4141
CMAKE_BUILD_DIR: ${{ github.workspace }}/builddir/
@@ -45,16 +45,17 @@ jobs:
4545
CIBW_BUILD: "cp36-* cp37-* cp38-* cp39-*"
4646
CIBW_ARCHS: "auto64"
4747
CIBW_MANYLINUX_X86_64_IMAGE: "manylinux_2_24"
48-
TWINE_USERNAME: __token__
49-
CIBW_BUILD_VERBOSITY: 3
48+
CIBW_BUILD_VERBOSITY: 1
5049
CIBW_REPAIR_WHEEL_COMMAND_MACOS: "pip uninstall -y delocate && pip install git+https://github.com/Chia-Network/delocate.git && delocate-listdeps {wheel} && delocate-wheel -w {dest_dir} -v {wheel}"
51-
# CIBW_BEFORE_TEST_LINUX: "pip install -r requirements.txt"
52-
# CIBW_TEST_COMMAND_LINUX: "python3 -m unittest discover -s ${{ github.workspace }}"
50+
CIBW_REPAIR_WHEEL_COMMAND_WINDOWS: "pip install -U wheel delvewheel && python fix_windows_wheel.py {wheel} {dest_dir}"
51+
CIBW_TEST_COMMAND: "python3 -m unittest discover -s {project}"
52+
CIBW_TEST_SKIP: "*-win_amd64" # skip tests on windows
5353
CIBW_BEFORE_BUILD_LINUX: "apt update && apt install -y libtiff5-dev libhdf5-dev"
5454

5555
steps:
5656
- uses: actions/checkout@v2
5757
with:
58+
fetch-depth: 0
5859
submodules: true
5960

6061
- name: Submodule recursive
@@ -81,7 +82,7 @@ jobs:
8182
key: |
8283
${{ hashFiles( 'external/LibAPR/vcpkg.json' ) }}-${{ hashFiles( '.git/modules/vcpkg/HEAD' )}}-${{ matrix.triplet }}-invalidate
8384
84-
- name: check file paths
85+
- name: Check file paths
8586
run: |
8687
cd ${{ github.workspace }}/external/LibAPR/vcpkg/scripts/buildsystems/
8788
ls
@@ -111,24 +112,84 @@ jobs:
111112
112113
- name: Run cibuildwheel
113114
run: |
114-
python3 -m cibuildwheel --output-dir ${{matrix.builddir1}}
115+
python3 -m cibuildwheel --output-dir ${{matrix.builddir}}
115116
116-
- name: Fix windows wheels
117-
if: contains(matrix.os,'windows')
117+
- name: Upload wheels as artifacts
118+
uses: actions/upload-artifact@v2
119+
with:
120+
name: ${{ matrix.os }}-wheels
121+
path: ${{matrix.builddir}}/
122+
retention-days: 5
123+
124+
windows-tests:
125+
name: windows py${{ matrix.python-version }} tests
126+
runs-on: windows-latest
127+
needs: build-wheels
128+
strategy:
129+
fail-fast: false
130+
matrix:
131+
python-version: [3.6, 3.7, 3.8, 3.9]
132+
include:
133+
- os: windows-latest
134+
triplet: x64-windows
135+
136+
steps:
137+
- name: Checkout
138+
uses: actions/checkout@v2
139+
with:
140+
submodules: false
141+
142+
- name: Set up Python
143+
uses: actions/setup-python@v2
144+
with:
145+
python-version: ${{ matrix.python-version }}
146+
147+
- name: Download wheels from artifacts
148+
uses: actions/download-artifact@v2
149+
with:
150+
name: windows-latest-wheels
151+
path: wheelhouse
152+
153+
- name: Set version string
154+
shell: bash
155+
run: echo "py_version_str=cp$(echo ${{ matrix.python-version }} | tr -d -c 0-9)" >> $GITHUB_ENV
156+
157+
- name: Install package from wheel
158+
shell: bash
118159
run: |
119-
python3 -m pip install wheel
120-
python3 -m pip install delvewheel
121-
python3 fix_windows_wheel.py
160+
ls -R wheelhouse
161+
python -m pip install --upgrade pip
162+
pip install wheelhouse/pyapr-*${{ env.py_version_str }}*.whl
122163
123-
- name: Install twine
164+
- name: Run tests
124165
run: |
125-
python3 -m pip install twine
166+
python -m unittest discover -s ${{ github.workspace }}
167+
126168
127-
- name: Publish to test Pypi
169+
deploy:
170+
runs-on: ubuntu-latest
171+
needs: windows-tests
172+
name: publish to pypi
173+
if: contains(github.ref, 'tags') # only run on tagged commits starting with "v*"
174+
steps:
175+
- name: Download wheels from artifacts
176+
uses: actions/download-artifact@v2
177+
with:
178+
path: wheelhouse
179+
180+
- name: Set up Python
181+
uses: actions/setup-python@v2
182+
with:
183+
python-version: '3.7'
184+
185+
- name: Install dependencies
128186
run: |
129-
python3 -m twine upload --skip-existing --repository pypi ${{matrix.builddir}}/*.whl -p ${{ secrets.PYPI_API_TOKEN }}
187+
python -m pip install --upgrade pip
188+
pip install -U twine
130189
131-
# - name: Test release from pypi 3.7
132-
# run: |
133-
# pip install pyapr
134-
# python3 -m unittest
190+
- name: Publish
191+
env:
192+
TWINE_USERNAME: __token__
193+
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
194+
run: |
195+
twine upload wheelhouse/*wheels/*.whl

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,3 +109,7 @@ venv.bak/
109109

110110
data/
111111
/processing
112+
113+
# written by setuptools_scm
114+
**/_version.py
115+

INSTALL.md

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
### Dependencies
2+
3+
[LibAPR](https://github.com/AdaptiveParticles/LibAPR) is included as a submodule, and built alongside the wrappers.
4+
This requires the following packages:
5+
6+
* HDF5 1.8.20 or higher
7+
* OpenMP > 3.0 (optional, but recommended)
8+
* CMake 3.6 or higher
9+
* LibTIFF 4.0 or higher
10+
11+
The Python library additionally requires Python 3, and the packages listed in [requirements.txt](requirements.txt).
12+
13+
### Installing dependencies on Linux
14+
15+
On Ubuntu, install the `cmake`, `build-essential`, `libhdf5-dev` and `libtiff5-dev` packages (on other distributions,
16+
refer to the documentation there, the package names will be similar). OpenMP support is provided by the GCC compiler
17+
installed as part of the `build-essential` package.
18+
19+
### Installing dependencies on OSX
20+
21+
On OSX, install the `cmake`, `hdf5` and `libtiff` [homebrew](https://brew.sh) packages and have the
22+
[Xcode command line tools](http://osxdaily.com/2014/02/12/install-command-line-tools-mac-os-x/) installed.
23+
If you want to compile with OpenMP support, also install the `llvm` package (this can also be done using homebrew),
24+
as the clang version shipped by Apple currently does not support OpenMP.
25+
26+
### Note for windows users
27+
28+
Please see https://github.com/AdaptiveParticles/LibAPR for the latest windows install instructions.
29+
30+
## Building
31+
32+
The repository requires submodules, so the repository needs to be cloned recursively:
33+
34+
```
35+
git clone --recursive https://github.com/AdaptiveParticles/PyLibAPR.git
36+
```
37+
38+
It is recommended to use a virtual environment, such as `virtualenv`. To set this up, use e.g.
39+
40+
```
41+
pip3 install virtualenv
42+
python3 -m virtualenv myenv
43+
source myenv/bin/activate
44+
```
45+
46+
The required Python packages can be installed via the command
47+
```
48+
pip install -r requirements.txt
49+
```
50+
51+
Once the dependencies are installed, PyLibAPR can be built via the setup.py script:
52+
```
53+
python setup.py install
54+
```
55+
56+
### CMake build options
57+
58+
There are two CMake options that can be given to enable or disable OpenMP and CUDA:
59+
60+
| Option | Description | Default value |
61+
|:--|:--|:--|
62+
| PYAPR_USE_OPENMP | Enable multithreading via OpenMP | ON |
63+
| PYAPR_USE_CUDA | Build available CUDA functionality | OFF |
64+
| PYAPR_PREFER_EXTERNAL_LIBAPR | Use an installed version of LibAPR (if found) rather than building it from submodules | OFF |
65+
66+
When building via the setup.py script, these options can be set via the environment variable `EXTRA_CMAKE_ARGS`. For example,
67+
```
68+
EXTRA_CMAKE_ARGS="-DPYAPR_USE_OPENMP=OFF -DPYAPR_USE_CUDA=OFF" python setup.py install
69+
```
70+
will install the package with both OpenMP and CUDA disabled. If building from an installed version of LibAPR in a non-standard
71+
location, help CMake find it, e.g., by passing `-DCMAKE_PREFIX_PATH=/path/to/APR`.
72+
73+
### OpenMP support on OSX
74+
75+
To use the homebrew-installed clang for OpenMP support on OSX, modify the call above to
76+
```
77+
CPPFLAGS="-I/usr/local/opt/llvm/include" LDFLAGS="-L/usr/local/opt/llvm/lib -Wl,-rpath,/usr/local/opt/llvm/lib" CXX="/usr/local/opt/llvm/bin/clang++" CC="/usr/local/opt/llvm/bin/clang" python setup.py install
78+
```

0 commit comments

Comments
 (0)