Skip to content

Commit

Permalink
Drop support for Python 2 (#63)
Browse files Browse the repository at this point in the history
Signed-off-by: Thomas Druez <[email protected]>
  • Loading branch information
tdruez authored Oct 5, 2021
1 parent fe770b1 commit 255e232
Show file tree
Hide file tree
Showing 25 changed files with 857 additions and 224 deletions.
9 changes: 5 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
language: python

python:
- "2.7"
- "3.6"
- "3.7"
- "3.8"
- "3.9"

install:
- virtualenv .
- bin/pip install -r requirements_tests.txt
- python thirdparty/virtualenv.pyz --never-download --no-periodic-update .
- bin/pip install -e .[test]

script:
- bin/py.test -vvs
- bin/isort --check-only src/ tests/
- bin/py.test -vvs
1 change: 1 addition & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Changelog
0.9.6 (2021-10-05)
------------------

- Drop support for Python 2 #61
- Add support for new github URLs in url2purl #47

0.9.5 (2021-10-04)
Expand Down
17 changes: 7 additions & 10 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# packageurl-python

A parser and builder for purl aka. Package URLs for Python 2 and 3.
Python library to parse and build "purl" aka. Package URLs.
See https://github.com/package-url/purl-spec for details.

Join the discussion at https://gitter.im/package-url/Lobby or enter a ticket for support.
Expand Down Expand Up @@ -50,45 +50,42 @@ Install

pip install packageurl-python



Run tests
=========

install::

python -m venv .
bin/pip install -r requirements_tests.txt
python3 thirdparty/virtualenv.pyz --never-download --no-periodic-update .
bin/pip install -e ."[test]"

run tests::

bin/py.test tests


Make a new release
==================

- start a new release branch
- update the CHANGELOG.rst and AUTHORS.rst
- update README.rst if needed
- bump version in setup.py
- bump version in setup.cfg
- run all tests
- install restview and validate that all .rst docs are correct
- commit and push this branch
- tag and push that tag
- make a PR to merge branch
- once merged, run::

pip install --upgrade pip wheel twine setuptools
bin/pip install --upgrade pip wheel twine setuptools

- delete the "dist" and "build" directories::

rm -rf dist/ build/

- create a source distribution and wheel with::

python setup.py sdist bdist_wheel
bin/python setup.py sdist bdist_wheel

- finally, upload to PyPI::

twine upload dist/*
bin/twine upload dist/*
2 changes: 0 additions & 2 deletions requirements_tests.txt

This file was deleted.

58 changes: 48 additions & 10 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,16 +1,57 @@
[bdist_wheel]
universal = 1

[metadata]
name = packageurl-python
version = 0.9.5
license = MIT
description = A purl aka. Package URL parser and builder
long_description = file:README.rst
author = the purl authors
url = https://github.com/package-url/packageurl-python
classifiers =
Development Status :: 4 - Beta
Intended Audience :: Developers
License :: OSI Approved :: MIT License
Operating System :: OS Independent
Programming Language :: Python
Programming Language :: Python :: 3 :: Only
Programming Language :: Python :: 3.6
Programming Language :: Python :: 3.7
Programming Language :: Python :: 3.8
Programming Language :: Python :: 3.9
Topic :: Software Development :: Libraries
Topic :: Utilities
keywords =
package
url
package manager
package url
license_files =
- mit.LICENSE
- AUTHORS.rst
- README.rst
- CONTRIBUTING.rst
- CHANGELOG.rst

[aliases]
release = clean --all sdist bdist_wheel
[options]
python_requires = >=3.6
packages = find:
package_dir = =src
include_package_data = true
zip_safe = false
install_requires =

[options.packages.find]
where = src

[options.extras_require]
test =
pytest
isort

[isort]
force_single_line = True
line_length = 88
known_django = django
sections = FUTURE,STDLIB,DJANGO,THIRDPARTY,FIRSTPARTY,LOCALFOLDER

[tool:pytest]
norecursedirs =
Expand All @@ -35,14 +76,11 @@ norecursedirs =
thirdparty
tmp
src/packageurl/contrib

python_files = *.py

python_classes=Test
python_functions=test

addopts =
-rfEsxXw
--strict
-rfExXw
--strict-markers
--ignore setup.py
--doctest-modules
42 changes: 3 additions & 39 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,43 +3,7 @@

# SPDX-License-Identifier: MIT

from __future__ import absolute_import
from __future__ import print_function
import setuptools

from glob import glob
from os.path import basename
from os.path import splitext

from setuptools import find_packages
from setuptools import setup

setup(
name='packageurl-python',
version='0.9.5',
license='MIT',
description='A "purl" aka. Package URL parser and builder',
long_description='Python library to parse and build "purl" aka. Package URLs. '
'This is a microlibrary implementing the purl spec at https://github.com/package-url',
author='the purl authors',
url='https://github.com/package-url/packageurl-python',
packages=find_packages('src'),
package_dir={'': 'src'},
py_modules=[splitext(basename(path))[0] for path in glob('src/*.py')],
include_package_data=True,
zip_safe=False,
platforms='any',
keywords='package, url, package manager, package url',
classifiers=[
'Development Status :: 4 - Beta',
'Intended Audience :: Developers',
'License :: OSI Approved :: MIT License',
'Operating System :: OS Independent',
'Programming Language :: Python',
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.6',
'Topic :: Software Development :: Libraries',
'Topic :: Utilities',
],
)
if __name__ == "__main__":
setuptools.setup()
44 changes: 10 additions & 34 deletions src/packageurl/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,39 +24,15 @@
# Visit https://github.com/package-url/packageurl-python for support and
# download.


from __future__ import absolute_import
from __future__ import print_function
from __future__ import unicode_literals

from collections import namedtuple
from collections import OrderedDict
import string
from collections import namedtuple
from urllib.parse import quote as _percent_quote
from urllib.parse import unquote as _percent_unquote
from urllib.parse import urlsplit as _urlsplit

# Python 2 and 3 support
try:
# Python 2
from urlparse import urlsplit as _urlsplit
from urllib import quote as _percent_quote
from urllib import unquote as _percent_unquote
except ImportError:
# Python 3
from urllib.parse import urlsplit as _urlsplit
from urllib.parse import quote as _percent_quote
from urllib.parse import unquote as _percent_unquote

# Python 2 and 3 support
try:
# Python 2
unicode # NOQA
basestring = basestring # NOQA
bytes = str # NOQA
str = unicode # NOQA
except NameError:
# Python 3
unicode = str # NOQA
basestring = (bytes, str,) # NOQA
OrderedDict = dict
# Python 3
unicode = str # NOQA
basestring = (bytes, str,) # NOQA

"""
A purl (aka. Package URL) implementation as specified at:
Expand Down Expand Up @@ -161,7 +137,7 @@ def normalize_qualifiers(qualifiers, encode=True): # NOQA
Raise ValueError on errors.
"""
if not qualifiers:
return None if encode else OrderedDict()
return None if encode else dict()

if isinstance(qualifiers, basestring):
if not isinstance(qualifiers, unicode):
Expand Down Expand Up @@ -208,7 +184,7 @@ def normalize_qualifiers(qualifiers, encode=True): # NOQA
"A qualifier key cannot start with a number: {}".format(repr(key)))

qualifiers = sorted(qualifiers.items())
qualifiers = OrderedDict(qualifiers)
qualifiers = dict(qualifiers)
if encode:
qualifiers = ['{}={}'.format(k, v) for k, v in qualifiers.items()]
qualifiers = '&'.join(qualifiers)
Expand Down Expand Up @@ -306,7 +282,7 @@ def to_dict(self, encode=False, empty=None):
string. Otherwise, qualifiers is a mapping.
You can provide a value for `empty` to be used in place of default None.
"""
data = OrderedDict(self._asdict())
data = self._asdict()
if encode:
data['qualifiers'] = normalize_qualifiers(self.qualifiers, encode=encode)

Expand Down
5 changes: 0 additions & 5 deletions src/packageurl/contrib/django/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,6 @@
# Visit https://github.com/package-url/packageurl-python for support and
# download.


from __future__ import absolute_import
from __future__ import print_function
from __future__ import unicode_literals

import django_filters


Expand Down
5 changes: 0 additions & 5 deletions src/packageurl/contrib/django/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,6 @@
# Visit https://github.com/package-url/packageurl-python for support and
# download.


from __future__ import absolute_import
from __future__ import print_function
from __future__ import unicode_literals

from django.core.exceptions import ValidationError
from django.db import models
from django.utils.translation import gettext_lazy as _
Expand Down
40 changes: 0 additions & 40 deletions src/packageurl/contrib/django_models.py

This file was deleted.

8 changes: 1 addition & 7 deletions src/packageurl/contrib/purl2url.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,9 @@
# Visit https://github.com/package-url/packageurl-python for support and
# download.


from __future__ import absolute_import
from __future__ import print_function
from __future__ import unicode_literals

from packageurl import PackageURL
from packageurl.contrib.route import Router
from packageurl.contrib.route import NoRouteAvailable

from packageurl.contrib.route import Router

router = Router()

Expand Down
Loading

0 comments on commit 255e232

Please sign in to comment.