Skip to content

Commit

Permalink
Merge a6e3e98 into 7bbf41f
Browse files Browse the repository at this point in the history
  • Loading branch information
zblz committed Aug 29, 2019
2 parents 7bbf41f + a6e3e98 commit ed32a62
Show file tree
Hide file tree
Showing 37 changed files with 334 additions and 414 deletions.
26 changes: 8 additions & 18 deletions .travis.yml
Expand Up @@ -23,24 +23,21 @@ env:
# The following versions are the 'default' for tests, unless
# overidden underneath. They are defined here in order to save having
# to repeat them for all configurations.
- PYTHON_VERSION=3.6
- NUMPY_VERSION=1.13
- PYTHON_VERSION=3.7
- NUMPY_VERSION=stable
- ASTROPY_VERSION=stable
- CONDA_DEPENDENCIES='pytest pip Cython jinja2 pyyaml scipy matplotlib h5py mock sphinx_rtd_theme'
- PIP_DEPENDENCIES='emcee corner'
- CONDA_CHANNELS='sherpa'
- CONDA_DEPENDENCIES='pytest pip Cython jinja2 pyyaml scipy matplotlib h5py mock sphinx_rtd_theme sherpa'
- PIP_DEPENDENCIES='emcee corner sphinx-astropy'

matrix:
- PYTHON_VERSION=2.7 SETUP_CMD='egg_info'
- PYTHON_VERSION=3.6 SETUP_CMD='egg_info'
- PYTHON_VERSION=3.7 SETUP_CMD='egg_info'

matrix:

include:

# Windows (start early as it is significantly slower)
- os: windows
env: SETUP_CMD='test'

# Check for sphinx doc build warnings
- os: linux
env: SETUP_CMD='build_docs -w'
Expand All @@ -49,19 +46,12 @@ matrix:
- os: linux
env: SETUP_CMD='examples'

# Try all python versions, with sherpa and coverage testing in py35
- os: linux
env: PYTHON_VERSION=2.7 SETUP_CMD='test --args="-v"'
- os: linux
env: PYTHON_VERSION=3.5 SETUP_CMD='test --coverage --args="-v"'
CONDA_CHANNELS='astropy-ci-extras sherpa'
CONDA_DEPENDENCIES="$CONDA_DEPENDENCIES sherpa"
env: PYTHON_VERSION=3.6 SETUP_CMD='test --args="-v"'
- os: linux
env: SETUP_CMD='test --args="-v"'
env: SETUP_CMD='test --coverage --args="-v"'

# Try MacOS X
- os: osx
env: PYTHON_VERSION=2.7 SETUP_CMD='test --args="-v"'
- os: osx
env: SETUP_CMD='test --args="-v"'

Expand Down
180 changes: 102 additions & 78 deletions ah_bootstrap.py
Expand Up @@ -45,41 +45,115 @@
import subprocess as sp
import sys

__minimum_python_version__ = (2, 7)
from distutils import log
from distutils.debug import DEBUG

if sys.version_info < __minimum_python_version__:
print("ERROR: Python {} or later is required by astropy-helpers".format(
__minimum_python_version__))
sys.exit(1)
from configparser import ConfigParser, RawConfigParser

try:
from ConfigParser import ConfigParser, RawConfigParser
except ImportError:
from configparser import ConfigParser, RawConfigParser
import pkg_resources

from setuptools import Distribution
from setuptools.package_index import PackageIndex

# This is the minimum Python version required for astropy-helpers
__minimum_python_version__ = (3, 5)

# TODO: Maybe enable checking for a specific version of astropy_helpers?
DIST_NAME = 'astropy-helpers'
PACKAGE_NAME = 'astropy_helpers'
UPPER_VERSION_EXCLUSIVE = None

# Defaults for other options
DOWNLOAD_IF_NEEDED = True
INDEX_URL = 'https://pypi.python.org/simple'
USE_GIT = True
OFFLINE = False
AUTO_UPGRADE = True

# A list of all the configuration options and their required types
CFG_OPTIONS = [
('auto_use', bool), ('path', str), ('download_if_needed', bool),
('index_url', str), ('use_git', bool), ('offline', bool),
('auto_upgrade', bool)
]

# Start off by parsing the setup.cfg file

SETUP_CFG = ConfigParser()

if os.path.exists('setup.cfg'):

try:
SETUP_CFG.read('setup.cfg')
except Exception as e:
if DEBUG:
raise

log.error(
"Error reading setup.cfg: {0!r}\n{1} will not be "
"automatically bootstrapped and package installation may fail."
"\n{2}".format(e, PACKAGE_NAME, _err_help_msg))

if sys.version_info[0] < 3:
_str_types = (str, unicode)
_text_type = unicode
PY3 = False
# We used package_name in the package template for a while instead of name
if SETUP_CFG.has_option('metadata', 'name'):
parent_package = SETUP_CFG.get('metadata', 'name')
elif SETUP_CFG.has_option('metadata', 'package_name'):
parent_package = SETUP_CFG.get('metadata', 'package_name')
else:
_str_types = (str, bytes)
_text_type = str
PY3 = True
parent_package = None

if SETUP_CFG.has_option('options', 'python_requires'):

python_requires = SETUP_CFG.get('options', 'python_requires')

# The python_requires key has a syntax that can be parsed by SpecifierSet
# in the packaging package. However, we don't want to have to depend on that
# package, so instead we can use setuptools (which bundles packaging). We
# have to add 'python' to parse it with Requirement.

from pkg_resources import Requirement
req = Requirement.parse('python' + python_requires)

# We want the Python version as a string, which we can get from the platform module
import platform
# strip off trailing '+' incase this is a dev install of python
python_version = platform.python_version().strip('+')
# allow pre-releases to count as 'new enough'
if not req.specifier.contains(python_version, True):
if parent_package is None:
message = "ERROR: Python {} is required by this package\n".format(req.specifier)
else:
message = "ERROR: Python {} is required by {}\n".format(req.specifier, parent_package)
sys.stderr.write(message)
sys.exit(1)

if sys.version_info < __minimum_python_version__:

if parent_package is None:
message = "ERROR: Python {} or later is required by astropy-helpers\n".format(
__minimum_python_version__)
else:
message = "ERROR: Python {} or later is required by astropy-helpers for {}\n".format(
__minimum_python_version__, parent_package)

sys.stderr.write(message)
sys.exit(1)

_str_types = (str, bytes)


# What follows are several import statements meant to deal with install-time
# issues with either missing or misbehaving pacakges (including making sure
# setuptools itself is installed):

# Check that setuptools 1.0 or later is present
# Check that setuptools 30.3 or later is present
from distutils.version import LooseVersion

try:
import setuptools
assert LooseVersion(setuptools.__version__) >= LooseVersion('1.0')
assert LooseVersion(setuptools.__version__) >= LooseVersion('30.3')
except (ImportError, AssertionError):
print("ERROR: setuptools 1.0 or later is required by astropy-helpers")
sys.stderr.write("ERROR: setuptools 30.3 or later is required by astropy-helpers\n")
sys.exit(1)

# typing as a dependency for 1.6.1+ Sphinx causes issues when imported after
Expand Down Expand Up @@ -123,40 +197,6 @@
# End compatibility imports...


# In case it didn't successfully import before the ez_setup checks
import pkg_resources

from setuptools import Distribution
from setuptools.package_index import PackageIndex

from distutils import log
from distutils.debug import DEBUG


# TODO: Maybe enable checking for a specific version of astropy_helpers?
DIST_NAME = 'astropy-helpers'
PACKAGE_NAME = 'astropy_helpers'

if PY3:
UPPER_VERSION_EXCLUSIVE = None
else:
UPPER_VERSION_EXCLUSIVE = '3'

# Defaults for other options
DOWNLOAD_IF_NEEDED = True
INDEX_URL = 'https://pypi.python.org/simple'
USE_GIT = True
OFFLINE = False
AUTO_UPGRADE = True

# A list of all the configuration options and their required types
CFG_OPTIONS = [
('auto_use', bool), ('path', str), ('download_if_needed', bool),
('index_url', str), ('use_git', bool), ('offline', bool),
('auto_upgrade', bool)
]


class _Bootstrapper(object):
"""
Bootstrapper implementation. See ``use_astropy_helpers`` for parameter
Expand All @@ -172,7 +212,7 @@ def __init__(self, path=None, index_url=None, use_git=None, offline=None,
if not (isinstance(path, _str_types) or path is False):
raise TypeError('path must be a string or False')

if PY3 and not isinstance(path, _text_type):
if not isinstance(path, str):
fs_encoding = sys.getfilesystemencoding()
path = path.decode(fs_encoding) # path to unicode

Expand Down Expand Up @@ -226,36 +266,20 @@ def main(cls, argv=None):

@classmethod
def parse_config(cls):
if not os.path.exists('setup.cfg'):
return {}

cfg = ConfigParser()

try:
cfg.read('setup.cfg')
except Exception as e:
if DEBUG:
raise

log.error(
"Error reading setup.cfg: {0!r}\n{1} will not be "
"automatically bootstrapped and package installation may fail."
"\n{2}".format(e, PACKAGE_NAME, _err_help_msg))
return {}

if not cfg.has_section('ah_bootstrap'):
if not SETUP_CFG.has_section('ah_bootstrap'):
return {}

config = {}

for option, type_ in CFG_OPTIONS:
if not cfg.has_option('ah_bootstrap', option):
if not SETUP_CFG.has_option('ah_bootstrap', option):
continue

if type_ is bool:
value = cfg.getboolean('ah_bootstrap', option)
value = SETUP_CFG.getboolean('ah_bootstrap', option)
else:
value = cfg.get('ah_bootstrap', option)
value = SETUP_CFG.get('ah_bootstrap', option)

config[option] = value

Expand Down Expand Up @@ -644,8 +668,8 @@ def _check_submodule_using_git(self):
# only if the submodule is initialized. We ignore this information for
# now
_git_submodule_status_re = re.compile(
'^(?P<status>[+-U ])(?P<commit>[0-9a-f]{40}) '
'(?P<submodule>\S+)( .*)?$')
r'^(?P<status>[+-U ])(?P<commit>[0-9a-f]{40}) '
r'(?P<submodule>\S+)( .*)?$')

# The stdout should only contain one line--the status of the
# requested submodule
Expand Down Expand Up @@ -815,9 +839,9 @@ def run_cmd(cmd):
stdio_encoding = 'latin1'

# Unlikely to fail at this point but even then let's be flexible
if not isinstance(stdout, _text_type):
if not isinstance(stdout, str):
stdout = stdout.decode(stdio_encoding, 'replace')
if not isinstance(stderr, _text_type):
if not isinstance(stderr, str):
stderr = stderr.decode(stdio_encoding, 'replace')

return (p.returncode, stdout, stderr)
Expand Down
2 changes: 1 addition & 1 deletion astropy_helpers
Submodule astropy_helpers updated 91 files
+39 −0 .circleci/config.yml
+0 −0 .coveragerc
+3 −2 .gitignore
+10 −0 .readthedocs.yml
+78 −29 .travis.yml
+132 −1 CHANGES.rst
+18 −42 README.rst
+102 −78 ah_bootstrap.py
+7 −5 appveyor.yml
+1 −4 astropy_helpers/__init__.py
+2 −10 astropy_helpers/commands/_dummy.py
+0 −307 astropy_helpers/commands/_test_compat.py
+165 −435 astropy_helpers/commands/build_ext.py
+0 −39 astropy_helpers/commands/build_py.py
+116 −137 astropy_helpers/commands/build_sphinx.py
+0 −14 astropy_helpers/commands/install.py
+0 −14 astropy_helpers/commands/install_lib.py
+0 −53 astropy_helpers/commands/register.py
+0 −5 astropy_helpers/commands/setup_package.py
+14 −36 astropy_helpers/commands/src/compiler.c
+17 −12 astropy_helpers/commands/test.py
+0 −12 astropy_helpers/compat/__init__.py
+9 −3 astropy_helpers/conftest.py
+6 −0 astropy_helpers/distutils_helpers.py
+0 −11 astropy_helpers/extern/__init__.py
+0 −1 astropy_helpers/extern/automodapi/__init__.py
+0 −138 astropy_helpers/extern/automodapi/autodoc_enhancements.py
+0 −426 astropy_helpers/extern/automodapi/automodapi.py
+0 −686 astropy_helpers/extern/automodapi/automodsumm.py
+0 −107 astropy_helpers/extern/automodapi/smart_resolver.py
+0 −10 astropy_helpers/extern/automodapi/templates/autosummary_core/base.rst
+0 −65 astropy_helpers/extern/automodapi/templates/autosummary_core/class.rst
+0 −41 astropy_helpers/extern/automodapi/templates/autosummary_core/module.rst
+0 −214 astropy_helpers/extern/automodapi/utils.py
+0 −8 astropy_helpers/extern/numpydoc/__init__.py
+0 −624 astropy_helpers/extern/numpydoc/docscrape.py
+0 −425 astropy_helpers/extern/numpydoc/docscrape_sphinx.py
+0 −325 astropy_helpers/extern/numpydoc/numpydoc.py
+0 −16 astropy_helpers/extern/numpydoc/templates/numpydoc_docstring.rst
+0 −4 astropy_helpers/extern/setup_package.py
+2 −0 astropy_helpers/git_helpers.py
+231 −30 astropy_helpers/openmp_helpers.py
+97 −83 astropy_helpers/setup_helpers.py
+0 −8 astropy_helpers/sphinx/__init__.py
+2 −341 astropy_helpers/sphinx/conf.py
+0 −2 astropy_helpers/sphinx/ext/__init__.py
+0 −82 astropy_helpers/sphinx/ext/changelog_links.py
+0 −56 astropy_helpers/sphinx/ext/doctest.py
+0 −168 astropy_helpers/sphinx/ext/edit_on_github.py
+0 −0 astropy_helpers/sphinx/ext/tests/__init__.py
+0 −22 astropy_helpers/sphinx/ext/tocdepthfix.py
+ astropy_helpers/sphinx/local/python2_local_links.inv
+0 −25 astropy_helpers/sphinx/local/python2_local_links.txt
+ astropy_helpers/sphinx/local/python3_local_links.inv
+0 −38 astropy_helpers/sphinx/local/python3_local_links.txt
+0 −10 astropy_helpers/sphinx/setup_package.py
+0 −3 astropy_helpers/sphinx/themes/bootstrap-astropy/globaltoc.html
+0 −96 astropy_helpers/sphinx/themes/bootstrap-astropy/layout.html
+0 −3 astropy_helpers/sphinx/themes/bootstrap-astropy/localtoc.html
+0 −7 astropy_helpers/sphinx/themes/bootstrap-astropy/searchbox.html
+0 −75 astropy_helpers/sphinx/themes/bootstrap-astropy/static/astropy_linkout.svg
+ astropy_helpers/sphinx/themes/bootstrap-astropy/static/astropy_linkout_20.png
+ astropy_helpers/sphinx/themes/bootstrap-astropy/static/astropy_logo.ico
+0 −87 astropy_helpers/sphinx/themes/bootstrap-astropy/static/astropy_logo.svg
+ astropy_helpers/sphinx/themes/bootstrap-astropy/static/astropy_logo_32.png
+0 −601 astropy_helpers/sphinx/themes/bootstrap-astropy/static/bootstrap-astropy.css
+0 −63 astropy_helpers/sphinx/themes/bootstrap-astropy/static/copybutton.js
+0 −160 astropy_helpers/sphinx/themes/bootstrap-astropy/static/sidebar.js
+0 −10 astropy_helpers/sphinx/themes/bootstrap-astropy/theme.conf
+0 −13 astropy_helpers/test_helpers.py
+3 −0 astropy_helpers/tests/__init__.py
+57 −16 astropy_helpers/tests/test_git_helpers.py
+32 −3 astropy_helpers/tests/test_openmp_helpers.py
+41 −208 astropy_helpers/tests/test_setup_helpers.py
+16 −566 astropy_helpers/utils.py
+94 −37 astropy_helpers/version_helpers.py
+19 −0 docs/Makefile
+22 −0 docs/advanced.rst
+14 −0 docs/api.rst
+273 −0 docs/basic.rst
+52 −0 docs/conf.py
+29 −0 docs/developers.rst
+36 −0 docs/index.rst
+12 −0 docs/known_issues.rst
+35 −0 docs/make.bat
+28 −0 docs/updating.rst
+53 −0 docs/using.rst
+0 −50 licenses/LICENSE_COPYBUTTON.rst
+0 −94 licenses/LICENSE_NUMPYDOC.rst
+34 −0 setup.cfg
+12 −44 setup.py
8 changes: 4 additions & 4 deletions docs/_static/RXJ1713_IC.py
@@ -1,15 +1,15 @@
#!/usr/bin/env python
import numpy as np
import naima
import os
import sys

import astropy.units as u
import naima
import numpy as np
from astropy.io import ascii
from naima.models import ExponentialCutoffPowerLaw, InverseCompton

# Model definition

from naima.models import InverseCompton, ExponentialCutoffPowerLaw


def ElectronIC(pars, data):

Expand Down
9 changes: 6 additions & 3 deletions docs/conf.py
Expand Up @@ -29,6 +29,8 @@
import os
import sys

from astropy_helpers.sphinx.conf import *

try:
import astropy_helpers
except ImportError:
Expand All @@ -41,8 +43,6 @@
# If that doesn't work trying to import from astropy_helpers below will
# still blow up

# Load all of the global Astropy configuration
from astropy_helpers.sphinx.conf import *

# Get configuration information from setup.cfg
try:
Expand All @@ -60,7 +60,10 @@

# del intersphinx_mapping['h5py']

intersphinx_mapping["emcee"] = ("https://emcee.readthedocs.io/en/stable/", None)
intersphinx_mapping["emcee"] = (
"https://emcee.readthedocs.io/en/stable/",
None,
)


# List of patterns, relative to source directory, that match files and
Expand Down

0 comments on commit ed32a62

Please sign in to comment.