diff --git a/.travis.yml b/.travis.yml index 01bdbd682..c050aced8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -30,6 +30,7 @@ addons: - aspell-en install: + - pip install 'setuptools>=36' - pip install tox - pip install 'coverage<4.0' - pip install codecov diff --git a/markdown/__init__.py b/markdown/__init__.py index 80434e96c..b39202d6b 100644 --- a/markdown/__init__.py +++ b/markdown/__init__.py @@ -23,36 +23,42 @@ from __future__ import absolute_import from __future__ import unicode_literals from .core import Markdown, markdown, markdownFromFile +from pkg_resources.extern import packaging # For backward compatibility as some extensions expect it... from .extensions import Extension # noqa __all__ = ['Markdown', 'markdown', 'markdownFromFile'] -# version_info should conform to PEP 386 -# (major, minor, micro, alpha/beta/rc/final, #) -# (1, 1, 2, 'alpha', 0) => "1.1.2.dev" +# version must conform to PEP 440 +# https://www.python.org/dev/peps/pep-0440/ + +# __version_info__ format: +# (major, minor, patch, dev/alpha/beta/rc/final, #) +# (1, 1, 2, 'dev', 0) => "1.1.2.dev0" +# (1, 1, 2, 'alpha', 1) => "1.1.2a1" # (1, 2, 0, 'beta', 2) => "1.2b2" -__version_info__ = (3, 0, 1, 'final', 0) +# (1, 2, 0, 'rc', 4) => "1.2rc4" +# (1, 2, 0, 'final', 0) => "1.2" +__version_info__ = (3, 1, 0, 'dev', 0) def _get_version(): # pragma: no cover - " Returns a PEP 386-compliant version number from version_info. " + " Returns a PEP 440-compliant version number from version_info. " assert len(__version_info__) == 5 - assert __version_info__[3] in ('alpha', 'beta', 'rc', 'final') + assert __version_info__[3] in ('dev', 'alpha', 'beta', 'rc', 'final') parts = 2 if __version_info__[2] == 0 else 3 - main = '.'.join(map(str, __version_info__[:parts])) + v = '.'.join(map(str, __version_info__[:parts])) - sub = '' - if __version_info__[3] == 'alpha' and __version_info__[4] == 0: - # TODO: maybe append some sort of git info here?? - sub = '.dev' + if __version_info__[3] == 'dev': + v += '.dev' + str(__version_info__[4]) elif __version_info__[3] != 'final': - mapping = {'alpha': 'a', 'beta': 'b', 'rc': 'c'} - sub = mapping[__version_info__[3]] + str(__version_info__[4]) + mapping = {'alpha': 'a', 'beta': 'b', 'rc': 'rc'} + v += mapping[__version_info__[3]] + str(__version_info__[4]) - return str(main + sub) + # Ensure version is valid and normalized + return str(packaging.version.Version(v)) __version__ = _get_version() diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 000000000..a1d0683e2 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,4 @@ +[build-system] +# Minimum requirements for the build system to execute. +requires = ["setuptools>=36", "wheel"] +build-backend = "setuptools.build_meta" diff --git a/setup.py b/setup.py index f906389f4..938defa20 100755 --- a/setup.py +++ b/setup.py @@ -28,15 +28,13 @@ # Get development Status for classifiers dev_status_map = { + 'dev': '2 - Pre-Alpha', 'alpha': '3 - Alpha', 'beta': '4 - Beta', 'rc': '4 - Beta', 'final': '5 - Production/Stable' } -if __version_info__[3] == 'alpha' and __version_info__[4] == 0: - DEVSTATUS = '2 - Pre-Alpha' -else: - DEVSTATUS = dev_status_map[__version_info__[3]] +DEVSTATUS = dev_status_map[__version_info__[3]] # The command line script name. Currently set to "markdown_py" so as not to # conflict with the perl implimentation (which uses "markdown"). @@ -79,6 +77,7 @@ license='BSD License', packages=['markdown', 'markdown.extensions'], python_requires='>=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*', + install_requires=['setuptools >= 36'], entry_points={ 'console_scripts': [ '%s = markdown.__main__:run' % SCRIPT_NAME, diff --git a/tox.ini b/tox.ini index 42cdd50c3..0e130aebf 100644 --- a/tox.ini +++ b/tox.ini @@ -1,8 +1,13 @@ [tox] envlist = py27, py34, py35, py36, py37, pypy, pypy3, flake8, checkspelling +requires = setuptools>=36 +isolated_build = True [testenv] -deps = -rtest-requirements.txt +deps = + coverage<4.0 + pyyaml + pytidylib commands = coverage run --source=markdown -m unittest discover {toxinidir}/tests coverage report --show-missing