A purl aka. Package URL parser and builder
Project description
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.
License: MIT
Tests and build status
Tests and build |
---|
Install
pip install packageurl-python
Usage
>>> from packageurl import PackageURL >>> purl = PackageURL.from_string("pkg:maven/org.apache.commons/io@1.3.4") >>> print(purl.to_dict()) {'type': 'maven', 'namespace': 'org.apache.commons', 'name': 'io', 'version': '1.3.4', 'qualifiers': None, 'subpath': None} >>> print(purl.to_string()) pkg:maven/org.apache.commons/io@1.3.4 >>> print(str(purl)) pkg:maven/org.apache.commons/io@1.3.4 >>> print(repr(purl)) PackageURL(type='maven', namespace='org.apache.commons', name='io', version='1.3.4', qualifiers={}, subpath=None)
Utilities
Django models
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
packageurl.contrib.url2purl.get_purl(url) returns a Package URL inferred from an URL.
>>> from packageurl.contrib import url2purl >>> url2purl.get_purl("https://github.com/package-url/packageurl-python") PackageURL(type='github', namespace='package-url', name='packageurl-python', version=None, qualifiers={}, subpath=None)
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.
>>> from packageurl.contrib import purl2url >>> purl2url.get_repo_url("pkg:rubygems/bundler@2.3.23") "https://rubygems.org/gems/bundler/versions/2.3.23" >>> purl2url.get_download_url("pkg:rubygems/bundler@2.3.23") "https://rubygems.org/downloads/bundler-2.3.23.gem" >>> purl2url.get_inferred_urls("pkg:rubygems/bundler@2.3.23") ["https://rubygems.org/gems/bundler/versions/2.3.23", "https://rubygems.org/downloads/bundler-2.3.23.gem",]
Run tests
Install test dependencies:
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.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/*
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file packageurl-python-0.11.2.tar.gz
.
File metadata
- Download URL: packageurl-python-0.11.2.tar.gz
- Upload date:
- Size: 36.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.17
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 01fbf74a41ef85cf413f1ede529a1411f658bda66ed22d45d27280ad9ceba471 |
|
MD5 | 81c40ae1f3c95014f918c972384484fd |
|
BLAKE2b-256 | 3334a7843f732e1e0b01e961f6ae835b3fd6bd4e361c1a3a72debd31244cb718 |
File details
Details for the file packageurl_python-0.11.2-py3-none-any.whl
.
File metadata
- Download URL: packageurl_python-0.11.2-py3-none-any.whl
- Upload date:
- Size: 25.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.17
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 799acfe8d9e6e3534bbc19660be97d5b66754bc033e62c39f1e2f16323fcfa84 |
|
MD5 | b2eb8256ad8daa132274a4a5f8dc00a8 |
|
BLAKE2b-256 | aba22cb369e5626fffffda3413a018e9b89955fdaa5a4b78489f72cf59bd63c2 |