From d8a323584e7eddc3cbd512b25c70a9103df56faf Mon Sep 17 00:00:00 2001 From: Thomas Druez Date: Mon, 10 Apr 2023 09:37:47 +0400 Subject: [PATCH 1/6] Remove backward compatible import from `contrib.django.models` Signed-off-by: Thomas Druez --- CHANGELOG.rst | 7 +++++++ src/packageurl/contrib/django/models.py | 25 ++----------------------- 2 files changed, 9 insertions(+), 23 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 0813033..d9dea12 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -1,6 +1,13 @@ Changelog ========= +unreleased +---------- + +- Remove deprecated `purl_to_lookups` and `without_empty_values` import compatibility + from `packageurl.contrib.django.models`. + Replace those functions import using `packageurl.contrib.django.utils`. + 0.11.1 (2022-03-24) ------------------- diff --git a/src/packageurl/contrib/django/models.py b/src/packageurl/contrib/django/models.py index 55a0678..ead1f7f 100644 --- a/src/packageurl/contrib/django/models.py +++ b/src/packageurl/contrib/django/models.py @@ -24,33 +24,12 @@ # Visit https://github.com/package-url/packageurl-python for support and # download. -import warnings - from django.core.exceptions import ValidationError from django.db import models from django.utils.translation import gettext_lazy as _ from packageurl import PackageURL -from packageurl.contrib.django.utils import purl_to_lookups as _purl_to_lookups -from packageurl.contrib.django.utils import without_empty_values as _without_empty_values - - -def purl_to_lookups(purl, encode=True): - warnings.warn( - "purl_to_lookups is deprecated and will be removed in a future version. " - "Use packageurl.contrib.django.utils.purl_to_lookups instead.", - DeprecationWarning, - ) - return _purl_to_lookups(purl_str=purl, encode=encode) - - -def without_empty_values(input_dict): - warnings.warn( - "without_empty_values is deprecated and will be removed in a future version. " - "Use packageurl.contrib.django.utils.without_empty_values instead.", - DeprecationWarning, - ) - return _without_empty_values(input_dict) +from packageurl.contrib.django.utils import purl_to_lookups class PackageURLQuerySetMixin: @@ -63,7 +42,7 @@ def for_package_url(self, purl_str, encode=True): Filter the QuerySet with the provided Package URL string. The purl string is validated and transformed into filtering lookups. """ - lookups = purl_to_lookups(purl=purl_str, encode=encode) + lookups = purl_to_lookups(purl_str=purl_str, encode=encode) if lookups: return self.filter(**lookups) return self.none() From 1da18224bf9a88cedc438fd61872cfc425976155 Mon Sep 17 00:00:00 2001 From: behnazh-w Date: Wed, 26 Apr 2023 18:00:15 +1000 Subject: [PATCH 2/6] feat: add SQLAlchemy declarative mixin Signed-off-by: behnazh-w --- README.rst | 7 +- setup.cfg | 2 + src/packageurl/contrib/sqlalchemy/mixin.py | 123 +++++++++++++++++++++ 3 files changed, 131 insertions(+), 1 deletion(-) create mode 100644 src/packageurl/contrib/sqlalchemy/mixin.py diff --git a/README.rst b/README.rst index f779819..bbba949 100644 --- a/README.rst +++ b/README.rst @@ -49,7 +49,12 @@ 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. URL to PURL ^^^^^^^^^^^ diff --git a/setup.cfg b/setup.cfg index 8eebac0..2585009 100644 --- a/setup.cfg +++ b/setup.cfg @@ -56,6 +56,8 @@ test = pytest build = wheel +sqlalchemy = + sqlalchemy >= 2.0.0 [isort] force_single_line = True diff --git a/src/packageurl/contrib/sqlalchemy/mixin.py b/src/packageurl/contrib/sqlalchemy/mixin.py new file mode 100644 index 0000000..59bcbbb --- /dev/null +++ b/src/packageurl/contrib/sqlalchemy/mixin.py @@ -0,0 +1,123 @@ +# -*- coding: utf-8 -*- +# +# 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. + +from sqlalchemy import String +from sqlalchemy.orm import Mapped +from sqlalchemy.orm import declarative_mixin +from sqlalchemy.orm import mapped_column + +from packageurl import PackageURL + + +@declarative_mixin +class PackageURLMixin: + """ + SQLAlchemy declarative mixin class for Package URL "purl" fields support. + """ + + type: Mapped[str] = mapped_column( + String(16), + nullable=False, + comment=( + "A short code to identify the type of this package. " + "For example: gem for a Rubygem, docker for a container, " + "pypi for a Python Wheel or Egg, maven for a Maven Jar, " + "deb for a Debian package, etc." + ), + ) + namespace: Mapped[str] = mapped_column( + String(255), + nullable=True, + comment=( + "Package name prefix, such as Maven groupid, Docker image owner, " + "GitHub user or organization, etc." + ), + ) + name: Mapped[str] = mapped_column(String(100), nullable=False, comment="Name of the package.") + version: Mapped[str] = mapped_column( + String(100), nullable=True, comment="Version of the package." + ) + qualifiers: Mapped[str] = mapped_column( + String(1024), + nullable=True, + comment=( + "Extra qualifying data for a package such as the name of an OS, " + "architecture, distro, etc." + ), + ) + subpath: Mapped[str] = mapped_column( + String(200), + nullable=True, + comment="Extra subpath within a package, relative to the package root.", + ) + + @property + def package_url(self) -> str: + """ + Return the Package URL "purl" string. + + Returns + ------- + str + """ + try: + package_url = self.get_package_url() + except ValueError: + return "" + return str(package_url) + + def get_package_url(self) -> PackageURL: + """ + Get the PackageURL instance. + + Returns + ------- + PackageURL + """ + return PackageURL( + self.type, + self.namespace, + self.name, + self.version, + self.qualifiers, + self.subpath, + ) + + def set_package_url(self, package_url: PackageURL) -> None: + """ + Set or update the PackageURL object attributes. + + Parameters + ---------- + package_url: PackageURL + The PackageURL object to set get attributes from. + """ + if not isinstance(package_url, PackageURL): + package_url = PackageURL.from_string(package_url) + + package_url_dict = package_url.to_dict(encode=True, empty="") + for key, value in package_url_dict.items(): + setattr(self, key, value) From 2b7e68a862c8fb811bf97e51e88a263cb7134473 Mon Sep 17 00:00:00 2001 From: Tushar Goel Date: Tue, 25 Jul 2023 17:15:38 +0530 Subject: [PATCH 3/6] Add download purl2url support for bitbucket and gitlab Signed-off-by: Tushar Goel --- src/packageurl/contrib/purl2url.py | 40 +++++++++++++++++++++++++++--- tests/contrib/test_purl2url.py | 12 ++++++--- 2 files changed, 45 insertions(+), 7 deletions(-) diff --git a/src/packageurl/contrib/purl2url.py b/src/packageurl/contrib/purl2url.py index 6e91bab..5da2109 100644 --- a/src/packageurl/contrib/purl2url.py +++ b/src/packageurl/contrib/purl2url.py @@ -28,6 +28,26 @@ from packageurl.contrib.route import NoRouteAvailable from packageurl.contrib.route import Router + +def get_repo_download_url_by_package_type( + type, namespace, name, version, archive_extension="tar.gz" +): + """ + Return the download URL for a hosted git repository given a package type + or None. + """ + assert archive_extension in ( + "zip", + "tar.gz", + ) + download_url_by_type = { + "github": f"https://github.com/{namespace}/{name}/archive/refs/tags/{version}.{archive_extension}", + "bitbucket": f"https://bitbucket.org/{namespace}/{name}/get/{version}.{archive_extension}", + "gitlab": f"https://gitlab.com/{namespace}/{name}/-/archive/{version}/{name}-{version}.{archive_extension}", + } + return download_url_by_type.get(type) + + repo_router = Router() download_router = Router() @@ -328,14 +348,24 @@ def build_nuget_download_url(purl): return f"https://www.nuget.org/api/v2/package/{name}/{version}" -@download_router.route("pkg:github/.*") -def build_github_download_url(purl): +@download_router.route("pkg:gitlab/.*", "pkg:bitbucket/.*", "pkg:github/.*") +def build_repo_download_url(purl): """ - Return a github download URL from the `purl` string. + Return a gitlab download URL from the `purl` string. + """ + return get_repo_download_url(purl) + + +def get_repo_download_url(purl): + """ + Return ``download_url`` if present in ``purl`` qualifiers or + if ``namespace``, ``name`` and ``version`` are present in ``purl`` + else return None. """ purl_data = PackageURL.from_string(purl) namespace = purl_data.namespace + type = purl_data.type name = purl_data.name version = purl_data.version qualifiers = purl_data.qualifiers @@ -350,4 +380,6 @@ def build_github_download_url(purl): version_prefix = qualifiers.get("version_prefix", "") version = f"{version_prefix}{version}" - return f"https://github.com/{namespace}/{name}/archive/refs/tags/{version}.zip" + return get_repo_download_url_by_package_type( + type=type, namespace=namespace, name=name, version=version + ) diff --git a/tests/contrib/test_purl2url.py b/tests/contrib/test_purl2url.py index ed0c686..6bfb94c 100644 --- a/tests/contrib/test_purl2url.py +++ b/tests/contrib/test_purl2url.py @@ -74,7 +74,11 @@ def test_purl2url_get_download_url(): "pkg:npm/is-npm@1.0.0": "http://registry.npmjs.org/is-npm/-/is-npm-1.0.0.tgz", "pkg:hackage/cli-extras@0.2.0.0": "https://hackage.haskell.org/package/cli-extras-0.2.0.0/cli-extras-0.2.0.0.tar.gz", "pkg:nuget/System.Text.Json@6.0.6": "https://www.nuget.org/api/v2/package/System.Text.Json/6.0.6", - "pkg:github/nexb/scancode-toolkit@3.1.1?version_prefix=v": "https://github.com/nexb/scancode-toolkit/archive/refs/tags/v3.1.1.zip", + "pkg:github/nexb/scancode-toolkit@3.1.1?version_prefix=v": "https://github.com/nexb/scancode-toolkit/archive/refs/tags/v3.1.1.tar.gz", + "pkg:bitbucket/robeden/trove@3.0.3": "https://bitbucket.org/robeden/trove/get/3.0.3.tar.gz", + "pkg:bitbucket/robeden/trove@3.0.3?version_prefix=v": "https://bitbucket.org/robeden/trove/get/v3.0.3.tar.gz", + "pkg:gitlab/tg1999/firebase@1a122122": "https://gitlab.com/tg1999/firebase/-/archive/1a122122/firebase-1a122122.tar.gz", + "pkg:gitlab/tg1999/firebase@1a122122?version_prefix=v": "https://gitlab.com/tg1999/firebase/-/archive/v1a122122/firebase-v1a122122.tar.gz", # From `download_url` qualifier "pkg:github/yarnpkg/yarn@1.3.2?download_url=https://github.com/yarnpkg/yarn/releases/download/v1.3.2/yarn-v1.3.2.tar.gz&version_prefix=v": "https://github.com/yarnpkg/yarn/releases/download/v1.3.2/yarn-v1.3.2.tar.gz", "pkg:generic/lxc-master.tar.gz?download_url=https://salsa.debian.org/lxc-team/lxc/-/archive/master/lxc-master.tar.gz": "https://salsa.debian.org/lxc-team/lxc/-/archive/master/lxc-master.tar.gz", @@ -87,7 +91,6 @@ def test_purl2url_get_download_url(): "pkg:cargo/abc": None, "pkg:gem/package-name": None, "pkg:bitbucket/birkenfeld": None, - "pkg:gitlab/tg1999/firebase@1a122122": None, "pkg:pypi/sortedcontainers@2.4.0": None, "pkg:golang/xorm.io/xorm@v0.8.2": None, "pkg:golang/gopkg.in/ldap.v3@v3.1.0": None, @@ -121,7 +124,10 @@ def test_purl2url_get_inferred_urls(): ], "pkg:cargo/abc": ["https://crates.io/crates/abc"], "pkg:github/tg1999/fetchcode": ["https://github.com/tg1999/fetchcode"], - "pkg:gitlab/tg1999/firebase@1a122122": ["https://gitlab.com/tg1999/firebase"], + "pkg:gitlab/tg1999/firebase@1a122122": [ + "https://gitlab.com/tg1999/firebase", + "https://gitlab.com/tg1999/firebase/-/archive/1a122122/firebase-1a122122.tar.gz", + ], "pkg:pypi/sortedcontainers@2.4.0": ["https://pypi.org/project/sortedcontainers/2.4.0/"], "pkg:gem/package-name": [], "pkg:bitbucket/birkenfeld": [], From e9721981cc040d77ce646f4081e05806628cb772 Mon Sep 17 00:00:00 2001 From: Tushar Goel Date: Tue, 25 Jul 2023 18:31:42 +0530 Subject: [PATCH 4/6] Prepare for release v0.11.2 Signed-off-by: Tushar Goel --- CHANGELOG.rst | 5 +++-- setup.cfg | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index d9dea12..61c4d63 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -1,12 +1,13 @@ Changelog ========= -unreleased ----------- +0.11.2 (2022-07-25) +-------------------- - Remove deprecated `purl_to_lookups` and `without_empty_values` import compatibility from `packageurl.contrib.django.models`. Replace those functions import using `packageurl.contrib.django.utils`. +- Add download purl2url support for bitbucket and gitlab. 0.11.1 (2022-03-24) ------------------- diff --git a/setup.cfg b/setup.cfg index 2585009..3603149 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,6 @@ [metadata] name = packageurl-python -version = 0.11.1 +version = 0.11.2 license = MIT description = A purl aka. Package URL parser and builder long_description = file:README.rst From 7b1f4c4fc81f115288e7d19de09ac79f7aa735b1 Mon Sep 17 00:00:00 2001 From: tdruez <489057+tdruez@users.noreply.github.com> Date: Fri, 8 Dec 2023 09:35:19 +0400 Subject: [PATCH 5/6] Add support for GitLab "/archive/" URLs in url2purl #133 (#134) * Add support for GitLab "/archive/" URLs in `url2purl` #133 Signed-off-by: tdruez * Add a Makefile to simplify setup Signed-off-by: tdruez * Bump version to 0.11.3 Signed-off-by: tdruez * Minor adjustments to the CI confs Signed-off-by: tdruez * Upgrade python version to 3.7 in mypy conf Signed-off-by: tdruez --------- Signed-off-by: tdruez --- .github/workflows/ci.yml | 4 +-- .github/workflows/pypi-release.yml | 16 ++++----- CHANGELOG.rst | 6 ++++ MANIFEST.in | 1 + Makefile | 54 ++++++++++++++++++++++++++++++ README.rst | 15 ++++++--- setup.cfg | 4 +-- src/packageurl/contrib/url2purl.py | 13 ++++++- tests/contrib/data/url2purl.json | 1 + 9 files changed, 95 insertions(+), 19 deletions(-) create mode 100644 Makefile 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", From 21520a99a24125527b8a7b2d7003b616ad717c12 Mon Sep 17 00:00:00 2001 From: tdruez Date: Fri, 8 Dec 2023 09:46:48 +0400 Subject: [PATCH 6/6] Update the "Make a new release" chapter of the README Signed-off-by: tdruez --- README.rst | 40 +++++++++++++++------------------------- 1 file changed, 15 insertions(+), 25 deletions(-) diff --git a/README.rst b/README.rst index 8d86d17..91e1bf3 100644 --- a/README.rst +++ b/README.rst @@ -107,31 +107,21 @@ Run 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.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:: - - 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:: - - bin/python setup.py sdist bdist_wheel - -- finally, upload to PyPI:: - - bin/twine upload dist/* - +- Start a new release branch +- Update the CHANGELOG.rst, AUTHORS.rst, and README.rst if needed +- Bump version in setup.cfg +- Run all tests +- Install restview and validate that all .rst docs are correct +- Commit and push this branch +- Make a PR and merge once approved +- Tag and push that tag. This triggers the pypi-release.yml workflow that takes care of + building the dist release files and upload those to pypi:: + + git tag -a vx.x.x -m "Tag vx.x.x" + git push origin vx.x.x + +- Review and publish the "draft" release created by the workflow at + https://github.com/package-url/packageurl-python/releases .. |ci-tests| image:: https://github.com/package-url/packageurl-python/actions/workflows/ci.yml/badge.svg?branch=main :target: https://github.com/package-url/packageurl-python/actions/workflows/ci.yml