Skip to content

Commit 6802928

Browse files
authored
Merge pull request #154 from boutproject/packaging-update
Packaging update, auto-publish to PyPi
2 parents 4b4fc97 + 249e46e commit 6802928

File tree

14 files changed

+336
-106
lines changed

14 files changed

+336
-106
lines changed

.git_archival.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ref-names: $Format:%D$

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.git_archival.txt export-subst

.github/workflows/master.yml

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
2+
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
3+
#
4+
# This workflow should be an exact duplicate of 'Python package' in
5+
# pythonpackage.yml, except that it only runs on pushes to master. This is done
6+
# so that we can refer to this workflow specifically in the status badge in
7+
# README.md
8+
9+
name: master
10+
11+
on:
12+
push:
13+
branches:
14+
- master
15+
16+
jobs:
17+
pytest:
18+
19+
runs-on: ubuntu-latest
20+
if: always()
21+
strategy:
22+
matrix:
23+
python-version: [3.6, 3.7, 3.8]
24+
pip-packages:
25+
- "setuptools pip pytest pytest-cov coverage codecov boutdata xarray!=0.14.0 numpy>=1.16.0"
26+
- "setuptools pip pytest pytest-cov coverage codecov boutdata xarray==0.16.0 dask==2.10.0 numpy==1.16.0 natsort==5.5.0 matplotlib==3.1.1 animatplot==0.4.1 netcdf4==1.4.2 Pillow==6.1.0 fsspec" # test with oldest supported version of packages. Note, using numpy==1.16.0 as a workaround for some weird fails on Travis, in principle we should work with numpy>=1.13.3. We should not need to install fsspec explicitly, but at the moment are getting import errors in the tests due to fsspec not being present - should remove in future, probably when dask version is increased.
27+
fail-fast: false
28+
29+
steps:
30+
- uses: actions/checkout@v2
31+
- name: Set up Python ${{ matrix.python-version }}
32+
uses: actions/setup-python@v1
33+
with:
34+
python-version: ${{ matrix.python-version }}
35+
- name: Install dependencies
36+
run: |
37+
sudo apt-get install libhdf5-dev libnetcdf-dev
38+
python -m pip install --upgrade pip
39+
pip install --upgrade ${{ matrix.pip-packages }}
40+
pip install -e .
41+
- name: Test with pytest
42+
run: |
43+
pip install pytest
44+
pytest -v --long --cov
45+
- name: Upload coverage to Codecov
46+
uses: codecov/codecov-action@v1
47+
with:
48+
fail_ci_if_error: true
49+
50+
51+
# Need to tidy up the things that flake8 finds before we activate this
52+
#flake8:
53+
54+
# runs-on: ubuntu-latest
55+
# if: always()
56+
57+
# steps:
58+
# - uses: actions/checkout@v2
59+
# - name: Set up Python
60+
# uses: actions/setup-python@v1
61+
# - name: Install dependencies
62+
# run: |
63+
# python -m pip install --upgrade pip
64+
# - name: Lint with flake8
65+
# run: |
66+
# pip install flake8
67+
# flake8
68+
69+
70+
black:
71+
72+
runs-on: ubuntu-latest
73+
if: always()
74+
75+
steps:
76+
- uses: actions/checkout@v2
77+
- name: Set up Python
78+
uses: actions/setup-python@v1
79+
- name: Install dependencies
80+
run: |
81+
python -m pip install --upgrade pip
82+
- name: Check formatting with black
83+
run: |
84+
pip install black
85+
black --check .

.github/workflows/pythonpackage.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@
44
name: Python package
55

66
on:
7-
[push, pull_request]
7+
push:
8+
branches-ignore:
9+
- master
10+
pull_request:
811

912
jobs:
1013
pytest:
@@ -30,7 +33,7 @@ jobs:
3033
sudo apt-get install libhdf5-dev libnetcdf-dev
3134
python -m pip install --upgrade pip
3235
pip install --upgrade ${{ matrix.pip-packages }}
33-
pip install -r requirements.txt
36+
pip install -e .
3437
- name: Test with pytest
3538
run: |
3639
pip install pytest
@@ -54,7 +57,6 @@ jobs:
5457
# - name: Install dependencies
5558
# run: |
5659
# python -m pip install --upgrade pip
57-
# pip install -r requirements.txt
5860
# - name: Lint with flake8
5961
# run: |
6062
# pip install flake8
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
# This workflows will upload a Python Package using Twine when a release is created
2+
# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries
3+
4+
name: Upload Python Package
5+
6+
on:
7+
release:
8+
types: [created]
9+
10+
jobs:
11+
pytest:
12+
13+
runs-on: ubuntu-latest
14+
if: always()
15+
strategy:
16+
matrix:
17+
python-version: [3.6, 3.7, 3.8]
18+
pip-packages:
19+
- "setuptools pip pytest pytest-cov coverage codecov boutdata xarray!=0.14.0 numpy>=1.16.0"
20+
- "setuptools pip pytest pytest-cov coverage codecov boutdata xarray==0.16.0 dask==2.10.0 numpy==1.16.0 natsort==5.5.0 matplotlib==3.1.1 animatplot==0.4.1 netcdf4==1.4.2 Pillow==6.1.0 fsspec" # test with oldest supported version of packages. Note, using numpy==1.16.0 as a workaround for some weird fails on Travis, in principle we should work with numpy>=1.13.3. We should not need to install fsspec explicitly, but at the moment are getting import errors in the tests due to fsspec not being present - should remove in future, probably when dask version is increased.
21+
fail-fast: true
22+
23+
steps:
24+
- uses: actions/checkout@v2
25+
- name: Set up Python ${{ matrix.python-version }}
26+
uses: actions/setup-python@v1
27+
with:
28+
python-version: ${{ matrix.python-version }}
29+
- name: Install dependencies
30+
run: |
31+
sudo apt-get install libhdf5-dev libnetcdf-dev
32+
python -m pip install --upgrade pip
33+
pip install --upgrade ${{ matrix.pip-packages }}
34+
pip install -e .
35+
- name: Test with pytest
36+
run: |
37+
pip install pytest
38+
pytest -v --long --cov
39+
- name: Upload coverage to Codecov
40+
uses: codecov/codecov-action@v1
41+
with:
42+
fail_ci_if_error: true
43+
44+
45+
# Need to tidy up the things that flake8 finds before we activate this
46+
#flake8:
47+
48+
# runs-on: ubuntu-latest
49+
# if: always()
50+
51+
# steps:
52+
# - uses: actions/checkout@v2
53+
# - name: Set up Python
54+
# uses: actions/setup-python@v1
55+
# - name: Install dependencies
56+
# run: |
57+
# python -m pip install --upgrade pip
58+
# - name: Lint with flake8
59+
# run: |
60+
# pip install flake8
61+
# flake8
62+
63+
64+
black:
65+
66+
runs-on: ubuntu-latest
67+
if: always()
68+
69+
steps:
70+
- uses: actions/checkout@v2
71+
- name: Set up Python
72+
uses: actions/setup-python@v1
73+
- name: Install dependencies
74+
run: |
75+
python -m pip install --upgrade pip
76+
- name: Check formatting with black
77+
run: |
78+
pip install black
79+
black --check .
80+
81+
deploy:
82+
83+
runs-on: ubuntu-latest
84+
needs: [pytest, black]
85+
86+
steps:
87+
- uses: actions/checkout@v2
88+
- name: Set up Python
89+
uses: actions/setup-python@v1
90+
with:
91+
python-version: '3.x'
92+
- name: Install dependencies
93+
run: |
94+
sudo apt-get install libhdf5-dev libnetcdf-dev
95+
python -m pip install --upgrade pip
96+
pip install --upgrade setuptools wheel twine
97+
pip install -e .
98+
- name: Build and publish
99+
env:
100+
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
101+
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
102+
run: |
103+
git fetch --tags --unshallow
104+
python setup.py sdist bdist_wheel
105+
twine upload dist/*

LICENSE

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,10 @@
186186
same "printed page" as the copyright notice for easier
187187
identification within third-party archives.
188188

189-
Copyright [yyyy] [name of copyright owner]
189+
Copyright 2020 The contributors to the xBOUT project.
190+
xBOUT provides an interface for collecting the output data from a BOUT++
191+
simulation into an xarray dataset in an efficient and scalable way, as well
192+
as accessor methods for common BOUT++ analysis and plotting tasks.
190193

191194
Licensed under the Apache License, Version 2.0 (the "License");
192195
you may not use this file except in compliance with the License.

README.md

Lines changed: 33 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# xBOUT
22

3-
[![Build Status](https://travis-ci.org/boutproject/xBOUT.svg?branch=master)](https://travis-ci.org/boutproject/xBOUT.svg?branch=master)
3+
[![Build Status](https://github.com/boutproject/xBOUT/workflows/master/badge.svg)](https://github.com/boutproject/xBOUT/actions)
44
[![codecov](https://codecov.io/gh/boutproject/xBOUT/branch/master/graph/badge.svg)](https://codecov.io/gh/boutproject/xBOUT)
55

66
Documentation: https://xbout.readthedocs.io
@@ -17,30 +17,17 @@ and feel free to raise issues asking questions or making suggestions.
1717

1818
### Installation
1919

20-
xBOUT is not currently on pip or conda. Therefore to install xBOUT on
21-
your system you must first clone the repository using:
22-
23-
```bash
24-
git clone [email protected]:boutproject/xBOUT.git
25-
```
26-
or
20+
With pip:
2721
```bash
28-
git clone https://github.com/boutproject/xBOUT.git
22+
pip install --user xbout
2923
```
3024

31-
Once cloned navigate to the `xBOUT` directory and run the following command:
32-
25+
With conda:
3326
```bash
34-
pip3 install --user ./
35-
```
36-
or
37-
```bash
38-
python3 setup.py install
27+
conda install xbout
3928
```
4029

41-
You can run the tests by navigating to the `/xBOUT/` directory and
42-
entering `pytest`. You can also test your installation of `xBOUT` by
43-
running `pytest --pyargs xbout`.
30+
You can test your installation of `xBOUT` by running `pytest --pyargs xbout`.
4431

4532
xBOUT requires other python packages, which will be installed when you
4633
run one of the above install commands if they are not already installed on
@@ -144,6 +131,33 @@ for your BOUT module, but it could potentially be added as an example to
144131
this repository too.
145132

146133

134+
### Developers
135+
136+
Clone the repository with:
137+
```bash
138+
git clone [email protected]:boutproject/xBOUT.git
139+
```
140+
141+
The recommended way to work with `xBOUT` from the git repo is to do an editable
142+
install with pip. Run this command from the `xBOUT/` directory:
143+
```bash
144+
pip install --user -e .
145+
```
146+
which will also install all the required dependencies. Dependencies can also be
147+
installed using pip
148+
```bash
149+
pip install --user -r requirements.txt
150+
```
151+
or conda
152+
```
153+
conda install --file requirements.txt
154+
```
155+
It is possible to use `xBOUT` by adding the `xBOUT/` directory to your
156+
`$PYTHONPATH`.
157+
158+
Test by running `pytest` in the `xBOUT/` directory.
159+
160+
147161
### Development plan
148162

149163
Things which definitely need to be included (see the 1.0 milestone):

pyproject.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[build-system]
2+
requires = ["setuptools >= 42", "wheel", "setuptools_scm[toml]>=3.4", "setuptools_scm_git_archive"]
3+
build-backend = "setuptools.build_meta"
4+
5+
[tool.setuptools_scm]
6+
write_to = "xbout/_version.py"

requirements.txt

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,21 @@
1-
xarray >= 0.16.0
2-
dask[array] >= 2.10.0
3-
natsort >= 5.5.0
4-
matplotlib >= 3.1.1
5-
animatplot >= 0.4.1
6-
netcdf4 >= 1.4.0
7-
Pillow >= 6.1.0
1+
xarray>=0.16.0
2+
boutdata>=0.1.2
3+
dask[array]>=2.10.0
4+
natsort>=5.5.0
5+
matplotlib>=3.1.1
6+
animatplot>=0.4.1
7+
netcdf4>=1.4.0
8+
Pillow>=6.1.0
9+
10+
# Not required for Python>=3.8, but included because conda does not support
11+
# conditional expressions in --file arguments.
12+
# This file should only be used by developers, so the odd extra package is not
13+
# a big issue. If it is not wanted, you can install these dependencies by hand.
14+
importlib-metadata
15+
16+
# for version number in non-installed package:
17+
setuptools>=42
18+
setuptools_scm[toml]>=3.4
19+
20+
# for tests
21+
pytest>=3.3.0

0 commit comments

Comments
 (0)