Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: paylogic/py2deb
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 2.0
Choose a base ref
...
head repository: paylogic/py2deb
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 2.1
Choose a head ref
  • 2 commits
  • 6 files changed
  • 1 contributor

Commits on Dec 16, 2018

  1. Verified

    This commit was signed with the committer’s verified signature.
    denis256 Denis O
    Copy the full SHA
    55526e4 View commit details
  2. Copy the full SHA
    5e144e4 View commit details
Showing with 49 additions and 14 deletions.
  1. +14 −0 CHANGELOG.rst
  2. +2 −2 py2deb/__init__.py
  3. +14 −2 py2deb/converter.py
  4. +4 −2 py2deb/package.py
  5. +5 −2 py2deb/tests.py
  6. +10 −6 py2deb/utils.py
14 changes: 14 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -11,6 +11,20 @@ to `semantic versioning`_.
.. _Keep a Changelog: http://keepachangelog.com/
.. _semantic versioning: http://semver.org/

`Release 2.1`_ (2018-12-16)
---------------------------

Enable optional backwards compatibility with the old version number conversion
up to :ref:`release 0.25` in which pre-release identifiers didn't receive any
special treatment.

My reason for adding this backwards compatibility now is that it will allow me
to upgrade py2deb on the build server of my employer to the latest version
without being forced to switch to the new version number format at the same
time. This simplifies the transition significantly.

.. _Release 2.1: https://github.com/paylogic/py2deb/compare/2.0...2.1

`Release 2.0`_ (2018-11-18)
---------------------------

4 changes: 2 additions & 2 deletions py2deb/__init__.py
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@
# Authors:
# - Arjan Verwer
# - Peter Odding <peter.odding@paylogic.com>
# Last Change: November 18, 2018
# Last Change: December 16, 2018
# URL: https://py2deb.readthedocs.io

"""
@@ -15,4 +15,4 @@
"""

# Semi-standard module versioning.
__version__ = '2.0'
__version__ = '2.1'
16 changes: 14 additions & 2 deletions py2deb/converter.py
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@
# Authors:
# - Arjan Verwer
# - Peter Odding <peter.odding@paylogic.com>
# Last Change: November 18, 2018
# Last Change: December 16, 2018
# URL: https://py2deb.readthedocs.io

"""
@@ -212,6 +212,18 @@ def name_prefix(self):
"""
return default_name_prefix()

@mutable_property
def prerelease_workaround(self):
"""
Whether to enable the pre-release workaround in :func:`normalize_package_version()` (a boolean).
By setting this to :data:`False` converted version numbers will match
those generated by py2deb 0.25 and earlier. Release 1.0 introduced the
pre-release workaround and release 2.1 added the option to control
backwards compatibility in this respect.
"""
return True

@mutable_property
def python_callback(self):
"""
@@ -908,4 +920,4 @@ def transform_version(self, package_to_convert, python_requirement_name, python_
python_requirement_name, package_to_convert.python_name,
python_requirement_version, modified_version)
python_requirement_version = modified_version
return normalize_package_version(python_requirement_version)
return normalize_package_version(python_requirement_version, prerelease_workaround=self.prerelease_workaround)
6 changes: 4 additions & 2 deletions py2deb/package.py
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@
# Authors:
# - Arjan Verwer
# - Peter Odding <peter.odding@paylogic.com>
# Last Change: November 18, 2018
# Last Change: December 16, 2018
# URL: https://py2deb.readthedocs.io

"""
@@ -126,7 +126,9 @@ def debian_version(self):
Reformats :attr:`python_version` using
:func:`.normalize_package_version()`.
"""
return normalize_package_version(self.python_version)
return normalize_package_version(
self.python_version, prerelease_workaround=self.converter.prerelease_workaround
)

@cached_property
def debian_maintainer(self):
7 changes: 5 additions & 2 deletions py2deb/tests.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Automated tests for the `py2deb' package.
#
# Author: Peter Odding <peter.odding@paylogic.com>
# Last Change: November 18, 2018
# Last Change: December 16, 2018
# URL: https://py2deb.readthedocs.io

"""
@@ -156,11 +156,14 @@ def test_version_reformatting(self):
"""Test reformatting of Python version strings."""
assert normalize_package_version('1.5_42') == '1.5-42'
assert normalize_package_version('1.5-whatever') == '1.5-whatever-1'
# PEP 440 pre-release versions.
# PEP 440 pre-release versions (specific handling added in release 1.0).
assert normalize_package_version('1.0a2') == '1.0~a2'
assert normalize_package_version('1.0b2') == '1.0~b2'
assert normalize_package_version('1.0c2') == '1.0~rc2'
assert normalize_package_version('1.0rc2') == '1.0~rc2'
# New versus old behavior (the option to control backwards compatibility was added in release 2.1).
assert normalize_package_version('1.0a2', prerelease_workaround=True) == '1.0~a2'
assert normalize_package_version('1.0a2', prerelease_workaround=False) == '1.0a2'

def test_conversion_of_simple_package(self):
"""
16 changes: 10 additions & 6 deletions py2deb/utils.py
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@
# Authors:
# - Arjan Verwer
# - Peter Odding <peter.odding@paylogic.com>
# Last Change: November 18, 2018
# Last Change: December 16, 2018
# URL: https://py2deb.readthedocs.io

"""The :mod:`py2deb.utils` module contains miscellaneous code."""
@@ -346,11 +346,14 @@ def normalize_package_name(python_package_name):
return re.sub('[^a-z0-9]+', '-', python_package_name.lower()).strip('-')


def normalize_package_version(python_package_version):
def normalize_package_version(python_package_version, prerelease_workaround=True):
"""
Normalize Python package version to be used as Debian package version.
:param python_package_version: The version of a Python package (a string).
:param prerelease_workaround: :data:`True` to enable the pre-release
handling documented below, :data:`False` to
restore the old behavior.
Reformats Python package versions to comply with the Debian policy manual.
All characters except alphanumerics, dot (``.``) and plus (``+``) are
@@ -363,10 +366,11 @@ def normalize_package_version(python_package_version):
"""
# Lowercase and remove invalid characters from the version string.
version = re.sub('[^a-z0-9.+]+', '-', python_package_version.lower()).strip('-')
# Translate the PEP 440 pre-release identifier 'c' to 'rc'.
version = re.sub(r'(\d)c(\d)', r'\1rc\2', version)
# Replicate the intended ordering of PEP 440 pre-release versions (a, b, rc).
version = re.sub(r'(\d)(a|b|rc)(\d)', r'\1~\2\3', version)
if prerelease_workaround:
# Translate the PEP 440 pre-release identifier 'c' to 'rc'.
version = re.sub(r'(\d)c(\d)', r'\1rc\2', version)
# Replicate the intended ordering of PEP 440 pre-release versions (a, b, rc).
version = re.sub(r'(\d)(a|b|rc)(\d)', r'\1~\2\3', version)
# Make sure the "Debian revision" contains a digit.
components = version.split('-')
if len(components) > 1 and not re.search('[0-9]', components[-1]):