Skip to content
This repository has been archived by the owner on Aug 11, 2023. It is now read-only.

Commit

Permalink
Explicitly ask for minimum supported Python version
Browse files Browse the repository at this point in the history
  • Loading branch information
astrofrog committed Apr 11, 2018
1 parent ec36c77 commit 24d246e
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 14 deletions.
3 changes: 1 addition & 2 deletions QUESTIONS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,4 @@ a description of each of the prompts.
15. ``use_appveyor_ci``: If 'y' the template will include an example ``appveyor.yml`` file for the Appveyor CI service.
16. ``use_read_the_docs``: If 'y' the ``read_the_docs.yml`` and ``.rtd-environment.yml`` files will be included for using conda on Read the Docs.
17. ``sphinx_theme``: The value of the ``html_theme`` variable in the sphinx configuration file.
18. ``support_python2``: If 'y' the template will include the Python 2 compatible ``astropy_helpers`` LTS version, otherwise it uses the latest one.
19. ``minimum_python_version``: Version string of minimum supported Python version. For example, "3.5" or "2.7". Leave as "" to skip this check.
18. ``minimum_python_version``: Version string of minimum supported Python version
5 changes: 2 additions & 3 deletions cookiecutter.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
"_copy_without_render": [
"docs/_templates"
],
"support_python2": "n",
"astropy_helpers_version": "{% if cookiecutter.support_python2 == 'y' %}v2.0.6{% else %}v3.0.1{% endif %}",
"minimum_python_version": "{% if cookiecutter.support_python2 == 'n'%}3.5{% endif %}"
"minimum_python_version": ["2.7", "3.5", "3.6"],
"astropy_helpers_version": "{% if cookiecutter.minimum_python_version == '2.7' %}v2.0.6{% else %}v3.0.1{% endif %}"
}
9 changes: 2 additions & 7 deletions {{ cookiecutter.package_name }}/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,11 @@
import os
import sys

# Enforce Python version check during package import.
# This is the same check as packagename/__init__.py but this one has to
# happen before importing ah_bootstrap.
{% if cookiecutter.minimum_python_version %}
# 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 "{{ cookiecutter.minimum_python_version }}".split('.'))):
sys.stderr.write("ERROR: {{ cookiecutter.module_name }} requires Python {} or later\n".format({{ cookiecutter.minimum_python_version }}))
sys.exit(1)
{% endif %}

import ah_bootstrap
from setuptools import setup
Expand Down Expand Up @@ -145,8 +142,6 @@
zip_safe=False,
use_2to3=False,
entry_points=entry_points,
{% if cookiecutter.minimum_python_version %}
python_requires='>={}'.format({{ cookiecutter.minimum_python_version }}),
{% endif %}
**package_info
)
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@

# Enforce Python version check during package import.
# This is the same check as the one at the top of setup.py
{% if cookiecutter.minimum_python_version %}
import sys

class UnsupportedPythonError(Exception):
pass

if sys.version_info < tuple((int(val) for val in "{{ cookiecutter.minimum_python_version }}".split('.'))):
raise UnsupportedPythonError("{{ cookiecutter.module_name }} does not support Python < {}".format({{ cookiecutter.minimum_python_version }}))
{% endif %}

if not _ASTROPY_SETUP_:
# For egg_info test builds to pass, put package imports here.
Expand Down

0 comments on commit 24d246e

Please sign in to comment.