Skip to content

Commit

Permalink
Merge pull request #6 from mwcraig/add-package-template-stuff
Browse files Browse the repository at this point in the history
Add package template stuff
  • Loading branch information
pllim committed Jul 31, 2018
2 parents 883688d + 4c1066a commit 847af4b
Show file tree
Hide file tree
Showing 33 changed files with 1,358 additions and 0 deletions.
12 changes: 12 additions & 0 deletions .rtd-environment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: astrowidgets

channels:
- astropy

dependencies:
- astropy
- Cython
- matplotlib
- numpy
# - pip:
# - dependency_from_pip
146 changes: 146 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
# 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

os:
- linux

# Setting sudo to false opts in to Travis-CI container-based builds.
sudo: false

# The apt packages below are needed for sphinx builds. A full list of packages
# that can be included can be found here:
#
# https://github.com/travis-ci/apt-package-whitelist/blob/master/ubuntu-precise

addons:
apt:
packages:
- graphviz
- texlive-latex-extra
- dvipng

env:
global:

# 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'


# List other runtime dependencies for the package that are available as
# conda packages here.
- CONDA_DEPENDENCIES=''

# List other runtime dependencies for the package that are available as
# pip packages here.
# - PIP_DEPENDENCIES=''

# 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='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
- 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.
- 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
- os: linux
env: SETUP_CMD='build_docs -w'

# Now try Astropy dev with the latest Python and LTS with Python 2.7 and 3.x.
- os: linux
env: ASTROPY_VERSION=development
EVENT_TYPE='pull_request push cron'
- 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=3.5 NUMPY_VERSION=1.13
- os: linux
env: NUMPY_VERSION=1.14

# Try numpy pre-release
- os: linux
env: NUMPY_VERSION=prerelease
EVENT_TYPE='pull_request push cron'

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

allow_failures:
# Do a PEP8 test with pycodestyle
# (allow to fail unless your code completely compliant)
- os: linux
env: MAIN_CMD='pycodestyle astrowidgets --count' SETUP_CMD=''

install:

# We now use the ci-helpers package to set up our testing environment.
# This is done by using Miniconda and then using conda and pip to install
# dependencies. Which dependencies are installed using conda and pip is
# determined by the CONDA_DEPENDENCIES and PIP_DEPENDENCIES variables,
# which should be space-delimited lists of package names. See the README
# in https://github.com/astropy/ci-helpers for information about the full
# list of environment variables that can be used to customize your
# environment. In some cases, ci-helpers may not offer enough flexibility
# in how to install a package, in which case you can have additional
# commands in the install: section below.

- git clone --depth 1 git://github.com/astropy/ci-helpers.git
- source ci-helpers/travis/setup_conda.sh

# As described above, using ci-helpers, you should be able to set up an
# environment with dependencies installed using conda and pip, but in some
# cases this may not provide enough flexibility in how to install a
# specific dependency (and it will not be able to install non-Python
# dependencies). Therefore, you can also include commands below (as
# well as at the start of the install section or in the before_install
# section if they are needed before setting up conda) to install any
# other dependencies.

script:
- $MAIN_CMD $SETUP_CMD

after_success:
# If coveralls.io is set up for this package, uncomment the line below.
# The coveragerc file may be customized as needed for your package.
# - if [[ $SETUP_CMD == *coverage* ]]; then coveralls --rcfile='astrowidgets/tests/coveragerc'; fi
39 changes: 39 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
include README.rst
include CHANGES.rst

include ah_bootstrap.py
include setup.cfg
include astrowidgets/tests/coveragerc

recursive-include astrowidgets *.pyx *.c *.pxd
recursive-include docs *
recursive-include licenses *
recursive-include cextern *
recursive-include scripts *

prune build
prune docs/_build
prune docs/api


# the next few stanzas are for astropy_helpers. It's derived from the
# astropy_helpers/MANIFEST.in, but requires additional includes for the actual
# package directory and egg-info.

include astropy_helpers/README.rst
include astropy_helpers/CHANGES.rst
include astropy_helpers/LICENSE.rst
recursive-include astropy_helpers/licenses *

include astropy_helpers/ah_bootstrap.py

recursive-include astropy_helpers/astropy_helpers *.py *.pyx *.c *.h *.rst
recursive-include astropy_helpers/astropy_helpers.egg-info *
# include the sphinx stuff with "*" because there are css/html/rst/etc.
recursive-include astropy_helpers/astropy_helpers/sphinx *

prune astropy_helpers/build
prune astropy_helpers/astropy_helpers/tests


global-exclude *.pyc *.o
18 changes: 18 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
Widgets for the Jupyter notebook and JupyterLab
-----------------------------------------------

.. image:: http://img.shields.io/badge/powered%20by-AstroPy-orange.svg?style=flat
:target: http://www.astropy.org
:alt: Powered by Astropy Badge




License
-------

This project is Copyright (c) Astropy Developers and licensed under
the terms of the BSD 3-Clause license. This package is based upon
the `Astropy package template <https://github.com/astropy/package-template>`_
which is licensed under the BSD 3-clause licence. See the licenses folder for
more information.
49 changes: 49 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# AppVeyor.com is a Continuous Integration service to build and run tests under
# Windows

environment:

global:
PYTHON: "C:\\conda"
MINICONDA_VERSION: "latest"
CMD_IN_ENV: "cmd /E:ON /V:ON /C .\\ci-helpers\\appveyor\\windows_sdk.cmd"
PYTHON_ARCH: "64" # needs to be set for CMD_IN_ENV to succeed. If a mix
# of 32 bit and 64 bit builds are needed, move this
# to the matrix section.


# List other runtime dependencies for the package that are available as
# conda packages here.
CONDA_DEPENDENCIES: ""


# 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: "astropy-ci-extras astropy"

matrix:

# We test Python 2.7 and 3.6 because 2.7 is the supported Python 2
# release of Astropy and Python 3.6 is the latest Python 3 release.

- PYTHON_VERSION: "3.6"
ASTROPY_VERSION: "stable"
NUMPY_VERSION: "stable"

platform:
-x64

install:
- "git clone --depth 1 git://github.com/astropy/ci-helpers.git"
- "powershell ci-helpers/appveyor/install-miniconda.ps1"
- "SET PATH=%PYTHON%;%PYTHON%\\Scripts;%PATH%"
- "activate test"

# Not a .NET project, we build the package in the install step instead
build: false

test_script:
- "%CMD_IN_ENV% python setup.py test"
23 changes: 23 additions & 0 deletions astrowidgets/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Licensed under a 3-clause BSD style license - see LICENSE.rst

# Packages may add whatever they like to this file, but
# should keep this content at the top.
# ----------------------------------------------------------------------------
from ._astropy_init import *
# ----------------------------------------------------------------------------

# Enforce Python version check during package import.
# This is the same check as the one at the top of setup.py
import sys

__minimum_python_version__ = "3.5"

class UnsupportedPythonError(Exception):
pass

if sys.version_info < tuple((int(val) for val in __minimum_python_version__.split('.'))):
raise UnsupportedPythonError("astrowidgets does not support Python < {}".format(__minimum_python_version__))

if not _ASTROPY_SETUP_:
# For egg_info test builds to pass, put package imports here.
from .core import *
59 changes: 59 additions & 0 deletions astrowidgets/_astropy_init.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# Licensed under a 3-clause BSD style license - see LICENSE.rst

__all__ = ['__version__', '__githash__']

# this indicates whether or not we are in the package's setup.py
try:
_ASTROPY_SETUP_
except NameError:
from sys import version_info
if version_info[0] >= 3:
import builtins
else:
import __builtin__ as builtins
builtins._ASTROPY_SETUP_ = False

try:
from .version import version as __version__
except ImportError:
__version__ = ''
try:
from .version import githash as __githash__
except ImportError:
__githash__ = ''


if not _ASTROPY_SETUP_: # noqa
import os
from warnings import warn
from astropy.config.configuration import (
update_default_config,
ConfigurationDefaultMissingError,
ConfigurationDefaultMissingWarning)

# Create the test function for self test
from astropy.tests.runner import TestRunner
test = TestRunner.make_test_runner_in(os.path.dirname(__file__))
__all__ += ['test']

# add these here so we only need to cleanup the namespace at the end
config_dir = None

if not os.environ.get('ASTROPY_SKIP_CONFIG_UPDATE', False):
config_dir = os.path.dirname(__file__)
config_template = os.path.join(config_dir, __package__ + ".cfg")
if os.path.isfile(config_template):
try:
update_default_config(
__package__, config_dir, version=__version__)
except TypeError as orig_error:
try:
update_default_config(__package__, config_dir)
except ConfigurationDefaultMissingError as e:
wmsg = (e.args[0] +
" Cannot install default profile. If you are "
"importing from source, this is expected.")
warn(ConfigurationDefaultMissingWarning(wmsg))
del e
except Exception:
raise orig_error

0 comments on commit 847af4b

Please sign in to comment.