Skip to content

Commit

Permalink
Enforce minimum Python 3.5
Browse files Browse the repository at this point in the history
  • Loading branch information
mperrin committed Sep 18, 2018
1 parent 94db425 commit 83ba201
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 16 deletions.
15 changes: 5 additions & 10 deletions docs/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,12 @@ latest development version from git::
Requirements
--------------

* Either Python 2.7 or Python 3.4. (Under :ref:`certain circumstances on Mac
OS <accelerated_multiprocessing>`, Python 3.4 is required if you want
parallelized calculations, but otherwise POPPY functionality is identical on
both versions.)
* Python 3.5, or more recent. Earlier versions of Python are no longer supported.
* The standard Python scientific stack: :py:mod:`numpy`, :py:mod:`scipy`,
:py:mod:`matplotlib`
* POPPY relies upon the `astropy
<http://www.astropy.org>`__ community-developed core library for astronomy.
astropy, version 1.0.1 or more recent, is needed.
astropy, version 1.3 or more recent, is needed.

The following are *optional*. The first, :py:mod:`pysynphot`, is recommended
for most users. The other optional installs are only worth adding for speed
Expand Down Expand Up @@ -82,13 +79,11 @@ that your installation is working properly::
>>> import poppy
>>> poppy.test()
============================ test session starts =====================================
platform darwin -- Python 2.7.8 -- pytest-2.5.1
Running tests with Astropy version 0.4.1.
Python 3.6.5, pytest-3.6.1, py-1.5.3, pluggy-0.6.0
Running tests with Astropy version 3.0.3.
... [etc] ...
================= 66 passed, 1 skipped, 1 xfailed in 124.68 seconds ==================
================= 126 passed, 1 skipped, 1 xfailed in 524.68 seconds ==================

Some tests may be automatically skipped depending on whether certain optional packaged are
installed, and other tests in development may be marked "expected to fail" (``xfail``), but
as long as no tests actually fail then your installation is working as expected.
(Note that you will need to run the test suite using a plain python interpreter, not
inside an IPython or Jupyter session.)
13 changes: 10 additions & 3 deletions poppy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,18 @@
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

import astropy as _astropy
__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("poppy does not support Python < {}".format(__minimum_python_version__))

if _astropy.version.major + _astropy.version.minor * 0.1 < 0.4: # pragma: no cover
raise ImportError("astropy >= 0.4 is required for this version of poppy.")

from astropy import config as _config

Expand Down
13 changes: 10 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,15 @@
import imp
import ast


__minimum_python_version__ = "3.5"

# Enforce Python version check - this is the same check as in __init__.py but
# this one has to happen before importing ah_bootstrap.
if sys.version_info < tuple((int(val) for val in __minimum_python_version__.split('.'))):
sys.stderr.write("ERROR: poppy requires Python {} or later\n".format(__minimum_python_version__))
sys.exit(1)

try:
import numpy
except ImportError:
Expand Down Expand Up @@ -116,14 +125,12 @@
'astropy>=1.3',
]

# Python 3.4.x backports
if sys.version_info[:2] < (3, 4):
install_requires_packages.append('enum34>=1.0.4')

setup(name=PACKAGENAME,
version=VERSION,
description=DESCRIPTION,
scripts=scripts,
python_requires='>=' + __minimum_python_version__,
install_requires=install_requires_packages,
provides=[PACKAGENAME],
author=AUTHOR,
Expand Down

0 comments on commit 83ba201

Please sign in to comment.