Skip to content

Commit

Permalink
Merge pull request #538 from bsipocz/update_infrastructure
Browse files Browse the repository at this point in the history
Infrastructure cleanup
  • Loading branch information
keflavich authored Mar 4, 2019
2 parents f65c335 + ba52b2a commit 7523dc8
Show file tree
Hide file tree
Showing 19 changed files with 171 additions and 153 deletions.
70 changes: 27 additions & 43 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@
language: python

python:
- 3.5
- 3.6

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

# The apt packages below are needed for sphinx builds, which can no longer
# be installed with sudo apt-get.
Expand All @@ -24,61 +17,52 @@ env:
# We run the tests in 'boxed' mode, i.e. one subprocess per test,
# because there are memory leaks in Astropy that currently cause the
# memory to go up to levels that cause the tests to be slow.
- PYTHON_VERSION=3.6
- SETUP_CMD='test -a "--boxed"'
- NUMPY_VERSION=1.13
- NUMPY_VERSION=stable
- ASTROPY_VERSION=stable
- CONDA_DEPENDENCIES='sip<4.19 aplpy pytest=3.9.3 pytest-xdist astropy-helpers joblib glue-core scipy'
- CONDA_CHANNELS='astropy-ci-extras astropy glueviz'
- CONDA_DEPENDENCIES='sip<4.19 aplpy pytest-xdist joblib glue-core scipy'
- CONDA_CHANNELS='astropy glueviz'
- PIP_DEPENDENCIES='matplotlib<2 Cython https://github.com/radio-astro-tools/pvextractor/archive/master.zip radio_beam https://github.com/astropy/regions/archive/master.zip https://github.com/astropy/reproject/archive/master.zip'
- SETUP_XVFB=True

matrix:
- SETUP_CMD='egg_info'
- # run with default settings
- ASTROPY_VERSION='development'
- CONDA_DEPENDENCIES='pytest=3.9.3 pytest-xdist' PIP_DEPENDENCIES='radio_beam'

matrix:
include:
- env: SETUP_CMD='egg_info'

- env: PYTHON_VERSION=3.5 CONDA_DEPENDENCIES='pytest-xdist' PIP_DEPENDENCIES='radio_beam' NUMPY_VERSION=1.14

# Do a coverage test in Python 3.
# make sure *everything* is run for coverage tests
## COVERAGE TESTS DISABLED: they don't work any more. I have found no combination of anything that fixes this.
- python: 3.6
env: SETUP_CMD='test --coverage'
PYTEST_VERSION="<3.10"
CONDA_DEPENDENCIES='matplotlib aplpy yt bottleneck sip<4.19 aplpy pytest=3.9.3 pytest-xdist astropy-helpers joblib glue-core scipy'
# pytest 3.9.3 suggested by @e-koch, @astrofrog. 3.10.1 doesn't work, 4.x doesn't work
# overrode python version too, per bsipocz
- env: SETUP_CMD='test --coverage'
CONDA_DEPENDENCIES='matplotlib yt bottleneck sip<4.19 aplpy pytest-xdist joblib glue-core scipy'
PIP_DEPENDENCIES="`echo $PIP_DEPENDENCIES | sed 's/matplotlib<2//'`"

# Check for sphinx doc build warnings - we do this first because it
# may run for a long time
- python: 3.6
env: SETUP_CMD='build_sphinx -w'
# may run for a long time.
# We need to use an old numpy version here as there are warnings in the inherited methods when using newer one
- env: SETUP_CMD='build_sphinx -w' NUMPY_VERSION=1.13

# test python2.7 with recent numpy version
- python: 2.7
env: PIP_DEPENDENCIES='https://github.com/radio-astro-tools/pvextractor/archive/master.zip radio_beam'
- env: PYTHON_VERSION=2.7 PYTEST_VERSION="<3.7"
PIP_DEPENDENCIES='https://github.com/radio-astro-tools/pvextractor/archive/master.zip radio_beam'

- python: 3.6
env: NUMPY_VERSION=1.11 ASTROPY_VERSION=LTS CONDA_DEPENDENCIES='matplotlib aplpy bottleneck pytest pytest-xdist astropy-helpers'
- env: NUMPY_VERSION=1.11 ASTROPY_VERSION=LTS
CONDA_DEPENDENCIES='matplotlib aplpy bottleneck pytest-xdist'
PYTEST_VERSION="<3.7"

# Test with development versions
- python: 3.5
env:
PIP_DEPENDENCIES='https://github.com/radio-astro-tools/radio_beam/archive/master.zip https://github.com/radio-astro-tools/pvextractor/archive/master.zip'
ASTROPY_VERSION='development'
- env: PYTHON_VERSION=3.5 NUMPY_VERSION=1.15 ASTROPY_VERSION='development'
PIP_DEPENDENCIES="`echo $PIP_DEPENDENCIES | sed 's/matplotlib<2//'`"

- env: ASTROPY_VERSION='development'
PIP_DEPENDENCIES="`echo $PIP_DEPENDENCIES | sed 's/matplotlib<2//'`"

- python: 3.6
env:
PIP_DEPENDENCIES='https://github.com/radio-astro-tools/radio_beam/archive/master.zip https://github.com/radio-astro-tools/pvextractor/archive/master.zip'
ASTROPY_VERSION='development'
- env: CONDA_DEPENDENCIES='matplotlib=3 aplpy yt bottleneck pytest-xdist joblib'
ASTROPY_VERSION='development'
PIP_DEPENDENCIES="`echo $PIP_DEPENDENCIES | sed 's/matplotlib<2//'`"

- python: 3.6
env:
CONDA_DEPENDENCIES='matplotlib=3 aplpy yt bottleneck pytest pytest-xdist astropy-helpers joblib'
PIP_DEPENDENCIES='https://github.com/radio-astro-tools/radio_beam/archive/master.zip https://github.com/radio-astro-tools/pvextractor/archive/master.zip'
ASTROPY_VERSION='development'

install:
- git clone git://github.com/astropy/ci-helpers.git
Expand Down
158 changes: 97 additions & 61 deletions ah_bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,18 +45,22 @@
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)

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__ = (2, 7)

if sys.version_info[0] < 3:
_str_types = (str, unicode)
Expand All @@ -67,6 +71,88 @@
_text_type = str
PY3 = True

# 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)
]

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

# 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:
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
python_version = platform.python_version()

if not req.specifier.contains(python_version):
if parent_package is None:
print("ERROR: Python {} is required by this package".format(req.specifier))
else:
print("ERROR: Python {} is required by {}".format(req.specifier, parent_package))
sys.exit(1)

if sys.version_info < __minimum_python_version__:

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

sys.exit(1)


# What follows are several import statements meant to deal with install-time
# issues with either missing or misbehaving pacakges (including making sure
Expand Down Expand Up @@ -123,40 +209,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 Down Expand Up @@ -226,36 +278,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 +680,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
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@

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

# Get configuration information from setup.cfg
try:
Expand Down
1 change: 1 addition & 0 deletions docs/installing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ This package has the following dependencies:
* `Regions <https://astropy-regions.readthedocs.io/en/latest>`_ >=0.3dev, optional
(Serialises/Deserialises DS9/CRTF region files and handles them. Used when
extracting a subcube from region)
* `six <http://pypi.python.org/pypi/six/>`_

Installation
------------
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ upload-dir = docs/_build/html
show-response = 1

[tool:pytest]
minversion = 2.2
minversion = 3.0
norecursedirs = build docs/_build
doctest_plus = enabled
addopts = -p no:warnings
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@
version=VERSION,
description=DESCRIPTION,
scripts=scripts,
install_requires=['astropy','numpy>=1.8.0', 'radio_beam'],
install_requires=['astropy','numpy>=1.8.0', 'radio_beam', 'six'],
author=AUTHOR,
author_email=AUTHOR_EMAIL,
license=LICENSE,
Expand Down
5 changes: 2 additions & 3 deletions spectral_cube/analysis_utilities.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import numpy as np

from astropy import units as u
from astropy.extern.six.moves import zip
from astropy.extern.six.moves import range as xrange
from six.moves import zip, range
from astropy.wcs import WCS
from astropy.utils.console import ProgressBar
import warnings
Expand Down Expand Up @@ -117,7 +116,7 @@ def get_chunks(num_items, chunk):

chunks = \
np.array_split(items,
[chunk * i for i in xrange(int(num_items / chunk))])
[chunk * i for i in range(int(num_items / chunk))])
if chunks[-1].size == 0:
# Last one is empty
chunks = chunks[:-1]
Expand Down
Loading

0 comments on commit 7523dc8

Please sign in to comment.