Skip to content

Commit

Permalink
Merge pull request #13 from boutproject/automatic_release
Browse files Browse the repository at this point in the history
Added automatic release
  • Loading branch information
johnomotani authored Jan 3, 2021
2 parents 545e46b + b9045e4 commit f0ada15
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 14 deletions.
27 changes: 27 additions & 0 deletions .github/workflows/python_publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Upload Python Package

on:
# Only run when a release is created
release:
types: [created]

jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Set up Python
uses: actions/setup-python@v1
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel twine
- name: Build and publish
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
python setup.py sdist bdist_wheel
twine upload dist/*
20 changes: 19 additions & 1 deletion boututils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,23 @@
do_import.append('View3D')
__all__ = do_import

__version__ = '0.1.4'
__name__ = 'boututils'

try:
from importlib.metadata import version, PackageNotFoundError
except ModuleNotFoundError:
from importlib_metadata import version, PackageNotFoundError
try:
__version__ = version(__name__)
except PackageNotFoundError:
try:
from setuptools_scm import get_version
except ModuleNotFoundError as e:
error_info = (
"'setuptools_scm' is required to get the version number when running "
"boututils from the git repo. Please install 'setuptools_scm'."
)
print(error_info)
raise ModuleNotFoundError(str(e) + ". " + error_info)
else:
__version__ = get_version(root="..", relative_to=__file__)
2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[tool.setuptools_scm]
write_to = "boututils/_version.py"
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ future==0.18.2
PyQt5==5.12.2 [mayavi]
mayavi==4.6.2 [mayavi]
netCDF4==1.5.3
setuptools_scm==5.0.1
19 changes: 6 additions & 13 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,11 @@
init_path = root_path.joinpath(name, '__init__.py')
readme_path = root_path.joinpath('README.md')

# https://packaging.python.org/guides/single-sourcing-package-version/
with init_path.open('r') as f:
version_file = f.read()
version_match = re.search(r"^__version__ = ['\"]([^'\"]*)['\"]",
version_file, re.M)
if version_match:
version = version_match.group(1)
else:
raise RuntimeError('Unable to find version string.')

with readme_path.open('r') as f:
long_description = f.read()

setuptools.setup(
name=name,
version=version,
author='Ben Dudson et al.',
description='Python package containing BOUT++ utils',
long_description=long_description,
Expand All @@ -44,13 +33,17 @@
'data-extraction',
'data-analysis',
'data-visualization'],
use_scm_version=True,
setup_requires=['setuptools>=42',
'setuptools_scm[toml]>=3.4',
'setuptools_scm_git_archive'],
install_requires=['numpy',
'matplotlib',
'scipy',
'h5py',
'boututils',
'future',
'netCDF4'],
'netCDF4'
"importlib-metadata ; python_version<'3.8'"],
extras_require={
'mayavi': ['mayavi', 'PyQt5']},
classifiers=[
Expand Down

0 comments on commit f0ada15

Please sign in to comment.