Commit 9b39fadd authored by Ole Streicher's avatar Ole Streicher

New upstream version 3.2~rc1

parent b02f7bc1
version: 2
jobs:
html-docs:
docker:
- image: circleci/python:3.6
steps:
- checkout
- run:
name: Install Python dependencies
command: |
python3 -m venv venv
. venv/bin/activate
pip install .[docs]
- run:
name: Build Documentation
command: |
. venv/bin/activate
cd docs
make html
make linkcheck
- store_artifacts:
path: docs/_build/html
- run:
name: "Built documentation is available at:"
command: DOCS_URL="${CIRCLE_BUILD_URL}/artifacts/${CIRCLE_NODE_INDEX}/${CIRCLE_WORKING_DIRECTORY/#\~/$HOME}/docs/_build/html/index.html"; echo $DOCS_URL
workflows:
version: 2
tests_and_docs:
jobs:
- html-docs
notify:
webhooks:
- url: https://giles.cadair.com/circleci
[run]
source = astropy_helpers
omit =
astropy_helpers/*/setup_package.py
astropy_helpers/tests/*
astropy_helpers/conftest.py
[report]
omit =
astropy_helpers/*/setup_package.py
astropy_helpers/tests/*
astropy_helpers/conftest.py
exclude_lines =
# Have to re-enable the standard pragma
pragma: no cover
# Don't complain about packages we have installed
except ImportError
# Don't complain if tests don't hit assertions
raise AssertionError
raise NotImplementedError
# Don't complain about script hooks
def main\(.*\):
# Ignore branches that don't pertain to this version of Python
pragma: py{ignore_python_version}
# Compiled files
*.py[cod]
*.a
*.o
*.so
*.pyd
__pycache__
# Ignore .c files by default to avoid including generated code. If you want to
# add a non-generated .c extension, use `git add -f filename.c`.
*.c
# Other generated files
MANIFEST
astropy_helpers/version.py
astropy_helpers/cython_version.py
# Sphinx
_build
_generated
api
# Packages/installer info
*.egg
*.egg-info
dist
build
eggs
parts
bin
var
sdist
develop-eggs
.installed.cfg
distribute-*.tar.gz
# Other
.cache
.tox
.*.swp
*~
.project
.pydevproject
.settings
.coverage
.coverage.subprocess
cover
htmlcov
.pytest_cache
# Mac OSX
.DS_Store
# PyCharm
.idea
# 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:
- osx
- linux
# Setting sudo to false opts in to Travis-CI container-based builds.
sudo: false
env:
matrix:
- PYTHON_VERSION=3.5
- PYTHON_VERSION=3.6
- PYTHON_VERSION=3.7 SETUPTOOLS_VERSION=dev DEBUG=True
CONDA_DEPENDENCIES='sphinx cython numpy pytest-cov'
EVENT_TYPE='push pull_request cron'
global:
- CONDA_DEPENDENCIES="setuptools sphinx cython numpy pytest-cov"
- PIP_DEPENDENCIES="codecov"
- EVENT_TYPE='push pull_request'
- DEBUG=True
matrix:
include:
# Do one build with sphinx-astropy as one of the tests bypasses the auto-
# installation but we want to make sure that test runs for coverage.
- os: linux
env: PYTHON_VERSION=3.6 PIP_DEPENDENCIES='codecov sphinx-astropy'
- os: linux
env: PYTHON_VERSION=3.6 SPHINX_VERSION='1.5' SETUPTOOLS_VERSION=30
- os: linux
env: PYTHON_VERSION=3.5 SPHINX_VERSION='1.5' SETUPTOOLS_VERSION=30
CONDA_DEPENDENCIES=`echo $CONDA_DEPENDENCIES sphinx-astropy 'numpydoc<0.9'`"
- os: linux
env: PYTHON_VERSION=3.6 PIP_DEPENDENCIES='git+https://github.com/sphinx-doc/sphinx.git#egg=sphinx codecov'
CONDA_DEPENDENCIES="setuptools cython numpy pytest-cov" EVENT_TYPE='push pull_request cron'
# Test without installing numpy beforehand to make sure everything works
# without assuming numpy is already installed
- os: linux
env: PYTHON_VERSION=3.6 CONDA_DEPENDENCIES='sphinx cython pytest-cov'
# Test conda's clang
- os: osx
env:
- PYTHON_VERSION=3.5
- CONDA_DEPENDENCIES="setuptools sphinx cython numpy pytest-cov clang llvm-openmp matplotlib"
- OPENMP_EXPECTED=True
- CCOMPILER=clang
# Test gcc on OSX
- os: osx
env:
- PYTHON_VERSION=3.5
- CONDA_DEPENDENCIES="setuptools sphinx cython numpy pytest-cov gcc sphinx-astropy"
- OPENMP_EXPECTED=True
- CCOMPILER=gcc
# Uncomment the following if there are issues in setuptools that we
# can't work around quickly - otherwise leave uncommented so that
# we notice when things go wrong.
#
# allow_failures:
# - env: PYTHON_VERSION=3.6 SETUPTOOLS_VERSION=dev DEBUG=True
# CONDA_DEPENDENCIES='sphinx cython numpy pytest-cov'
# EVENT_TYPE='push pull_request cron'
before_install:
# Test OSX without OpenMP support
# Since the matrix OSX tests use the OS shipped version of clang, they double up
# as exploratory tests for when the shipped version has automatic OpenMP support.
# These tests will then fail and at such a time a new one should be added
# to explicitly remove OpenMP support.
- if [ -z $OPENMP_EXPECTED ]; then
if [[ $TRAVIS_OS_NAME == osx ]]; then
export OPENMP_EXPECTED=False;
else
export OPENMP_EXPECTED=True;
fi
fi
# We need to use CCOMPILER otherwise Travis overwrites CC if we define it
# in env: above.
- if [ ! -z $CCOMPILER ]; then
export CC=$CCOMPILER;
fi
# Check CC variable
- echo $CC
install:
- git clone git://github.com/astropy/ci-helpers.git
- source ci-helpers/travis/setup_conda.sh
# We cannot install the developer version of setuptools using pip because
# pip tries to remove the previous version of setuptools before the
# installation is complete, which causes issues. Instead, we just install
# setuptools manually.
- if [[ $SETUPTOOLS_VERSION == dev ]]; then git clone http://github.com/pypa/setuptools.git; cd setuptools; python bootstrap.py; python setup.py install; cd ..; fi
before_script:
# Some of the tests use git commands that require a user to be configured
- git config --global user.name "A U Thor"
- git config --global user.email "author@example.com"
script:
- pytest --cov astropy_helpers astropy_helpers
# In conftest.py we produce a .coverage.subprocess that contains coverage
# statistics for sub-processes, so we combine it with the main one here.
- mv .coverage .coverage.main
- coverage combine .coverage.main .coverage.subprocess
- coverage report
after_success:
- codecov
astropy-helpers Changelog
*************************
3.2rc1 (2019-04-22)
-------------------
- Make sure that ``[options.package_data]`` in setup.cfg is taken into account
when collecting package data. [#453]
- Simplified the code for the custom build_ext command. [#446]
- Avoid importing the astropy package when trying to get the test command
when testing astropy itself. [#450]
- Avoid importing whole package when trying to get version information. Note
that this has also introduced a small API change - ``cython_version`` and
``compiler`` can no longer be imported from the ``package.version`` module
generated by astropy-helpers. Instead, you can import these from
``package.cython_version`` and ``package.compiler_version`` respectively. [#442]
- Make it possible to call ``generate_version_py`` and ``register_commands``
without any arguments, which causes information to be read in from the
``setup.cfg`` file. [#440]
- Simplified setup.py and moved most of the configuration to setup.cfg. [#445]
- Add a new ``astropy_helpers.setup_helpers.setup`` function that does all
the default boilerplate in typical ``setup.py`` files that use
astropy-helpers. [#443]
- Remove ``deprecated``, ``deprecated_attribute``, and ``minversion`` from
``astropy_helpers.utils``. [#447]
- Updated minimum required version of setuptools to 30.3.0. [#440]
- Remove functionality to adjust compilers if a broken compiler is detected.
This is not useful anymore as only a single compiler was previously patched
(now unlikely to be used) and this was only to fix a compilation issue in the
core astropy package. [#421]
3.1.1 (2019-02-22)
------------------
......
Contributing to astropy-helpers
===============================
The guidelines for contributing to ``astropy-helpers`` are generally the same
as the [contributing guidelines for the astropy core
package](http://github.com/astropy/astropy/blob/master/CONTRIBUTING.md).
Basically, report relevant issues in the ``astropy-helpers`` issue tracker, and
we welcome pull requests that broadly follow the [Astropy coding
guidelines](http://docs.astropy.org/en/latest/development/codeguide.html).
The key subtlety lies in understanding the relationship between ``astropy`` and
``astropy-helpers``. This package contains the build, installation, and
documentation tools used by astropy. It also includes support for the
``setup.py test`` command, though Astropy is still required for this to
function (it does not currently include the full Astropy test runner). So
issues or improvements to that functionality should be addressed in this
package. Any other aspect of the [astropy core
package](http://github.com/astropy/astropy) (or any other package that uses
``astropy-helpers``) should be addressed in the github repository for that
package.
include README.rst
include CHANGES.rst
include LICENSE.rst
recursive-include licenses *
include ah_bootstrap.py
exclude *.pyc *.o
prune build
prune astropy_helpers/tests
Metadata-Version: 2.1
Name: astropy-helpers
Version: 3.1.1
Summary: Utilities for building and installing Astropy, Astropy affiliated packages, and their respective documentation.
Home-page: https://github.com/astropy/astropy-helpers
Author: The Astropy Developers
Author-email: astropy.team@gmail.com
License: BSD
Description: astropy-helpers
===============
.. image:: https://travis-ci.org/astropy/astropy-helpers.svg
:target: https://travis-ci.org/astropy/astropy-helpers
.. image:: https://ci.appveyor.com/api/projects/status/rt9161t9mhx02xp7/branch/master?svg=true
:target: https://ci.appveyor.com/project/Astropy/astropy-helpers
.. image:: https://codecov.io/gh/astropy/astropy-helpers/branch/master/graph/badge.svg
:target: https://codecov.io/gh/astropy/astropy-helpers
The **astropy-helpers** package includes many build, installation, and
documentation-related tools used by the Astropy project, but packaged separately
for use by other projects that wish to leverage this work. The motivation behind
this package and details of its implementation are in the accepted
`Astropy Proposal for Enhancement (APE) 4 <https://github.com/astropy/astropy-APEs/blob/master/APE4.rst>`_.
Astropy-helpers is not a traditional package in the sense that it is not
intended to be installed directly by users or developers. Instead, it is meant
to be accessed when the ``setup.py`` command is run - see :doc:`using` for how
to do this. For a real-life example of how to implement astropy-helpers in a
project, see the ``setup.py`` and ``setup.cfg`` files of the
`Affiliated package template <https://github.com/astropy/package-template>`_.
For more information, see the documentation at http://astropy-helpers.readthedocs.io
Platform: UNKNOWN
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
Classifier: Framework :: Setuptools Plugin
Classifier: Framework :: Sphinx :: Extension
Classifier: Framework :: Sphinx :: Theme
Classifier: License :: OSI Approved :: BSD License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Software Development :: Build Tools
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Topic :: System :: Archiving :: Packaging
Requires-Python: >=3.5
Provides-Extra: docs
......@@ -48,10 +48,7 @@ import sys
from distutils import log
from distutils.debug import DEBUG
try:
from ConfigParser import ConfigParser, RawConfigParser
except ImportError:
from configparser import ConfigParser, RawConfigParser
from configparser import ConfigParser, RawConfigParser
import pkg_resources
......@@ -123,20 +120,22 @@ if SETUP_CFG.has_option('options', 'python_requires'):
if not req.specifier.contains(python_version):
if parent_package is None:
print("ERROR: Python {} is required by this package".format(req.specifier))
message = "ERROR: Python {} is required by this package\n".format(req.specifier)
else:
print("ERROR: Python {} is required by {}".format(req.specifier, parent_package))
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:
print("ERROR: Python {} or later is required by astropy-helpers".format(
__minimum_python_version__))
message = "ERROR: Python {} or later is required by astropy-helpers\n".format(
__minimum_python_version__)
else:
print("ERROR: Python {} or later is required by astropy-helpers for {}".format(
__minimum_python_version__, parent_package))
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)
......@@ -146,14 +145,14 @@ _str_types = (str, bytes)
# 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
......
# AppVeyor.com is a Continuous Integration service to build and run tests under
# Windows
environment:
global:
PYTHON: "C:\\conda"
MINICONDA_VERSION: "latest"
OPENMP_EXPECTED: "True"
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.
# babel 2.0 is known to break on Windows:
# https://github.com/python-babel/babel/issues/174
CONDA_DEPENDENCIES: "numpy Cython sphinx pytest babel!=2.0 setuptools pytest-cov"
PIP_DEPENDENCIES: "codecov"
matrix:
- PYTHON_VERSION: "3.5"
- PYTHON_VERSION: "3.6"
- PYTHON_VERSION: "3.7"
platform:
-x64
install:
# Set up ci-helpers
- "git clone git://github.com/astropy/ci-helpers.git"
- "powershell ci-helpers/appveyor/install-miniconda.ps1"
- "SET PATH=%PYTHON%;%PYTHON%\\Scripts;%PATH%"
- "activate test"
# Some of the tests use git commands that require a user to be configured
- git config --global user.name "A U Thor"
- git config --global user.email "author@example.com"
# Not a .NET project, we build the package in the install step instead
build: false
test_script:
# Specify basetemp explicitly otherwise some of the filenames exceed
# 260 characters when fetch_build_eggs runs.
- "%CMD_IN_ENV% py.test --cov --basetemp=\\pytest-tmp astropy_helpers"
- "%CMD_IN_ENV% codecov"
This diff is collapsed.
......@@ -17,6 +17,7 @@ from sphinx.setup_command import BuildDoc as SphinxBuildDoc
from ..utils import AstropyDeprecationWarning
SPHINX_LT_16 = LooseVersion(sphinx_version) < LooseVersion('1.6')
SPHINX_LT_17 = LooseVersion(sphinx_version) < LooseVersion('1.7')
SUBPROCESS_TEMPLATE = """
......@@ -57,6 +58,19 @@ def ensure_sphinx_astropy_installed():
from setuptools import Distribution
dist = Distribution()
# Numpydoc 0.9.0 requires sphinx 1.6+, we can limit the version here
# until we also makes our minimum required version Sphinx 1.6
if SPHINX_LT_16:
dist.fetch_build_eggs('numpydoc<0.9')
# This egg build doesn't respect python_requires, not aware of
# pre-releases. We know that mpl 3.1+ requires Python 3.6+, so this
# ugly workaround takes care of it until there is a solution for
# https://github.com/astropy/astropy-helpers/issues/462
if LooseVersion(sys.version) < LooseVersion('3.6'):
dist.fetch_build_eggs('matplotlib<3.1')
eggs = dist.fetch_build_eggs('sphinx-astropy')
# Find out the version of sphinx-astropy if possible. For some old
......
from os.path import join
def get_package_data():
return {'astropy_helpers.commands': [join('src', 'compiler.c')]}
......@@ -84,46 +84,33 @@ struct module_state {
#endif
};
#if PY3K
static struct PyModuleDef moduledef = {
PyModuleDef_HEAD_INIT,
"_compiler",
NULL,
sizeof(struct module_state),
NULL,
NULL,
NULL,
NULL,
NULL
};
#define INITERROR return NULL
PyMODINIT_FUNC
PyInit__compiler(void)
static struct PyModuleDef moduledef = {
PyModuleDef_HEAD_INIT,
"compiler_version",
NULL,
sizeof(struct module_state),
NULL,
NULL,
NULL,
NULL,
NULL
};
#else
#define INITERROR return
#define INITERROR return NULL
PyMODINIT_FUNC
PyInit_compiler_version(void)
PyMODINIT_FUNC
init_compiler(void)
#endif
{
PyObject* m;
#if PY3K
m = PyModule_Create(&moduledef);
#else
m = Py_InitModule3("_compiler", NULL, NULL);
#endif
if (m == NULL)
INITERROR;
PyModule_AddStringConstant(m, "compiler", COMPILER);
#if PY3K
return m;
#endif
}
......@@ -2,25 +2,33 @@
Different implementations of the ``./setup.py test`` command depending on
what's locally available.
If Astropy v1.1.0.dev or later is available it should be possible to import
AstropyTest from ``astropy.tests.command``. If ``astropy`` can be imported
but not ``astropy.tests.command`` (i.e. an older version of Astropy), we can
use the backwards-compat implementation of the command.
If Astropy can't be imported at all then there is a skeleton implementation
that allows users to at least discover the ``./setup.py test`` command and
learn that they need Astropy to run it.
If Astropy v1.1 or later is available it should be possible to import
AstropyTest from ``astropy.tests.command``. Otherwise there is a skeleton
implementation that allows users to at least discover the ``./setup.py test``
command and learn that they need Astropy to run it.
"""
import os
from ..utils import import_file
# Previously these except statements caught only ImportErrors, but there are
# some other obscure exceptional conditions that can occur when importing
# astropy.tests (at least on older versions) that can cause these imports to
# fail
try:
import astropy # noqa
from astropy.tests.command import AstropyTest
# If we are testing astropy itself, we need to use import_file to avoid
# actually importing astropy (just the file we need).
command_file = os.path.join('astropy', 'tests', 'command.py')
if os.path.exists(command_file):
AstropyTest = import_file(command_file, 'astropy_tests_command').AstropyTest
else:
import astropy # noqa
from astropy.tests.command import AstropyTest
except Exception:
# No astropy at all--provide the dummy implementation
from ._dummy import _DummyCommand
......
......@@ -53,6 +53,12 @@ def get_dummy_distribution():
return dist
def get_main_package_directory(distribution):
"""
Given a Distribution object, return the main package directory.
"""
return min(distribution.packages, key=len)
def get_distutils_option(option, commands):
""" Returns the value of the given distutils option.
......
......@@ -4,7 +4,7 @@ This module contains a number of utilities for use during
setup/build/packaging that are useful to astropy as a whole.
"""
from __future__ import absolute_import, print_function
from __future__ import absolute_import
import collections
import os
......@@ -13,6 +13,8 @@ import subprocess
import sys
import traceback
import warnings
from configparser import ConfigParser
import builtins
from distutils import log
from distutils.errors import DistutilsOptionError, DistutilsModuleError
......@@ -20,22 +22,23 @@ from distutils.core import Extension
from distutils.core import Command
from distutils.command.sdist import sdist as DistutilsSdist
from setuptools import setup as setuptools_setup
from setuptools.config import read_configuration
from setuptools import find_packages as _find_packages
from .distutils_helpers import (add_command_option, get_compiler_option,
get_dummy_distribution, get_distutils_build_option,
get_distutils_build_or_install_option)
from .version_helpers import get_pkg_version_module
from .version_helpers import get_pkg_version_module, generate_version_py
from .utils import (walk_skip_hidden, import_file, extends_doc,
resolve_name, AstropyDeprecationWarning)
from .commands.build_ext import generate_build_ext_command
from .commands.build_ext import AstropyHelpersBuildExt
from .commands.test import AstropyTest
# These imports are not used in this module, but are included for backwards
# compat with older versions of this module
from .utils import get_numpy_include_path, write_if_different # noqa
from .commands.build_ext import should_build_with_cython, get_compiler_version # noqa
__all__ = ['register_commands', 'get_package_info']
......@@ -66,30 +69,46 @@ except SyntaxError:
pass
def adjust_compiler(package):
def setup(**kwargs):
"""
A wrapper around setuptools' setup() function that automatically sets up
custom commands, generates a version file, and customizes the setup process
via the ``setup_package.py`` files.
"""
This function detects broken compilers and switches to another. If
the environment variable CC is explicitly set, or a compiler is
specified on the commandline, no override is performed -- the purpose
here is to only override a default compiler.
The specific compilers with problems are:
# DEPRECATED: store the package name in a built-in variable so it's easy
# to get from other parts of the setup infrastructure. We should phase this
# out in packages that use it - the cookiecutter template should now be
# able to put the right package name where needed.
conf = read_configuration('setup.cfg')
builtins._ASTROPY_PACKAGE_NAME_ = conf['metadata']['name']
* The default compiler in XCode-4.2, llvm-gcc-4.2,
segfaults when compiling wcslib.
# Create a dictionary with setup command overrides. Note that this gets
# information about the package (name and version) from the setup.cfg file.
cmdclass = register_commands()
The set of broken compilers can be updated by changing the
compiler_mapping variable. It is a list of 2-tuples where the
first in the pair is a regular expression matching the version
of the broken compiler, and the second is the compiler to change
to.
"""
# Freeze build information in version.py. Note that this gets information
# about the package (name and version) from the setup.cfg file.
version = generate_version_py()
# Get configuration information from all of the various subpackages.
# See the docstring for setup_helpers.update_package_files for more
# details.
package_info = get_package_info()
package_info['cmdclass'] = cmdclass
package_info['version'] = version
# Override using any specified keyword arguments
package_info.update(kwargs)
setuptools_setup(**package_info)
def adjust_compiler(package):
warnings.warn(
'Direct use of the adjust_compiler function in setup.py is '
'deprecated and can be removed from your setup.py. This '
'functionality is now incorporated directly into the build_ext '
'command.', AstropyDeprecationWarning)
'The adjust_compiler function in setup.py is '
'deprecated and can be removed from your setup.py.',
AstropyDeprecationWarning)