From 8d318082713632808f53f171afe209a0216b4f7d Mon Sep 17 00:00:00 2001 From: Thomas Robitaille Date: Wed, 13 Nov 2019 09:36:57 +0000 Subject: [PATCH 01/12] Updated minimum Python version to 3.6 --- .travis.yml | 10 +++------- appveyor.yml | 1 - setup.cfg | 2 +- 3 files changed, 4 insertions(+), 9 deletions(-) diff --git a/.travis.yml b/.travis.yml index d4195966..6cafc851 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,7 +12,6 @@ sudo: false env: matrix: - - PYTHON_VERSION=3.5 - PYTHON_VERSION=3.6 - PYTHON_VERSION=3.7 SETUPTOOLS_VERSION=dev DEBUG=True CONDA_DEPENDENCIES="cython numpy pytest-cov sphinx-astropy' @@ -31,10 +30,7 @@ matrix: - os: linux env: PYTHON_VERSION=3.6 PIP_DEPENDENCIES='codecov' - 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 'numpydoc<0.9'`" + env: PYTHON_VERSION=3.6 SPHINX_VERSION='1.7' SETUPTOOLS_VERSION=30 - 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 sphinx-astropy" @@ -47,7 +43,7 @@ matrix: # Test conda's clang - os: osx env: - - PYTHON_VERSION=3.5 + - PYTHON_VERSION=3.7 - CONDA_DEPENDENCIES="setuptools sphinx-astropy cython numpy pytest-cov clang llvm-openmp matplotlib" - OPENMP_EXPECTED=True - CCOMPILER=clang @@ -55,7 +51,7 @@ matrix: # Test gcc on OSX - os: osx env: - - PYTHON_VERSION=3.5 + - PYTHON_VERSION=3.7 - CONDA_DEPENDENCIES="setuptools sphinx-astropy cython numpy pytest-cov gcc" - OPENMP_EXPECTED=True - CCOMPILER=gcc diff --git a/appveyor.yml b/appveyor.yml index b1ea74a7..056546a3 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -18,7 +18,6 @@ environment: PIP_DEPENDENCIES: "codecov" matrix: - - PYTHON_VERSION: "3.5" - PYTHON_VERSION: "3.6" - PYTHON_VERSION: "3.7" diff --git a/setup.cfg b/setup.cfg index 3f1259ac..564ea4c2 100644 --- a/setup.cfg +++ b/setup.cfg @@ -23,7 +23,7 @@ classifiers = [options] zip_safe = False -python_requires = >=3.5 +python_requires = >=3.6 packages = find: [options.package_data] From fbc645a2e4bbffbcfbe59290bc7fca861f471133 Mon Sep 17 00:00:00 2001 From: Thomas Robitaille Date: Wed, 13 Nov 2019 09:38:26 +0000 Subject: [PATCH 02/12] Added support for --parallel in build_docs --- astropy_helpers/commands/build_sphinx.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/astropy_helpers/commands/build_sphinx.py b/astropy_helpers/commands/build_sphinx.py index 211ba9b4..bd465599 100644 --- a/astropy_helpers/commands/build_sphinx.py +++ b/astropy_helpers/commands/build_sphinx.py @@ -83,6 +83,11 @@ class AstropyBuildDocs(SphinxBuildDoc): ('open-docs-in-browser', 'o', 'Open the docs in a browser (using the webbrowser module) if the ' 'build finishes successfully.')) + user_options.append( + ('parallel=', 'j', + 'Build the docs in parallel on the specified number of ' + 'processes. If "auto", all the cores on the machine will be ' + 'used.')) boolean_options = SphinxBuildDoc.boolean_options[:] boolean_options.append('warnings-returncode') @@ -99,6 +104,7 @@ def initialize_options(self): self.open_docs_in_browser = False self.warnings_returncode = False self.traceback = False + self.parallel = None def finalize_options(self): @@ -198,6 +204,9 @@ def run(self): elif self.verbose > 1: argv.append('-v') + if self.parallel is not None: + argv.append(f'-j={self.parallel}') + if SPHINX_LT_17: argv.insert(0, 'sphinx-build') From b82535f7e527c855c1ba972b7d3c2ae62f8f48aa Mon Sep 17 00:00:00 2001 From: Thomas Robitaille Date: Wed, 13 Nov 2019 09:38:48 +0000 Subject: [PATCH 03/12] Added changelog entries --- CHANGES.rst | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGES.rst b/CHANGES.rst index 48543f5d..afe37361 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -4,7 +4,9 @@ astropy-helpers Changelog 4.0 (unreleased) ------------------ -- No changes yet. +- Changed minimum required Python version to 3.6. [#498] + +- Added a --parallel option for build_docs. [#498] 3.2.2 (unreleased) From f6ed0a3b755b6f886c7f86a09a34d7b56e77273a Mon Sep 17 00:00:00 2001 From: Thomas Robitaille Date: Wed, 13 Nov 2019 09:40:47 +0000 Subject: [PATCH 04/12] Added test of --parallel option --- astropy_helpers/tests/test_setup_helpers.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/astropy_helpers/tests/test_setup_helpers.py b/astropy_helpers/tests/test_setup_helpers.py index 6c62974d..ab2ae9c0 100644 --- a/astropy_helpers/tests/test_setup_helpers.py +++ b/astropy_helpers/tests/test_setup_helpers.py @@ -246,7 +246,7 @@ def test_missing_cython_c_files(capsys, pyx_extension_test_package, assert msg in stderr -@pytest.mark.parametrize('mode', ['cli', 'cli-w', 'cli-sphinx', 'cli-l']) +@pytest.mark.parametrize('mode', ['cli', 'cli-w', 'cli-sphinx', 'cli-l', 'cli-parallel']) def test_build_docs(capsys, tmpdir, mode): """ Test for build_docs @@ -309,6 +309,8 @@ class B(A): run_setup('setup.py', ['build_docs', '-l']) elif mode == 'cli-sphinx': run_setup('setup.py', ['build_sphinx']) + elif mode == 'cli-parallel': + run_setup('setup.py', ['build_docs', '--parallel=2']) assert os.path.exists(docs_dir.join('_build', 'html', 'index.html').strpath) From 53784a859e192fc18b40ef6e4964a058385377a8 Mon Sep 17 00:00:00 2001 From: Thomas Robitaille Date: Wed, 13 Nov 2019 09:46:17 +0000 Subject: [PATCH 05/12] Require sphinx-astropy 1.2 or later, which also means we can drop support for sphinx<1.7 --- astropy_helpers/commands/build_sphinx.py | 38 ++++++++---------------- 1 file changed, 13 insertions(+), 25 deletions(-) diff --git a/astropy_helpers/commands/build_sphinx.py b/astropy_helpers/commands/build_sphinx.py index bd465599..3abbea38 100644 --- a/astropy_helpers/commands/build_sphinx.py +++ b/astropy_helpers/commands/build_sphinx.py @@ -9,12 +9,8 @@ from distutils import log -from sphinx import __version__ as sphinx_version from sphinx.setup_command import BuildDoc as SphinxBuildDoc -SPHINX_LT_16 = LooseVersion(sphinx_version) < LooseVersion('1.6') -SPHINX_LT_17 = LooseVersion(sphinx_version) < LooseVersion('1.7') - SUBPROCESS_TEMPLATE = """ import os import sys @@ -50,7 +46,7 @@ def ensure_sphinx_astropy_installed(): try: from sphinx_astropy import __version__ as sphinx_astropy_version # noqa except ImportError: - raise ImportError("sphinx-astropy needs to be installed to build " + raise ImportError("sphinx-astropy 1.2 or later needs to be installed to build " "the documentation.") return sphinx_astropy_version, sys_path_inserts @@ -155,14 +151,16 @@ def run(self): else: ah_path = os.path.abspath(ah_importer.path) - if SPHINX_LT_17: - build_main = 'from sphinx import build_main' - else: - build_main = 'from sphinx.cmd.build import build_main' + build_main = 'from sphinx.cmd.build import build_main' # We need to make sure sphinx-astropy is installed sphinx_astropy_version, extra_paths = ensure_sphinx_astropy_installed() + # Require sphinx-astropy 1.2 which also enforces a requirement of sphinx>=1.7 + if LooseVersion(sphinx_astropy_version) <= LooseVersion('1.2'): + raise ImportError("sphinx-astropy 1.2 or later needs to be installed to build " + "the documentation.") + sys_path_inserts = [build_cmd_path, ah_path] + extra_paths sys_path_inserts = os.linesep.join(['sys.path.insert(0, {0!r})'.format(path) for path in sys_path_inserts]) @@ -172,14 +170,7 @@ def run(self): argv.append('-W') if self.no_intersphinx: - # Note, if sphinx_astropy_version is None, this could indicate an - # old version of setuptools, but sphinx-astropy is likely ok, so - # we can proceed. - if sphinx_astropy_version is None or LooseVersion(sphinx_astropy_version) >= LooseVersion('1.1'): - argv.extend(['-D', 'disable_intersphinx=1']) - else: - log.warn('The -n option to disable intersphinx requires ' - 'sphinx-astropy>=1.1. Ignoring.') + argv.extend(['-D', 'disable_intersphinx=1']) # We now need to adjust the flags based on the parent class's options @@ -207,20 +198,17 @@ def run(self): if self.parallel is not None: argv.append(f'-j={self.parallel}') - if SPHINX_LT_17: - argv.insert(0, 'sphinx-build') - if isinstance(self.builder, str): builders = [self.builder] else: builders = self.builder subproccode = SUBPROCESS_TEMPLATE.format(build_main=build_main, - srcdir=self.source_dir, - sys_path_inserts=sys_path_inserts, - builders=builders, - argv=argv, - output_dir=os.path.abspath(self.build_dir)) + srcdir=self.source_dir, + sys_path_inserts=sys_path_inserts, + builders=builders, + argv=argv, + output_dir=os.path.abspath(self.build_dir)) log.debug('Starting subprocess of {0} with python code:\n{1}\n' '[CODE END])'.format(sys.executable, subproccode)) From 4387661276cb4df9d56d905632a0d959dd3194dc Mon Sep 17 00:00:00 2001 From: Thomas Robitaille Date: Wed, 13 Nov 2019 09:56:14 +0000 Subject: [PATCH 06/12] Simplify code to make sure sphinx-astropy is installed --- astropy_helpers/commands/build_sphinx.py | 29 +++++++----------------- 1 file changed, 8 insertions(+), 21 deletions(-) diff --git a/astropy_helpers/commands/build_sphinx.py b/astropy_helpers/commands/build_sphinx.py index 3abbea38..e2d6eaef 100644 --- a/astropy_helpers/commands/build_sphinx.py +++ b/astropy_helpers/commands/build_sphinx.py @@ -31,25 +31,17 @@ def ensure_sphinx_astropy_installed(): """ Make sure that sphinx-astropy is available. - - This returns the available version of sphinx-astropy as well as any - paths that should be added to sys.path for sphinx-astropy to be available. """ - # We've split out the Sphinx part of astropy-helpers into sphinx-astropy - # but we want it to be auto-installed seamlessly for anyone using - # build_docs. We check if it's already installed, and if not, we install - # it to a local .eggs directory and add the eggs to the path (these - # have to each be added to the path, we can't add them by simply adding - # .eggs to the path) - sys_path_inserts = [] - sphinx_astropy_version = None + try: from sphinx_astropy import __version__ as sphinx_astropy_version # noqa except ImportError: - raise ImportError("sphinx-astropy 1.2 or later needs to be installed to build " - "the documentation.") + sphinx_astropy_version = None - return sphinx_astropy_version, sys_path_inserts + if (sphinx_astropy_version is None + or LooseVersion(sphinx_astropy_version) <= LooseVersion('1.2')): + raise ImportError("sphinx-astropy 1.2 or later needs to be installed to build " + "the documentation.") class AstropyBuildDocs(SphinxBuildDoc): @@ -154,14 +146,9 @@ def run(self): build_main = 'from sphinx.cmd.build import build_main' # We need to make sure sphinx-astropy is installed - sphinx_astropy_version, extra_paths = ensure_sphinx_astropy_installed() - - # Require sphinx-astropy 1.2 which also enforces a requirement of sphinx>=1.7 - if LooseVersion(sphinx_astropy_version) <= LooseVersion('1.2'): - raise ImportError("sphinx-astropy 1.2 or later needs to be installed to build " - "the documentation.") + ensure_sphinx_astropy_installed() - sys_path_inserts = [build_cmd_path, ah_path] + extra_paths + sys_path_inserts = [build_cmd_path, ah_path] sys_path_inserts = os.linesep.join(['sys.path.insert(0, {0!r})'.format(path) for path in sys_path_inserts]) argv = [] From 6ee513bdf9745071a92a0fae8a6543322215314c Mon Sep 17 00:00:00 2001 From: Thomas Robitaille Date: Wed, 13 Nov 2019 09:59:29 +0000 Subject: [PATCH 07/12] Make sure we specify to use the astropy conda channel for sphinx-astropy and switch to Travis CI for Windows builds. Also fix version comparison in build_docs. --- .travis.yml | 2 ++ appveyor.yml | 46 ------------------------ astropy_helpers/commands/build_sphinx.py | 2 +- 3 files changed, 3 insertions(+), 47 deletions(-) delete mode 100644 appveyor.yml diff --git a/.travis.yml b/.travis.yml index 6cafc851..634978fc 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,6 +4,7 @@ language: c os: + - windows - osx - linux @@ -22,6 +23,7 @@ env: - PIP_DEPENDENCIES="codecov" - EVENT_TYPE='push pull_request' - DEBUG=True + - CONDA_CHANNELS="astropy" matrix: include: diff --git a/appveyor.yml b/appveyor.yml deleted file mode 100644 index 056546a3..00000000 --- a/appveyor.yml +++ /dev/null @@ -1,46 +0,0 @@ -# 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-astropy pytest babel!=2.0 setuptools pytest-cov" - PIP_DEPENDENCIES: "codecov" - - matrix: - - 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" diff --git a/astropy_helpers/commands/build_sphinx.py b/astropy_helpers/commands/build_sphinx.py index e2d6eaef..8beb1dcc 100644 --- a/astropy_helpers/commands/build_sphinx.py +++ b/astropy_helpers/commands/build_sphinx.py @@ -39,7 +39,7 @@ def ensure_sphinx_astropy_installed(): sphinx_astropy_version = None if (sphinx_astropy_version is None - or LooseVersion(sphinx_astropy_version) <= LooseVersion('1.2')): + or LooseVersion(sphinx_astropy_version) < LooseVersion('1.2')): raise ImportError("sphinx-astropy 1.2 or later needs to be installed to build " "the documentation.") From 31c70cd33aef41d9d1fc623db66056f78eef7e0e Mon Sep 17 00:00:00 2001 From: Thomas Robitaille Date: Wed, 13 Nov 2019 12:15:30 +0000 Subject: [PATCH 08/12] Install sphinx-astropy with pip on Windows --- .travis.yml | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 634978fc..774bcb59 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,7 +4,6 @@ language: c os: - - windows - osx - linux @@ -27,6 +26,7 @@ env: 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 @@ -37,11 +37,23 @@ matrix: 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 sphinx-astropy" 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-astropy cython pytest-cov' + # Windows builds - for now we need to install sphinx-astropy with pip since + # there is not a recent enough version of graphviz according to conda on Windows + - os: windows + env: PYTHON_VERSION=3.6 + CONDA_DEPENDENCIES="setuptools cython numpy pytest-cov" + PIP_DEPENDENCIES="codecov sphinx-astropy" + - os: windows + env: PYTHON_VERSION=3.7 + CONDA_DEPENDENCIES="setuptools cython numpy pytest-cov" + PIP_DEPENDENCIES="codecov sphinx-astropy" + # Test conda's clang - os: osx env: From 36e20455f5249622d8e52060e0083965b33652aa Mon Sep 17 00:00:00 2001 From: Thomas Robitaille Date: Wed, 13 Nov 2019 13:25:03 +0000 Subject: [PATCH 09/12] Fix gcc build --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 774bcb59..295549ea 100644 --- a/.travis.yml +++ b/.travis.yml @@ -65,7 +65,7 @@ matrix: # Test gcc on OSX - os: osx env: - - PYTHON_VERSION=3.7 + - PYTHON_VERSION=3.6 - CONDA_DEPENDENCIES="setuptools sphinx-astropy cython numpy pytest-cov gcc" - OPENMP_EXPECTED=True - CCOMPILER=gcc From 50f2fdb65d2859c38d2a70a2fe10462beb9f39ac Mon Sep 17 00:00:00 2001 From: Thomas Robitaille Date: Wed, 13 Nov 2019 14:20:16 +0000 Subject: [PATCH 10/12] Add conda-forge for MacOS X gcc build --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 295549ea..72d4763b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -68,6 +68,7 @@ matrix: - PYTHON_VERSION=3.6 - CONDA_DEPENDENCIES="setuptools sphinx-astropy cython numpy pytest-cov gcc" - OPENMP_EXPECTED=True + - CONDA_CHANNELS="astropy conda-forge" - CCOMPILER=gcc # Uncomment the following if there are issues in setuptools that we From 55219ec56d617071a08e15e55098742666337b64 Mon Sep 17 00:00:00 2001 From: Thomas Robitaille Date: Sun, 17 Nov 2019 21:41:19 +0000 Subject: [PATCH 11/12] Only use CONDA_CHANNELS='astropy' when needed --- .travis.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 72d4763b..db3f98f0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -22,7 +22,6 @@ env: - PIP_DEPENDENCIES="codecov" - EVENT_TYPE='push pull_request' - DEBUG=True - - CONDA_CHANNELS="astropy" matrix: include: @@ -36,12 +35,13 @@ matrix: - 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 sphinx-astropy" - EVENT_TYPE='push pull_request cron' + EVENT_TYPE='push pull_request cron' CONDA_CHANNELS="astropy" # 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-astropy cython pytest-cov' + CONDA_CHANNELS="astropy" # Windows builds - for now we need to install sphinx-astropy with pip since # there is not a recent enough version of graphviz according to conda on Windows @@ -59,6 +59,7 @@ matrix: env: - PYTHON_VERSION=3.7 - CONDA_DEPENDENCIES="setuptools sphinx-astropy cython numpy pytest-cov clang llvm-openmp matplotlib" + - CONDA_CHANNELS="astropy" - OPENMP_EXPECTED=True - CCOMPILER=clang @@ -67,6 +68,7 @@ matrix: env: - PYTHON_VERSION=3.6 - CONDA_DEPENDENCIES="setuptools sphinx-astropy cython numpy pytest-cov gcc" + - CONDA_CHANNELS="astropy" - OPENMP_EXPECTED=True - CONDA_CHANNELS="astropy conda-forge" - CCOMPILER=gcc From 7cd8ca8a13a78b19ce6f3699a4a05d032184b328 Mon Sep 17 00:00:00 2001 From: Thomas Robitaille Date: Sun, 17 Nov 2019 21:41:28 +0000 Subject: [PATCH 12/12] Added changelog entry for minimum sphinx version --- CHANGES.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGES.rst b/CHANGES.rst index afe37361..8840e6f3 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -6,6 +6,8 @@ astropy-helpers Changelog - Changed minimum required Python version to 3.6. [#498] +- Changed minimum required Sphinx version to 1.7. [#498] + - Added a --parallel option for build_docs. [#498]