Skip to content

Commit

Permalink
Up version to 3.1.dev0 (Python-Markdown#736)
Browse files Browse the repository at this point in the history
Update version format to be PEP 440 compliant in preparation for Python-Markdown#732.

Add `pyproject.toml` file and configure tox to use it. Define requirement for `setuptools>=36` which validates and normalizes the version format.
  • Loading branch information
waylan authored Oct 21, 2018
1 parent 9d73d7b commit b431bbb
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 19 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ addons:
- aspell-en

install:
- pip install 'setuptools>=36'
- pip install tox
- pip install 'coverage<4.0'
- pip install codecov
Expand Down
34 changes: 20 additions & 14 deletions markdown/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
4 changes: 4 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[build-system]
# Minimum requirements for the build system to execute.
requires = ["setuptools>=36", "wheel"]
build-backend = "setuptools.build_meta"
7 changes: 3 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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").
Expand Down Expand Up @@ -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,
Expand Down
7 changes: 6 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
@@ -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

Expand Down

0 comments on commit b431bbb

Please sign in to comment.