Public API¶
PEP 503 Python package repository generator.
Classes:
|
Represents a wheel file in the repository. |
Functions:
|
Generate the simple repository index page, containing a list of all projects. |
|
Generate the repository page for a project. |
|
Generate a simple repository of Python wheels. |
-
namedtuple
WheelFile
(filename, wheel_hash, requires_python=None, metadata_hash=None)[source]¶ Bases:
NamedTuple
Represents a wheel file in the repository.
- Fields
filename (
str
) – The name of the wheel file.wheel_hash (
HASH
) – The hash of the wheel file. Repositories SHOULD choose a hash function from one of the ones guaranteed to be available via the hashlib module in the Python standard library (currentlymd5
,sha1
,sha224
,sha256
,sha384
,sha512
). The current recommendation is to usesha256
.requires_python (
Optional
[str
]) – TheRequires-Python
attribute from the wheel’sMETADATA
file.None
if undefined.metadata_hash (
Union
[HASH
,Literal
[True
],None
]) – The hash of the wheel’s METADATA file.None
if the metadata file is not exposed. May beTrue
if no hash is available.
-
__repr__
()¶ Return a nicely formatted representation string
-
generate_index
(projects, base_url='/')[source]¶ Generate the simple repository index page, containing a list of all projects.
-
generate_project_page
(name, files, base_url='/')[source]¶ Generate the repository page for a project.
- Parameters
name (
str
) – The project name, e.g.domdf-python-tools
.files (
Iterable
[WheelFile
]) – An iterable of files for the project, which will be linked to from the index page.base_url (
Union
[str
,URL
]) – The base URL of the Python package repository. For example, with PyPI’s URL, a URL of /foo/ would be https://pypi.org/simple/foo/. Default'/'
.
- Return type
Airium
-
make_simple
(origin, target=None, base_url='/', *, sort=False, copy=False, extract_metadata=True)[source]¶ Generate a simple repository of Python wheels.
- Parameters
origin (
Union
[str
,Path
,PathLike
]) – A directory containing wheels. The wheels may be arranged in subdirectories.target (
Union
[str
,Path
,PathLike
,None
]) – The directory to create the repository in. The directory structure oforigin
will be recreated there. Defaults toorigin
.base_url (
Union
[str
,URL
]) – The base URL of the simple repository. Default'/'
.sort (
bool
) – Sort the wheel files into per-project base directories. DefaultFalse
.copy (
bool
) – Copy files from the source to the destination, rather than moving them. DefaultFalse
.extract_metadata (
bool
) – Extract and serve METADATA files per PEP 658. DefaultTrue
.
- Return type
- Returns
A mapping of (unnormalized) project names to a list of wheels for that project.
Changed in version 0.2.0: Now ignores wheels in the following directories:
.git
,.hg
,.tox
,.tox4
,.nox
,venv
,.venv
.Changed in version 0.3.0:Renamed the
move
option tosort
to better reflect its behaviour.Files are moved to the destination by default, unless the
copy
option isTrue
.
Changed in version 0.4.0: Added the
extract_metadata
option.