Skip to content

Commit

Permalink
Add installation with setup.py
Browse files Browse the repository at this point in the history
  • Loading branch information
awvwgk committed Feb 8, 2020
1 parent c9b8553 commit f2cabe3
Show file tree
Hide file tree
Showing 11 changed files with 2,018 additions and 3 deletions.
14 changes: 14 additions & 0 deletions .codecov.yml
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
12 changes: 12 additions & 0 deletions .lgtm.yml
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
48 changes: 48 additions & 0 deletions .travis.yml
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
21 changes: 21 additions & 0 deletions devtools/travis-ci/before_install.sh
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
1 change: 1 addition & 0 deletions src/LICENSE
6 changes: 6 additions & 0 deletions src/MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
include LICENSE
include MANIFEST.in
include versioneer.py

graft hsd
global-exclude *.py[cod] __pycache__ *.so
30 changes: 30 additions & 0 deletions src/setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Helper file to handle all configs

[coverage:run]
# .coveragerc to control coverage.py and pytest-cov
omit =
# Omit the tests
*/tests/*
# Omit generated versioneer
hsd/_version.py

[yapf]
# YAPF, in .style.yapf files this shows up as "[style]" header
COLUMN_LIMIT = 119
INDENT_WIDTH = 4
USE_TABS = False

[flake8]
# Flake8, PyFlakes, etc
max-line-length = 119

[versioneer]
# Automatic version numbering scheme
VCS = git
style = pep440
versionfile_source = hsd/_version.py
versionfile_build = hsd/_version.py
tag_prefix = ''

[aliases]
test = pytest
59 changes: 59 additions & 0 deletions src/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
"""
hsd
Python routines to manipulate HSD data
"""
import sys
from setuptools import setup, find_packages
import versioneer

short_description = __doc__.split("\n")

# from https://github.com/pytest-dev/pytest-runner#conditional-requirement
needs_pytest = {'pytest', 'test', 'ptr'}.intersection(sys.argv)
pytest_runner = ['pytest-runner'] if needs_pytest else []

try:
with open("README.rst", "r") as handle:
long_description = handle.read()
except:
long_description = "\n".join(short_description[2:])


setup(
# Self-descriptive entries which should always be present
name='hsd',
author='DFTB+ developers group',
author_email='[email protected]',
description=short_description[0],
long_description=long_description,
long_description_content_type="text/x-rst",
version=versioneer.get_version(),
cmdclass=versioneer.get_cmdclass(),
license='BSD 2-clause license',

# Which Python importable modules should be included when your package is installed
# Handled automatically by setuptools. Use 'exclude' to prevent some specific
# subpackage(s) from being added, if needed
packages=find_packages(),

# Optional include package data to ship with your package
# Customize MANIFEST.in if the general case does not suit your needs
# Comment out this line to prevent the files from being packaged with your software
include_package_data=True,

# Allows `setup.py test` to work correctly with pytest
setup_requires=[] + pytest_runner,

# Additional entries you may want simply uncomment the lines you want and fill in the data
# url='http://www.my_package.com', # Website
install_requires=['numpy'], # Required packages, pulls from pip if needed; do not use for Conda deployment
# platforms=['Linux',
# 'Mac OS-X',
# 'Unix',
# 'Windows'], # Valid platforms your code works on, adjust to your flavor
# python_requires=">=3.5", # Python version restrictions

# Manual control if final package is compressible or not, set False to prevent the .egg from being made
# zip_safe=False,

)
Loading

0 comments on commit f2cabe3

Please sign in to comment.