Skip to main content

Shadwell - A finder for Python packages

It wasn't a dark and stormy night.
It should have been, but that's the weather for you.

-- "Good Omens", by Terry Pratchett and Neil Gaiman

Shadwell lets you find Python packages, from a set of "sources" (typically a package index or local directory).

Finders

In order to use the library, you need to create a Finder object, and then use that to fetch candidates for a requirement, as follows:

sources = [
    # A list of package sources, we'll come back to this
]
finder = Finder(sources)
results = finder.find(requirement)

The results are returned in "best first" order, so callers which just want the best match can take the first result returned and ignore the rest.

When creating a finder, you can supply any of the following arguments, to configure its behaviour:

  • compatibility_tags: This is a set of binary compatibility tags, used to determine if a wheel is compatible with the target platform. It should be a list of packaging.tags.Tag objects. Normally this will be omitted, in which case the default is to use packaging.tags.sys_tags(), which is the set supported by the current Python interpreter.
  • allow_prerelease: If this is True, the finder will return pre-release versions. Otherwise it will ignore prereleases (this is the default behaviour).
  • python_version: A packaging.version.Version object representing the target Python release. It is used to filter candidates based on their Requires-Python metadata. As usual, the current interpreter is used by default.
  • wheel_policy: This is a function that determines for a package, how we should choose between wheels and source distributions. Called with a package name, it should return one of the WheelPolicy values ALLOW (wheels can be used), REQUIRE (only wheels are allowed), PROHIBIT (wheels cannot be used, only sdists are allowed) or PREFER (older wheels will be selected in preference to newer source-only versions).
  • allow_yanked: This option only affects the case where all of the selected candidates are yanked. If there are any unyanked candidates, yanked candidates will be omitted regardless of the value of this option. If only yanked candidates are available, this option determines whether to return them rather than returning an empty list (the default). The intention here is to allow callers flexibility in how they implement the rules in PEP 592.

Candidates

The objects returned from the finder are Candidate objects. The exact class is up to the source, but they must have the following attributes:

  • name: The project name (a string).
  • version: The project version (packaging.version.Version)
  • requires_python: The Python versions this candidate works with (packaging.specifiers.SpecifierSet)
  • is_wheel: Is this a wheel or sdist.
  • tags: The compatibility tags for this wheel (ignored for sdists). (Set[packaging.tags.Tag])
  • is_yanked: Is this file yanked?

Sources

A source is any Python callable that takes a project name as an argument, and yields candidate objects for the named project. Note in particular that it is not the responsibility of the source to do any sort of filtering.

Further possibilities

  1. Rather than having the finder return a flat list of candidates, maybe return a list of (version, ordered list of candidates)? That allows callers to more easily select the best candidate per version. However, "prefer wheel" may split the candidates for a version into 2 parts (wheels in one batch, sources in another), and that would be potentially harder for callers...

Release files for shadwell 0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for shadwell 0.1
File Size Uploaded
shadwell-0.1.tar.gz 8.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for shadwell 0.1
File Interpreter ABI Platform
shadwell-0.1-py3-none-any.whl Python 3 none any Details

Total release size: 15.8 kB

Release files / shadwell-0.1.tar.gz

Download URL shadwell-0.1.tar.gz
Size 8.7 kB
Tags Source
SHA-256 checksum
How to use checksums
7173d70ee83a821fd519f52894d2a9bb2b5b3968337c35a75a036486ed40c14a
BLAKE2b-256 checksum
How to use checksums
006ab3dce4a44b447c2b654162d397f94489a9ea24838de9c15376d38b87c1b8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/51.1.2 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.9.1

Release files / shadwell-0.1-py3-none-any.whl

Download URL shadwell-0.1-py3-none-any.whl
Size 7.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
351813cc7fb0080d1f5c8c5a7e05d98f6f1093452e07b278218e4982f85af8ce
BLAKE2b-256 checksum
How to use checksums
d1894c4aa5bfbb1f8d9bb56c993f926294d2ff1d63d02270bb99c3192837dafa
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/51.1.2 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.9.1

Release history Release notifications | RSS feed

This release

0.1 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page