diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e78e52c..541d254 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -9,7 +9,7 @@ jobs: timeout-minutes: 5 steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Setup Python environment uses: actions/setup-python@v4 @@ -43,7 +43,7 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Setup Python environment uses: actions/setup-python@v4 diff --git a/.github/workflows/pypi-release.yml b/.github/workflows/pypi-release.yml index 22315ff..bef15b1 100644 --- a/.github/workflows/pypi-release.yml +++ b/.github/workflows/pypi-release.yml @@ -1,6 +1,5 @@ name: Create library release archives, create a GH release and publish PyPI wheel and sdist on tag in main branch - # This is executed automatically on a tag in the main branch # Summary of the steps: @@ -21,14 +20,15 @@ on: jobs: build-pypi-distribs: name: Build and publish library to PyPI - runs-on: ubuntu-20.04 + runs-on: ubuntu-22.04 steps: - - uses: actions/checkout@master + - uses: actions/checkout@v4 + - name: Set up Python - uses: actions/setup-python@v1 + uses: actions/setup-python@v4 with: - python-version: 3.9 + python-version: 3.11 - name: Install pypa/build run: python -m pip install build --user @@ -42,12 +42,11 @@ jobs: name: pypi_archives path: dist/* - create-gh-release: name: Create GH release needs: - build-pypi-distribs - runs-on: ubuntu-20.04 + runs-on: ubuntu-22.04 steps: - name: Download built archives @@ -62,12 +61,11 @@ jobs: draft: true files: dist/* - create-pypi-release: name: Create PyPI release needs: - create-gh-release - runs-on: ubuntu-20.04 + runs-on: ubuntu-22.04 steps: - name: Download built archives diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 61c4d63..4733872 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -1,6 +1,12 @@ Changelog ========= +0.11.3 (2023-12-08) +-------------------- + +- Add support for GitLab "/archive/" URLs in `url2purl`. + https://github.com/package-url/packageurl-python/issues/133 + 0.11.2 (2022-07-25) -------------------- diff --git a/MANIFEST.in b/MANIFEST.in index bafcaa2..1ae2c64 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -5,6 +5,7 @@ include mit.LICENSE include setup.py include setup.cfg include README.rst +include Makefile include MANIFEST.in include CHANGELOG.rst include CONTRIBUTING.rst diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..d4ef663 --- /dev/null +++ b/Makefile @@ -0,0 +1,54 @@ +# Copyright (c) the purl authors +# SPDX-License-Identifier: MIT +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. + +# Visit https://github.com/package-url/packageurl-python for support and +# download. + +# Python version can be specified with `$ PYTHON_EXE=python3.x make conf` +PYTHON_EXE?=python3 +ACTIVATE?=. bin/activate; +VIRTUALENV_PYZ=thirdparty/virtualenv.pyz +BLACK_ARGS=--exclude=".cache|migrations|data|lib|bin|var" + +virtualenv: + @echo "-> Bootstrap the virtualenv with PYTHON_EXE=${PYTHON_EXE}" + @${PYTHON_EXE} ${VIRTUALENV_PYZ} --never-download --no-periodic-update . + +conf: virtualenv + @echo "-> Install dependencies" + @${ACTIVATE} pip install -e . + +dev: virtualenv + @echo "-> Configure and install development dependencies" + @${ACTIVATE} pip install -e .[test] + +clean: + @echo "-> Clean the Python env" + rm -rf bin/ lib*/ include/ build/ dist/ .*cache/ pip-selfcheck.json pyvenv.cfg + find . -type f -name '*.py[co]' -delete -o -type d -name __pycache__ \ + -delete -type d -name '*.egg-info' -delete + +test: + @echo "-> Run the test suite" + ${MANAGE} test --noinput + bin/py.test tests + +.PHONY: virtualenv conf dev clean test diff --git a/README.rst b/README.rst index bbba949..8d86d17 100644 --- a/README.rst +++ b/README.rst @@ -49,12 +49,14 @@ Utilities Django models ^^^^^^^^^^^^^ -`packageurl.contrib.django.models.PackageURLMixin` is a Django abstract model mixin to use Package URLs in Django. +`packageurl.contrib.django.models.PackageURLMixin` is a Django abstract model mixin to +use Package URLs in Django. SQLAlchemy mixin ^^^^^^^^^^^^^^^^ -`packageurl.contrib.sqlalchemy.mixin.PackageURLMixin` is a SQLAlchemy declarative mixin to use Package URLs in SQLAlchemy models. +`packageurl.contrib.sqlalchemy.mixin.PackageURLMixin` is a SQLAlchemy declarative mixin +to use Package URLs in SQLAlchemy models. URL to PURL ^^^^^^^^^^^ @@ -70,9 +72,12 @@ URL to PURL PURL to URL ^^^^^^^^^^^ -- `packageurl.contrib.purl2url.get_repo_url(purl)` returns a repository URL inferred from a Package URL. -- `packageurl.contrib.purl2url.get_download_url(purl)` returns a download URL inferred from a Package URL. -- `packageurl.contrib.purl2url.get_inferred_urls(purl)` return all inferred URLs (repository, download) from a Package URL. +- `packageurl.contrib.purl2url.get_repo_url(purl)` returns a repository URL inferred + from a Package URL. +- `packageurl.contrib.purl2url.get_download_url(purl)` returns a download URL inferred + from a Package URL. +- `packageurl.contrib.purl2url.get_inferred_urls(purl)` return all inferred URLs + (repository, download) from a Package URL. :: diff --git a/setup.cfg b/setup.cfg index 3603149..776b171 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,6 @@ [metadata] name = packageurl-python -version = 0.11.2 +version = 0.11.3 license = MIT description = A purl aka. Package URL parser and builder long_description = file:README.rst @@ -66,7 +66,7 @@ known_django = django sections = FUTURE,STDLIB,DJANGO,THIRDPARTY,FIRSTPARTY,LOCALFOLDER [mypy] -python_version = 3.6 +python_version = 3.7 files = src/packageurl/__init__.py show_error_codes = True diff --git a/src/packageurl/contrib/url2purl.py b/src/packageurl/contrib/url2purl.py index 0f51b2e..aade473 100644 --- a/src/packageurl/contrib/url2purl.py +++ b/src/packageurl/contrib/url2purl.py @@ -564,7 +564,7 @@ def build_bitbucket_purl(url): ) -@purl_router.route("https?://gitlab\\.com/.*") +@purl_router.route("https?://gitlab\\.com/(?!.*/archive/).*") def build_gitlab_purl(url): """ Return a PackageURL object from Gitlab `url`. @@ -602,6 +602,17 @@ def build_gitlab_purl(url): ) +# https://gitlab.com/hoppr/hoppr/-/archive/v1.11.1-dev.2/hoppr-v1.11.1-dev.2.tar.gz +gitlab_archive_pattern = ( + r"^https?://gitlab.com/" + r"(?P.+)/(?P.+)/-/archive/(?P.+)/" + r"(?P=name)-(?P=version).*" + r"[^/]$" +) + +register_pattern("gitlab", gitlab_archive_pattern) + + # https://hackage.haskell.org/package/cli-extras-0.2.0.0/cli-extras-0.2.0.0.tar.gz hackage_download_pattern = ( r"^https?://hackage.haskell.org/package/" diff --git a/tests/contrib/data/url2purl.json b/tests/contrib/data/url2purl.json index ab92a05..d4c87e2 100644 --- a/tests/contrib/data/url2purl.json +++ b/tests/contrib/data/url2purl.json @@ -248,6 +248,7 @@ "https://gitlab.com/TG1999/firebase/-/tree/master": "pkg:gitlab/tg1999/firebase@master", "https://gitlab.com/tg1999/Firebase/-/tree/master": "pkg:gitlab/tg1999/firebase@master", "https://gitlab.com/TG1999/FIREBASE": "pkg:gitlab/tg1999/firebase", + "https://gitlab.com/hoppr/hoppr/-/archive/v1.11.1-dev.2/hoppr-v1.11.1-dev.2.tar.gz": "pkg:gitlab/hoppr/hoppr@v1.11.1-dev.2", "https://hackage.haskell.org/package/a50-0.5/a50-0.5.tar.gz": "pkg:hackage/a50@0.5", "https://hackage.haskell.org/package/AC-HalfInteger-1.2.1/AC-HalfInteger-1.2.1.tar.gz": "pkg:hackage/AC-HalfInteger@1.2.1", "https://hackage.haskell.org/package/3d-graphics-examples-0.0.0.2/3d-graphics-examples-0.0.0.2.tar.gz": "pkg:hackage/3d-graphics-examples@0.0.0.2",