Skip to content

Commit 2cdf828

Browse files
hansenmsMichael Hansen
andauthored
Conda build (#56)
* Added conda build and fixed broken tests * Remove debug code * Removed Azure DevOps pipeline * Disabling nosetests on mac * PR review * Removed macos conda build for now * bump numpy in requirements file Co-authored-by: Michael Hansen <mihansen@microsoft>
1 parent b4ab63b commit 2cdf828

File tree

13 files changed

+201
-52
lines changed

13 files changed

+201
-52
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
on:
2+
pull_request:
3+
branches:
4+
- master
5+
release:
6+
types:
7+
- created
8+
9+
jobs:
10+
build-conda-packages:
11+
strategy:
12+
matrix:
13+
os: [ubuntu-latest]
14+
runs-on: ${{ matrix.os }}
15+
steps:
16+
- uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b
17+
- uses: conda-incubator/setup-miniconda@e81abac10ce2c37423b54eae5af93aa3b4d3475c
18+
with:
19+
activate-environment: ismrmrd-python-build
20+
environment-file: conda/environment.yml
21+
python-version: 3.9
22+
auto-activate-base: false
23+
- name: Build conda package
24+
shell: bash -l {0}
25+
working-directory: conda
26+
run: |
27+
./package.sh
28+
echo "Packages built: $(find build_pkg -name ismrmrd-python*.tar.bz2)"
29+
- name: Push conda package
30+
shell: bash -l {0}
31+
if: ${{ github.event_name == 'release' }}
32+
env:
33+
ANACONDA_TOKEN: ${{ secrets.ANACONDA_TOKEN }}
34+
working-directory: conda
35+
run: |
36+
./publish_package.sh -u ismrmrd -t "$ANACONDA_TOKEN" -p `find build_pkg -name ismrmrd-python*.tar.bz2`

azure-pipelines.yml

Lines changed: 0 additions & 47 deletions
This file was deleted.

conda/.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
build_pkg/
2+
.pytest_cache/
3+
__pycache__/

conda/build.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/bash
2+
3+
set -euo pipefail
4+
5+
python setup.py install

conda/environment.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
name: ismrmrd-python-build
2+
channels:
3+
- conda-forge
4+
dependencies:
5+
- conda-build
6+
- anaconda-client
7+

conda/meta.yaml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
{% set data = load_setup_py_data() %}
2+
3+
package:
4+
name: ismrmrd-python
5+
version: {{ data.get('version') }}
6+
7+
source:
8+
path: ../
9+
10+
requirements:
11+
build:
12+
- numpy>=1.22.0
13+
- h5py>=2.3
14+
- nose>=1.0
15+
- xsdata>=22.2
16+
17+
run:
18+
- xsdata>=22.2
19+
- numpy>=1.22.0
20+
- h5py>=2.3
21+
22+
test:
23+
source_files:
24+
- tests
25+
requires:
26+
- nose
27+
28+
about:
29+
home: https://github.com/ismrmrd/ismrmrd-python
30+
license: MIT
31+
summary: 'Python interface for ISMRMRD'
32+
description: |
33+
Python interface and utilities for the ISMRM Raw Data (ISMRMRD a.k.a. MRD) format.
34+
dev_url: https://github.com/ismrmrd/ismrmrd-python
35+
doc_url: https://github.com/ismrmrd/ismrmrd-python
36+
doc_source_url: https://github.com/ismrmrd/ismrmrd-python/blob/main/README.md

conda/package.sh

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/bin/bash
2+
set -euo pipefail
3+
4+
usage()
5+
{
6+
cat << EOF
7+
8+
Builds the ismrmrd-python conda package.
9+
10+
Usage: $0
11+
EOF
12+
}
13+
14+
output_path="$(dirname "$0")/build_pkg"
15+
16+
# Build up channel directives
17+
channels=(
18+
conda-forge
19+
)
20+
21+
channel_directives=$(printf -- "-c %s " "${channels[@]}")
22+
23+
mkdir -p "$output_path"
24+
bash -c "conda build --no-anaconda-upload --output-folder $output_path $channel_directives $(dirname "$0")"

conda/publish_package.sh

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
#!/bin/bash
2+
set -euo pipefail
3+
4+
usage()
5+
{
6+
cat << EOF
7+
8+
Publishes a conda package.
9+
10+
Usage: $0 [options]
11+
12+
Options:
13+
-p|--package_path <path> Path to the package (tar.gz) to push
14+
-u|--user <user> Anaconda.org channeluser or organization
15+
-t|--token <token> Token for uploading to anaconda.org
16+
-f|--force Force push even if package exists
17+
-h| --help Brings up this menu
18+
EOF
19+
}
20+
21+
while [[ $# -gt 0 ]]; do
22+
key="$1"
23+
24+
case $key in
25+
-p|--package_path)
26+
package_path="$2"
27+
shift
28+
shift
29+
;;
30+
-u|--user)
31+
user="$2"
32+
shift
33+
shift
34+
;;
35+
-t|--token)
36+
token="$2"
37+
shift
38+
shift
39+
;;
40+
--force)
41+
force=1
42+
shift
43+
;;
44+
-h|--help)
45+
usage
46+
exit
47+
;;
48+
*)
49+
echo "ERROR: unknown option \"$key\""
50+
usage
51+
exit 1
52+
;;
53+
esac
54+
done
55+
56+
if [[ -z "${package_path:-}" ]]; then
57+
echo "You cannot push to anaconda without a package"
58+
echo "Please supply a package path with the --package_path argument"
59+
exit 1
60+
fi
61+
if [[ -z "${token:-}" ]]; then
62+
echo "You cannot push to anaconda without a token"
63+
echo "Please supply a token with the --token argument"
64+
exit 1
65+
fi
66+
if [[ -z "${user:-}" ]]; then
67+
echo "You cannot push to anaconda without a user"
68+
echo "Please supply a user with the --user argument"
69+
exit 1
70+
fi
71+
72+
force_directive="--skip-existing"
73+
if [[ -n ${force:-} ]]; then
74+
force_directive="--force"
75+
fi
76+
77+
anaconda -t "$token" upload -u "$user" $force_directive "$package_path"

conda/run_test.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/bin/bash
2+
3+
set -euo pipefail
4+
5+
cd tests
6+
nosetests
7+

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
h5py==2.9.0
22
nose==1.3.7
3-
numpy==1.21.0
3+
numpy==1.22.0
44
PyXB==1.2.6
55
six==1.12.0
66
xsdata==22.2

0 commit comments

Comments
 (0)