-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'stage-0.1' into release
- Loading branch information
Showing
30 changed files
with
2,435 additions
and
217 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# Codecov configuration to make it a bit less noisy | ||
coverage: | ||
status: | ||
patch: false | ||
project: | ||
default: | ||
threshold: 50% | ||
comment: | ||
layout: "header" | ||
require_changes: false | ||
branches: null | ||
behavior: default | ||
flags: null | ||
paths: null |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
name: CI | ||
on: [push, pull_request] | ||
|
||
env: | ||
HSD_PYTHON_VERSION: '0.1' | ||
|
||
jobs: | ||
test: | ||
|
||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
|
||
- uses: actions/setup-python@v1 | ||
with: | ||
python-version: '3.x' | ||
|
||
- name: Install requirements (PIP) | ||
run: pip3 install pytest sphinx numpy build | ||
|
||
- name: Setup up root directory | ||
run: echo "PACKAGE_ROOT=${PWD}/src" >> $GITHUB_ENV | ||
|
||
- name: Build and install package | ||
run: | | ||
python -m build | ||
pip install dist/hsd_python*.whl | ||
python -c "import hsd; assert hsd.__version__ == '${HSD_PYTHON_VERSION}'" | ||
- name: Run test pytest | ||
run: python3 -m pytest | ||
|
||
- name: Run doctest | ||
run: cd docs; make doctest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# Configure LGTM for this package | ||
|
||
extraction: | ||
python: # Configure Python | ||
python_setup: # Configure the setup | ||
version: 3 # Specify Version 3 | ||
path_classifiers: | ||
library: | ||
- src/versioneer.py # Set Versioneer.py to an external "library" (3rd party code) | ||
- devtools/* | ||
generated: | ||
- src/hsd/_version.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
language: python | ||
|
||
# Run jobs on container-based infrastructure, can be overridden per job | ||
|
||
matrix: | ||
include: | ||
# Extra includes for OSX since python language is not available by default on OSX | ||
- os: osx | ||
language: generic | ||
env: PYTHON_VER=3.6 | ||
- os: osx | ||
language: generic | ||
env: PYTHON_VER=3.7 | ||
|
||
|
||
# Pip can use Travis build-in Python | ||
- os: linux | ||
python: 3.6 | ||
- os: linux | ||
dist: xenial # Travis Trusty image does not have Python 3.7, Xenial does | ||
python: 3.7 | ||
|
||
|
||
before_install: | ||
# Additional info about the build | ||
- uname -a | ||
- df -h | ||
- ulimit -a | ||
|
||
# Install the Python environment | ||
- source devtools/travis-ci/before_install.sh | ||
- python -V | ||
|
||
install: | ||
|
||
# Install the package locally | ||
- pip install -U pytest pytest-cov codecov | ||
- pip install -e src/ | ||
|
||
|
||
script: | ||
- pytest -v --cov=hsd test/ | ||
|
||
notifications: | ||
email: false | ||
|
||
after_success: | ||
- codecov |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
========== | ||
Change Log | ||
========== | ||
|
||
|
||
0.1 | ||
=== | ||
|
||
Added | ||
----- | ||
|
||
* Basic functionality to manipulate HSD-data in Python. | ||
|
||
* Pip installation |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
#!/usr/bin/env python3 | ||
|
||
"""Sets a version number in all relevant project files""" | ||
|
||
import sys | ||
import re | ||
import os | ||
|
||
# The pattern the version number must satisfy | ||
VERSION_PATTERN = r'\d+\.\d+(?:\.\d+)?(?:-\w+)?' | ||
|
||
# List of (file name, search pattern, replacement pattern) tuples for all | ||
# the occurancies to be replaced. | ||
FILES_PATTERNS = [('src/hsd/__init__.py', | ||
r'^__version__\s*=\s*([\'"]){}\1'.format(VERSION_PATTERN), | ||
"__version__ = '{version}'"), | ||
('docs/introduction.rst', | ||
r'hsd-python version[ ]*{}.'.format(VERSION_PATTERN), | ||
'hsd-python version {shortversion}.'), | ||
('setup.cfg', | ||
r'version\s*=\s*{}'.format(VERSION_PATTERN), | ||
"version = {version}"), | ||
('docs/conf.py', | ||
r'release\s*=\s*([\'"]){}\1'.format(VERSION_PATTERN), | ||
"release = '{version}'"), | ||
('.github/workflows/ci.yml', | ||
r'HSD_PYTHON_VERSION:\s*([\'"]){}\1'.format(VERSION_PATTERN), | ||
"HSD_PYTHON_VERSION: '{version}'"), | ||
] | ||
|
||
|
||
def main(): | ||
"""Main script.""" | ||
|
||
if len(sys.argv) < 2: | ||
sys.stderr.write("Missing version string\n") | ||
sys.exit(1) | ||
|
||
version, shortversion = _get_version_strings(sys.argv[1]) | ||
rootdir = os.path.join(os.path.dirname(sys.argv[0]), '..') | ||
_replace_version_in_files(FILES_PATTERNS, rootdir, version, shortversion) | ||
_replace_version_in_changelog(rootdir, version) | ||
|
||
|
||
def _get_version_strings(version): | ||
"""Returns version and the short version as string""" | ||
|
||
match = re.match(VERSION_PATTERN, version) | ||
if match is None: | ||
print("Invalid version string") | ||
sys.exit(1) | ||
|
||
shortversion = '.'.join(version.split('.')[0:2]) | ||
return version, shortversion | ||
|
||
|
||
def _replace_version_in_files(files_patterns, rootdir, version, shortversion): | ||
"""Replaces version number in given files with given search/replacement patterns""" | ||
|
||
for fname, regexp, repl in files_patterns: | ||
fname = os.path.join(rootdir, fname) | ||
print("Replacments in '{}': ".format(os.path.relpath(fname, rootdir)), end='') | ||
fp = open(fname, 'r') | ||
txt = fp.read() | ||
fp.close() | ||
replacement = repl.format(version=version, shortversion=shortversion) | ||
newtxt, nsub = re.subn(regexp, replacement, txt, flags=re.MULTILINE) | ||
print(nsub) | ||
fp = open(fname, 'w') | ||
fp.write(newtxt) | ||
fp.close() | ||
|
||
|
||
def _replace_version_in_changelog(rootdir, version): | ||
"""Replaces the unreleased section in CHANGELOG.rst""" | ||
|
||
fname = os.path.join(rootdir, 'CHANGELOG.rst') | ||
print("Replacments in '{}': ".format(os.path.relpath(fname, rootdir)), end='') | ||
fp = open(fname, 'r') | ||
txt = fp.read() | ||
fp.close() | ||
decoration = '=' * len(version) | ||
newtxt, nsub = re.subn( | ||
r'^Unreleased\s*\n=+', version + r'\n' + decoration, txt, | ||
count=1, flags=re.MULTILINE) | ||
print(nsub) | ||
fp = open(fname, 'w') | ||
fp.write(newtxt) | ||
fp.close() | ||
|
||
|
||
if __name__ == '__main__': | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Temporarily change directory to $HOME to install software | ||
pushd . | ||
cd $HOME | ||
# Make sure some level of pip is installed | ||
python -m ensurepip | ||
|
||
if [ "$TRAVIS_OS_NAME" == "osx" ]; then | ||
HOMEBREW_NO_AUTO_UPDATE=1 brew upgrade pyenv | ||
# Pyenv requires minor revision, get the latest | ||
PYENV_VERSION=$(pyenv install --list |grep $PYTHON_VER | sed -n "s/^[ \t]*\(${PYTHON_VER}\.*[0-9]*\).*/\1/p" | tail -n 1) | ||
# Install version | ||
pyenv install $PYENV_VERSION | ||
# Use version for this | ||
pyenv global $PYENV_VERSION | ||
# Setup up path shims | ||
eval "$(pyenv init -)" | ||
fi | ||
pip install --upgrade pip setuptools | ||
|
||
# Restore original directory | ||
popd |
Oops, something went wrong.