Skip to content

Commit

Permalink
update top-level files to latest package template
Browse files Browse the repository at this point in the history
  • Loading branch information
weaverba137 committed Mar 20, 2017
1 parent bd6277a commit 9f01aea
Show file tree
Hide file tree
Showing 10 changed files with 142 additions and 79 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -16,6 +16,7 @@ pydl/pydl.cfg
htmlcov
.coverage
MANIFEST
.ipynb_checkpoints

# Sphinx
docs/api
Expand Down
115 changes: 65 additions & 50 deletions .travis.yml
@@ -1,9 +1,10 @@
language: python
# We set the language to c because python isn't supported on the MacOS X nodes
# on Travis. However, the language ends up being irrelevant anyway, since we
# install Python ourselves using conda.
language: c

python:
- 2.7
- 3.4
- 3.5
os:
- linux

# Setting sudo to false opts in to Travis-CI container-based builds.
sudo: false
Expand All @@ -26,85 +27,99 @@ env:
# The following versions are the 'default' for tests, unless
# overridden underneath. They are defined here in order to save having
# to repeat them for all configurations.
- PYTHON_VERSION=3.6
- NUMPY_VERSION=stable
- ASTROPY_VERSION=stable
- MAIN_CMD='python setup.py'
- SETUP_CMD='test'
- PIP_DEPENDENCIES=''
- EVENT_TYPE='pull_request push'

# For this package-template, we include examples of Cython modules,
# so Cython is required for testing. If your package does not include
# Cython code, you can set CONDA_DEPENDENCIES=''
# - CONDA_DEPENDENCIES='Cython'
- CONDA_DEPENDENCIES='scipy matplotlib'

# Conda packages for affiliated packages are hosted in channel
# "astropy" while builds for astropy LTS with recent numpy versions
# are in astropy-ci-extras. If your package uses either of these,
# add the channels to CONDA_CHANNELS along with any other channels
# you want to use.
# - CONDA_CHANNELS='astopy-ci-extras astropy'
- CONDA_CHANNELS='astropy'
- CONDA_CHANNELS='astropy-ci-extras astropy'

# If there are matplotlib or other GUI tests, uncomment the following
# line to use the X virtual framebuffer.
# - SETUP_XVFB=True

matrix:
# Make sure that egg_info works without dependencies
- SETUP_CMD='egg_info'
# Try all python versions with the latest numpy
- SETUP_CMD='test'
- PYTHON_VERSION=2.7 SETUP_CMD='egg_info'
- PYTHON_VERSION=3.3 SETUP_CMD='egg_info'
- PYTHON_VERSION=3.4 SETUP_CMD='egg_info'
- PYTHON_VERSION=3.5 SETUP_CMD='egg_info'
- PYTHON_VERSION=3.6 SETUP_CMD='egg_info'

matrix:

# Don't wait for allowed failures
fast_finish: true

include:
# Try MacOS X
- os: osx
env: SETUP_CMD='test'

# Do a coverage test in Python 2.
- python: 2.7
# Do a coverage test.
- os: linux
env: SETUP_CMD='test --coverage'

# Check for sphinx doc build warnings - we do this first because it
# may run for a long time
- python: 2.7
env: SETUP_CMD='build_sphinx -w'

# Try Astropy development version
- python: 2.7
env: ASTROPY_VERSION=development
- python: 3.5
- os: linux
env: SETUP_CMD='build_docs -w'

# Now try Astropy dev and LTS vesions with the latest 3.x and 2.7.
- os: linux
env: PYTHON_VERSION=2.7 ASTROPY_VERSION=development
EVENT_TYPE='pull_request push cron'
- os: linux
env: ASTROPY_VERSION=development
- python: 2.7
env: ASTROPY_VERSION=lts NUMPY_VERSION=1.10
- python: 3.5
env: ASTROPY_VERSION=lts NUMPY_VERSION=1.10

# Python 3.3 doesn't have numpy 1.10 in conda, but can be put
# back into the main matrix once the numpy build is available in the
# astropy-ci-extras channel (or in the one provided in the
# CONDA_CHANNELS environmental variable).

- python: 3.3
env: SETUP_CMD='egg_info'
- python: 3.3
env: SETUP_CMD='test' NUMPY_VERSION=1.9 SCIPY_VERSION=0.14

# Try older numpy versions
- python: 2.7
env: NUMPY_VERSION=1.10 SCIPY_VERSION=0.16
- python: 2.7
env: NUMPY_VERSION=1.9 SCIPY_VERSION=0.14 CONDA_DEPENDENCIES='libgfortran=1.0 scipy matplotlib'
- python: 2.7
env: NUMPY_VERSION=1.8 SCIPY_VERSION=0.13
- python: 2.7
env: NUMPY_VERSION=1.7 SCIPY_VERSION=0.12
EVENT_TYPE='pull_request push cron'
- os: linux
env: PYTHON_VERSION=2.7 ASTROPY_VERSION=lts
- os: linux
env: ASTROPY_VERSION=lts

# Try all python versions and Numpy versions. Since we can assume that
# the Numpy developers have taken care of testing Numpy with different
# versions of Python, we can vary Python and Numpy versions at the same
# time.

- os: linux
env: PYTHON_VERSION=2.7 NUMPY_VERSION=1.7
- os: linux
env: PYTHON_VERSION=3.3 NUMPY_VERSION=1.8
- os: linux
env: PYTHON_VERSION=3.4 NUMPY_VERSION=1.9
- os: linux
env: PYTHON_VERSION=3.5 NUMPY_VERSION=1.10
- os: linux
env: NUMPY_VERSION=1.11

# Try numpy pre-release
- python: 3.5
env: NUMPY_VERSION=prerelease CONDA_DEPENDENCIES='nomkl scipy matplotlib'
- os: linux
env: NUMPY_VERSION=prerelease
EVENT_TYPE='pull_request push cron'

# Do a PEP8 test with pycodestyle
- os: linux
env: MAIN_CMD='pycodestyle packagename --count' SETUP_CMD=''

# PEP 8 Compliance
- python: 2.7
env: MAIN_CMD='pep8' SETUP_CMD='--count pydl'
allow_failures:
# Do a PEP8 test with pycodestyle
# (allow to fail unless your code completely compliant)
- os: linux
env: MAIN_CMD='pycodestyle packagename --count' SETUP_CMD=''

install:

Expand Down Expand Up @@ -138,4 +153,4 @@ after_success:
# If coveralls.io is set up for this package, uncomment the line
# below and replace "packagename" with the name of your package.
# The coveragerc file may be customized as needed for your package.
- if [[ $SETUP_CMD == 'test --coverage' ]]; then coveralls --rcfile='pydl/tests/coveragerc'; fi
- if [[ $SETUP_CMD == *coverage* ]]; then coveralls --rcfile='pydl/tests/coveragerc'; fi
4 changes: 2 additions & 2 deletions MANIFEST.in
@@ -1,11 +1,11 @@
include README.rst
# include CHANGES.rst

include ez_setup.py
include ah_bootstrap.py
include setup.cfg
include pytest.ini

recursive-include *.pyx *.c *.pxd
recursive-include pydl *.pyx *.c *.pxd
recursive-include docs *
recursive-include licenses *
recursive-include cextern *
Expand Down
1 change: 1 addition & 0 deletions docs/pydl/changes.rst
Expand Up @@ -5,6 +5,7 @@ PyDL Changelog
0.5.4 (unreleased)
------------------

* Update to `astropy_helpers`_/v1.3.1.
* Refactor HMF code into an object to contain the data and methods.
* Use functions from :mod:`astropy.utils.data` where possible.
* Fix an integer division error encountered when using Numpy 1.12
Expand Down
21 changes: 16 additions & 5 deletions ez_setup.py
Expand Up @@ -40,6 +40,8 @@
DEFAULT_URL = "https://pypi.io/packages/source/s/setuptools/"
DEFAULT_SAVE_DIR = os.curdir

MEANINGFUL_INVALID_ZIP_ERR_MSG = 'Maybe {0} is corrupted, delete it and try again.'


def _python_cmd(*args):
"""
Expand Down Expand Up @@ -104,8 +106,16 @@ def archive_context(filename):
old_wd = os.getcwd()
try:
os.chdir(tmpdir)
with ContextualZipFile(filename) as archive:
archive.extractall()
try:
with ContextualZipFile(filename) as archive:
archive.extractall()
except zipfile.BadZipfile as err:
if not err.args:
err.args = ('', )
err.args = err.args + (
MEANINGFUL_INVALID_ZIP_ERR_MSG.format(filename),
)
raise

# going in the directory
subdir = os.path.join(tmpdir, os.listdir(tmpdir)[0])
Expand All @@ -120,11 +130,12 @@ def archive_context(filename):

def _do_download(version, download_base, to_dir, download_delay):
"""Download Setuptools."""
egg = os.path.join(to_dir, 'setuptools-%s-py%d.%d.egg'
% (version, sys.version_info[0], sys.version_info[1]))
py_desig = 'py{sys.version_info[0]}.{sys.version_info[1]}'.format(sys=sys)
tp = 'setuptools-{version}-{py_desig}.egg'
egg = os.path.join(to_dir, tp.format(**locals()))
if not os.path.exists(egg):
archive = download_setuptools(version, download_base,
to_dir, download_delay)
to_dir, download_delay)
_build_egg(egg, archive, to_dir)
sys.path.insert(0, egg)

Expand Down
3 changes: 0 additions & 3 deletions pip-requirements

This file was deleted.

2 changes: 0 additions & 2 deletions pytest.ini

This file was deleted.

33 changes: 27 additions & 6 deletions setup.cfg
Expand Up @@ -3,6 +3,11 @@ source-dir = docs
build-dir = docs/_build
all_files = 1

[build_docs]
source-dir = docs
build-dir = docs/_build
all_files = 1

[upload_docs]
upload-dir = docs/_build/html
show-response = 1
Expand All @@ -12,23 +17,39 @@ minversion = 2.2
norecursedirs = build docs/_build
doctest_plus = enabled

[pep8]
ignore = E12,E133,E226,E501
# The default ignore set is E123,E133,E226,E241,E242

[ah_bootstrap]
auto_use = True

[pep8]
# E101 - mix of tabs and spaces
# W191 - use of tabs
# W291 - trailing whitespace
# W292 - no newline at end of file
# W293 - trailing whitespace
# W391 - blank line at end of file
# E111 - 4 spaces per indentation level
# E112 - 4 spaces per indentation level
# E113 - 4 spaces per indentation level
# E901 - SyntaxError or IndentationError
# E902 - IOError
# select = E101,W191,W291,W292,W293,W391,E111,E112,E113,E901,E902
# The default ignore set is E123,E133,E226,E241,E242
ignore = E12,E133,E226,E501
exclude = extern,sphinx,*parsetab.py

[metadata]
package_name = pydl
description = Astropy affiliated package
long_description = This description will be replaced with pydl.__doc__.
# long_description = This description will be obtained from pydl.__doc__.
author = Benjamin Alan Weaver
author_email = benjamin.weaver@nyu.edu
author_email = baweaver@lbl.gov
license = BSD
url = http://github.com/weaverba137/pydl
edit_on_github = False
github_project = weaverba137/pydl
install_requires = astropy
# version should be PEP440 compatible (http://www.python.org/dev/peps/pep-0440)
version = 0.5.4.dev

[entry_points]
get_juldate = pydl.goddard.astro:get_juldate_main
Expand Down
39 changes: 29 additions & 10 deletions setup.py
Expand Up @@ -8,7 +8,7 @@
import ah_bootstrap
from setuptools import setup

#A dirty hack to get around some early import/configurations ambiguities
# A dirty hack to get around some early import/configurations ambiguities
if sys.version_info[0] >= 3:
import builtins
else:
Expand Down Expand Up @@ -37,17 +37,36 @@
LICENSE = metadata.get('license', 'unknown')
URL = metadata.get('url', 'http://astropy.org')

# Get the long description from the package's docstring
__import__(PACKAGENAME)
package = sys.modules[PACKAGENAME]
LONG_DESCRIPTION = package.__doc__
# order of priority for long_description:
# (1) set in setup.cfg,
# (2) load LONG_DESCRIPTION.rst,
# (3) load README.rst,
# (4) package docstring
readme_glob = 'NOSUCHFILE*'
_cfg_long_description = metadata.get('long_description', '')
if _cfg_long_description:
LONG_DESCRIPTION = _cfg_long_description

elif os.path.exists('LONG_DESCRIPTION.rst'):
with open('LONG_DESCRIPTION.rst') as f:
LONG_DESCRIPTION = f.read()

elif len(glob.glob(readme_glob)) > 0:
with open(glob.glob(readme_glob)[0]) as f:
LONG_DESCRIPTION = f.read()

else:
# Get the long description from the package's docstring
__import__(PACKAGENAME)
package = sys.modules[PACKAGENAME]
LONG_DESCRIPTION = package.__doc__

# Store the package name in a built-in variable so it's easy
# to get from other parts of the setup infrastructure
builtins._ASTROPY_PACKAGE_NAME_ = PACKAGENAME

# VERSION should be PEP386 compatible (http://www.python.org/dev/peps/pep-0386)
VERSION = '0.5.4.dev'
# VERSION should be PEP440 compatible (http://www.python.org/dev/peps/pep-0440)
VERSION = metadata.get('version', '0.0.dev')

# Indicates if this version is a release version
RELEASE = 'dev' not in VERSION
Expand All @@ -64,9 +83,9 @@
generate_version_py(PACKAGENAME, VERSION, RELEASE,
get_debug_option(PACKAGENAME))

# Treat everything in scripts except README.rst as a script to be installed
# Treat everything in scripts except README* as a script to be installed
scripts = [fname for fname in glob.glob(os.path.join('scripts', '*'))
if os.path.basename(fname) != 'README.rst']
if not os.path.basename(fname).startswith('README')]


# Get configuration information from all of the various subpackages.
Expand Down Expand Up @@ -106,7 +125,7 @@
version=VERSION,
description=DESCRIPTION,
scripts=scripts,
install_requires=['astropy'],
install_requires=metadata.get('install_requires', 'astropy').strip().split(),
author=AUTHOR,
author_email=AUTHOR_EMAIL,
license=LICENSE,
Expand Down

0 comments on commit 9f01aea

Please sign in to comment.