Skip to content

Commit

Permalink
Merge pull request #62 from HERA-Team/auto-pypi
Browse files Browse the repository at this point in the history
maint: add setuptools_scm support and auto-pypi uploads
  • Loading branch information
steven-murray authored Jan 10, 2023
2 parents 34c7a67 + 729df3d commit fbe195f
Show file tree
Hide file tree
Showing 17 changed files with 167 additions and 132 deletions.
2 changes: 2 additions & 0 deletions .github/release-drafter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ categories:
labels:
- "dependencies"
- "build"
name-template: 'v$RESOLVED_VERSION'
tag-template: 'v$RESOLVED_VERSION'
autolabeler:
- label: 'documentation'
files:
Expand Down
27 changes: 27 additions & 0 deletions .github/workflows/check-build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Check Distribution Build

on: push

jobs:
check-build:
name: Twine Check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
with:
fetch-depth: 0

- uses: actions/setup-python@v4
with:
python-version: "3.10"

- name: Install Build Tools
run: pip install build twine

- name: Build a binary wheel and a source tarball
run: |
python -m build .
- name: Check Distribution
run: |
twine check dist/*
39 changes: 39 additions & 0 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Publish Python distributions to PyPI

on:
release:
types: [published]

jobs:
build-n-publish:
name: Make Release on PyPI and Github
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
with:
fetch-depth: 0

- uses: actions/setup-python@v4
with:
python-version: "3.10"

- name: Install Build Tools
run: pip install build

- name: Build a binary wheel and a source tarball
run: |
python -m build .
- name: Publish to PyPI
if: startsWith(github.event.ref, 'refs/tags/v') &&
uses: pypa/gh-action-pypi-publish@master
with:
password: ${{ secrets.pypi_password }}

- name: Publish the release notes
uses: release-drafter/[email protected]
with:
publish: ${{ startsWith(github.event.ref, 'refs/tags/v') }}
tag: ${{ github.ref_name }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
21 changes: 21 additions & 0 deletions .github/workflows/release-draft.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Update Draft Release

on: push

jobs:
draft-release:
name: Update Draft Release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
with:
fetch-depth: 0

- uses: actions/setup-python@v4
with:
python-version: "3.10"

- name: Publish the release notes
uses: release-drafter/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
55 changes: 0 additions & 55 deletions .github/workflows/run_tests.yml

This file was deleted.

28 changes: 28 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Run Tests

on: [push]

jobs:
Tests:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.8, 3.9, "3.10"]
steps:
- uses: actions/checkout@v2
- name: Set up ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install
run: |
pip install -e .[dev]
- name: Test with pytest
run: pytest --cov=./ --cov-report=xml
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
files: ./coverage.xml
flags: unittests
fail_ci_if_error: true
verbose: true
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@
/aipy/__version__.py
/aipy/*.so
/doc/build/
aipy/_version.py
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

- Remove `ez_setup` installation infrastructure; it has been deprecated for a
long time.
- Allow installing from empty environment
- Use github actions instead of travis
- Use python3 print()
- Use pytest instead of unittest
- Use explicit numpy types

# 3.0.1 (2019 Aug 21)

Expand Down
14 changes: 0 additions & 14 deletions PKG-INFO

This file was deleted.

10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ Aaron Parsons

-----------------------------------------------------------------------------

# Package Info for Developers
## Package Info for Developers

The miriad source code (`aipy/miriad/mirsrc`) was included from MIRIAD 4.0.5.
To update, download a MIRIAD distribution and copy `$MIR/src/subs/*` and
Expand All @@ -66,3 +66,11 @@ To update, download a MIRIAD distribution and copy `$MIR/src/subs/*` and
Healpix source code (`aipy/healpix/cxx`) was included from Healpix 2.01. To
update, download a HEALPix distribution and copy `src/cxx` into
`aipy/healpix`.

## Making Releases (for Maintainers)

To make a release of `aipy` (both on Github and PyPI), head to the most current
[Draft Release](https://github.com/HERA-Team/aipy/releases) and note the *suggested*
release version. Contact the maintainers with your intention to make a release either
to that version (or, if appropriate, to a different version), and publish the release
via the Github UI. All done!
19 changes: 11 additions & 8 deletions aipy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,15 @@
import ephem

try:
from .__gitlog__ import __gitlog__
from .__branch__ import __branch__
from .__version__ import __version__
from importlib.metadata import PackageNotFoundError, version
except ImportError:
__gitlog__ = None
__branch__ = None
fh = open('VERSION', 'r')
__version__ = fh.read()
fh.close()
from importlib_metadata import PackageNotFoundError, version

try:
from ._version import version as __version__
except ModuleNotFoundError: # pragma: no cover
try:
__version__ = version("aipy")
except PackageNotFoundError:
# package is not installed
__version__ = "unknown"
4 changes: 2 additions & 2 deletions aipy/healpix.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ def __getitem__(self, crd):
px,wgts = self.crd2px(*crd, **{'interpolate':1})
return np.sum(self.map[px] * wgts, axis=-1)
else: px = self.crd2px(*crd)
else: px = mk_arr(crd, dtype=np.long)
else: px = mk_arr(crd, dtype=np.int64)
return self.map[px]
def __setitem__(self, crd, val):
"""Assign data to a sphere via hpm[crd] = val. Functionality slightly
Expand All @@ -245,7 +245,7 @@ def __setitem__(self, crd, val):
px = self.crd2px(*crd)
else:
if type(crd) is np.ndarray: assert(len(crd.shape) == 1)
px = mk_arr(crd, dtype=np.int)
px = mk_arr(crd, dtype=int)
if px.size == 1:
if type(val) is np.ndarray: val = mk_arr(val, dtype=self.map.dtype)
self.map[px] = val
Expand Down
16 changes: 0 additions & 16 deletions ci/test_environment.yml

This file was deleted.

7 changes: 6 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[build-system]
requires = ["setuptools>=42", "wheel", "oldest-supported-numpy"]
requires = ["setuptools>=42", "wheel", "numpy", "setuptools-scm[toml]>=6.2"]
build-backend = "setuptools.build_meta"

[tool.pytest.ini_options]
Expand All @@ -16,3 +16,8 @@ testpaths = [
"tests/scripting_test.py",
"tests/twodgauss_test.py",
]

[tool.setuptools_scm]
write_to = "aipy/_version.py"
parentdir_prefix_version = "aipy-"
fallback_version = "0.0.0"
5 changes: 0 additions & 5 deletions setup.cfg

This file was deleted.

Loading

0 comments on commit fbe195f

Please sign in to comment.