Skip to content

Commit

Permalink
setuptools_scm automated versioning
Browse files Browse the repository at this point in the history
  • Loading branch information
MuellerSeb committed Mar 22, 2020
1 parent 19425e3 commit d3a2c7f
Show file tree
Hide file tree
Showing 9 changed files with 120 additions and 90 deletions.
105 changes: 72 additions & 33 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,43 +1,82 @@
language: python
python: 3.8

matrix:
include:
# separate sdist and coverage with py36 on linux
- name: "sdist and coverage"
sudo: required
language: python
python: 3.6
services: docker
script:
- python -m pip install -U setuptools pytest-cov coveralls
- python setup.py sdist -d dist
- python -m pip install -r requirements.txt
- python -m pytest --cov ogs5py --cov-report term-missing -v tests/
- python -m coveralls
# universal wheel on 64bit Linux with py36
- name: "py2.py3 wheel"
sudo: required
language: python
python: 3.6
services: docker
env: CIBW_BUILD="cp36-*64"
# setuptools-scm needs all tags in order to obtain a proper version
git:
depth: false

env:
global:
# Note: TWINE_PASSWORD is set in Travis settings
- TWINE_USERNAME=geostatframework
- CIBW_BEFORE_BUILD="pip install setuptools"

script:
# create wheels
- python -m pip install cibuildwheel==1.0.0
- python -m cibuildwheel --output-dir dist

after_success:
- python -m pip install twine
- python -m twine upload --verbose --skip-existing --repository-url https://test.pypi.org/legacy/ dist/*
- if [[ $TRAVIS_TAG ]]; then python -m twine upload --verbose --skip-existing dist/*; fi
# skip py27 (EOL)
- CIBW_SKIP="cp27-*"
# update setuptools to latest version
- CIBW_BEFORE_BUILD="pip install -U setuptools"
# testing with cibuildwheel
- CIBW_TEST_REQUIRES=pytest
- CIBW_TEST_COMMAND="pytest -v {project}/tests"

notifications:
email:
recipients:
- info@geostat-framework.org
- info@geostat-framework.org

before_install:
- |
if [[ "$TRAVIS_OS_NAME" = windows ]]; then
choco install python --version 3.8.0
export PATH="/c/Python38:/c/Python38/Scripts:$PATH"
# make sure it's on PATH as 'python3'
ln -s /c/Python38/python.exe /c/Python38/python3.exe
fi
install:
- python3 -m pip install cibuildwheel==1.1.0

script:
- python3 -m cibuildwheel --output-dir tmp_dist

stages:
- test
- coverage
- name: deploy
if: (NOT type IN (pull_request)) AND (repo = GeoStat-Framework/ogs5py)

jobs:
include:
- stage: test
name: Test on Linux
services: docker
- stage: test
name: Test on MacOS
os: osx
language: generic
- stage: test
name: Test on Windows
os: windows
language: shell

- stage: coverage
name: Coverage on Linux
services: docker
install: python3 -m pip install .[test] coveralls
script:
- python3 -m pytest --cov ogs5py --cov-report term-missing -v tests/
- python3 -m coveralls

# Test Deploy source distribution
- stage: deploy
name: Test Deploy
install: python3 -m pip install -U setuptools wheel twine
script: python3 setup.py sdist --formats=gztar bdist_wheel
after_success:
- python3 -m twine upload --verbose --skip-existing --repository-url https://test.pypi.org/legacy/ dist/*

# Deploy source distribution
- stage: deploy
name: Deploy to PyPI
if: tag IS present
install: python3 -m pip install -U setuptools wheel twine
script: python3 setup.py sdist --formats=gztar bdist_wheel
after_success: python3 -m twine upload --verbose --skip-existing dist/*
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.2546767.svg)](https://doi.org/10.5281/zenodo.2546767)
[![PyPI version](https://badge.fury.io/py/ogs5py.svg)](https://badge.fury.io/py/ogs5py)
[![Build Status](https://travis-ci.org/GeoStat-Framework/ogs5py.svg?branch=master)](https://travis-ci.org/GeoStat-Framework/ogs5py)
[![Build Status](https://travis-ci.com/GeoStat-Framework/ogs5py.svg?branch=master)](https://travis-ci.org/GeoStat-Framework/ogs5py)
[![Coverage Status](https://coveralls.io/repos/github/GeoStat-Framework/ogs5py/badge.svg?branch=master)](https://coveralls.io/github/GeoStat-Framework/ogs5py?branch=master)
[![Documentation Status](https://readthedocs.org/projects/ogs5py/badge/?version=latest)](https://geostat-framework.readthedocs.io/projects/ogs5py/en/latest/?badge=latest)
[![Documentation Status](https://readthedocs.org/projects/ogs5py/badge/?version=stable)](https://geostat-framework.readthedocs.io/projects/ogs5py/en/stable/?badge=stable)
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/ambv/black)

<p align="center">
Expand Down Expand Up @@ -149,7 +149,6 @@ model.run_model(ogs_exe="path/to/ogs")

- [NumPy >= 1.13.0](https://www.numpy.org)
- [Pandas >= 0.23.0](https://pandas.pydata.org/)
- [whichcraft](https://github.com/pydanny/whichcraft)
- [meshio](https://github.com/nschloe/meshio)
- [lxml](https://github.com/lxml/lxml)
- [vtk](https://vtk.org/)
Expand All @@ -162,7 +161,7 @@ You can contact us via <info@geostat-framework.org>.

## License

[MIT][gpl_link] © 2018-2019 (inspired by Falk Hesse and Miao Jing)
[MIT][gpl_link] © 2018-2020 (inspired by Falk Hesse and Miao Jing)

This project is based on [OGSPY][ogspy_link].

Expand Down
7 changes: 3 additions & 4 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# required for readthedocs.org
numpydoc
# https://stackoverflow.com/a/11704396/6696397
-r ../requirements.txt
-r requirements_doc.txt
-r ../requirements_setup.txt
-r ../requirements.txt
1 change: 1 addition & 0 deletions docs/requirements_doc.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
numpydoc
3 changes: 1 addition & 2 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,6 @@ Requirements

- `NumPy >= 1.13.0 <https://www.numpy.org>`_
- `Pandas >= 0.23.0 <https://pandas.pydata.org/>`_
- `whichcraft <https://github.com/pydanny/whichcraft>`_
- `meshio <https://github.com/nschloe/meshio>`_
- `lxml <https://github.com/lxml/lxml>`_
- `vtk <https://vtk.org/>`_
Expand All @@ -155,4 +154,4 @@ Requirements
License
=======

`MIT <https://github.com/GeoStat-Framework/ogs5py/blob/master/LICENSE>`_ © 2019
`MIT <https://github.com/GeoStat-Framework/ogs5py/blob/master/LICENSE>`_
13 changes: 6 additions & 7 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
numpy>=1.13
pandas>=0.23.0
whichcraft
meshio
lxml
vtk
pexpect
numpy>=1.14.5
pandas>=0.23.2
meshio>=4.0.3, <5.0
lxml~=4.0
pexpect~=4.0
vtk>=8.1
2 changes: 2 additions & 0 deletions requirements_setup.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
setuptools>=41.0.1
setuptools_scm>=3.5.0
2 changes: 2 additions & 0 deletions requirements_test.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
pytest-cov>=2.8.0
pytest>=5.3.0
70 changes: 30 additions & 40 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,39 +2,27 @@
"""ogs5py: a python API for OpenGeoSys5"""

import os
import codecs
import re

from setuptools import setup, find_packages


# find __version__ ############################################################


def read(*parts):
"""Read file data."""
here = os.path.abspath(os.path.dirname(__file__))
with codecs.open(os.path.join(here, *parts), "r") as fp:
return fp.read()


def find_version(*file_paths):
"""Find version without importing module."""
version_file = read(*file_paths)
version_match = re.search(
r"^__version__ = ['\"]([^'\"]*)['\"]", version_file, re.M
)
if version_match:
return version_match.group(1)
raise RuntimeError("Unable to find version string.")

HERE = os.path.abspath(os.path.dirname(__file__))

###############################################################################
with open(os.path.join(HERE, "README.md"), encoding="utf-8") as f:
README = f.read()
with open(os.path.join(HERE, "requirements.txt"), encoding="utf-8") as f:
REQ = f.read().splitlines()
with open(os.path.join(HERE, "requirements_setup.txt"), encoding="utf-8") as f:
REQ_SETUP = f.read().splitlines()
with open(os.path.join(HERE, "requirements_test.txt"), encoding="utf-8") as f:
REQ_TEST = f.read().splitlines()
with open(
os.path.join(HERE, "docs", "requirements_doc.txt"), encoding="utf-8"
) as f:
REQ_DOC = f.read().splitlines()

REQ_DEV = REQ_SETUP + REQ_TEST + REQ_DOC

VERSION = find_version("ogs5py", "_version.py")
DOCLINE = __doc__.split("\n")[0]
README = open("README.md").read()
CLASSIFIERS = [
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Developers",
Expand All @@ -49,42 +37,44 @@ def find_version(*file_paths):
"Operating System :: POSIX",
"Operating System :: Unix",
"Programming Language :: Python",
"Programming Language :: Python :: 2",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3 :: Only",
"Topic :: Scientific/Engineering",
"Topic :: Software Development",
"Topic :: Utilities",
]

setup(
name="ogs5py",
version=VERSION,
maintainer="Sebastian Mueller",
maintainer_email="sebastian.mueller@ufz.de",
description=DOCLINE,
long_description=README,
long_description_content_type="text/markdown",
maintainer="Sebastian Mueller",
maintainer_email="sebastian.mueller@ufz.de",
author="Sebastian Mueller, Falk Hesse",
author_email="info@geostat-framework.org",
url="https://github.com/GeoStat-Framework/ogs5py",
license="MIT",
classifiers=CLASSIFIERS,
platforms=["Windows", "Linux", "Solaris", "Mac OS-X", "Unix"],
include_package_data=True,
install_requires=[
"numpy>=1.13.0",
"pandas>=0.23.0", # read-routines and formatting
"whichcraft", # search for ogs
"meshio", # import/export external meshes
"lxml", # meshio vtu support
"vtk", # for the readers
"pexpect", # handle command calls
],
python_requires=">=3.5",
use_scm_version={
"relative_to": __file__,
"write_to": "ogs5py/_version.py",
"write_to_template": "__version__ = '{version}'",
"local_scheme": "no-local-version",
"fallback_version": "0.0.0.dev0",
},
install_requires=REQ,
setup_requires=REQ_SETUP,
extras_require={
# "reader": ["vtk"], # optional for reading output
"gmsh": ["pygmsh"], # optional for creating gmesh based meshes
"show": ["mayavi"], # optional to view a mesh
"all": ["pygmsh", "mayavi"], # everything
"doc": REQ_DOC,
"test": REQ_TEST,
"dev": REQ_DEV,
},
packages=find_packages(exclude=["tests*", "docs*"]),
)

0 comments on commit d3a2c7f

Please sign in to comment.