Skip to main content

Guess metadata from sdist without running

Project description

dowsing

Short version:

python -m dowsing.pep517 /path/to/repo | jq .

or

from dowsing.pep517 import get_metadata
dist = get_metadata(Path("/path/to/repo"))

Basic reasoning

I don't want to execute arbitrary setup.py in order to find out their basic metadata. I don't want to use the pep517 module in a sandbox, because commonly packages forget to list their build-time dependencies.

This project is one step better than grepping source files, but also understands build-system in pyproject.toml (from PEP 517/518). It does pretty well run on a sampling of pypi projects, but does fail on some notable ones (including setuptools).

When it fails, a key will be "??" and due to some quirks in list context, this can be ["?", "?"].

A rant

The reality of python packaging, even with recent PEPs, is that most nontrivial python packages do moderately interesting stuff in their setup.py:

  • Imports (either from local code, or setup_requires)
  • Fetching things from the Internet
  • Running commands
  • Making sure native libs are installed, or there's a working C compiler
  • Choosing deps based on platform

From the perspective of basically running a distro, they produce messages intended for humans, rather than actually using the mechanisms that we have in PEP 508 (environment markers) and 518 (pyproject.toml requires). There is also no well-specified way to request native libs, and many projects choose to fail to run setup.py when libs are missing.

Goals

This project is a bridge to find several things out, about primarily setup.py but also understanding some popular PEP 517/518 builders as a one-stop-shop, about:

  • doesn't actually execute, so fetches or execs can't cause it to fail [done]
  • cases where we could find out the version string, but it fails to import [done]
  • lets you simulate the pep517 module's output on different platforms [done]
  • a lower-level api suitable for making edits to the place where the setup args are defined [done]
  • to list potential imports, and guess at missing build-time deps (something like numpy.distutils is pretty clear) [todo]

Doing this "right"

A bunch of this is papering over problems with the current reality. If you have an existing sandbox and are ok with ~30% of projects just failing to build, you can rely on the pep517 module's API to actually execute the code on the current version of python.

If you're willing to run the code and have it take longer, take a look at the pep517 api get_requires_for_* or have it generate the metadata (assuming what you want is in there). An example is in dowsing/_demo_pep517.py

This project's dowsing.pep517 api is designed to do something similar, but not fail on missing build-time requirements.

Further Reading

License

dowsing is copyright Tim Hatch, and licensed under the MIT license. I am providing code in this repository to you under an open source license. This is my personal repository; the license you receive to my code is from me and not from my employer. See the LICENSE file for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dowsing-0.9.0b1.tar.gz (26.2 kB view details)

Uploaded Source

Built Distribution

dowsing-0.9.0b1-py3-none-any.whl (29.2 kB view details)

Uploaded Python 3

File details

Details for the file dowsing-0.9.0b1.tar.gz.

File metadata

  • Download URL: dowsing-0.9.0b1.tar.gz
  • Upload date:
  • Size: 26.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.50.0 CPython/3.8.6

File hashes

Hashes for dowsing-0.9.0b1.tar.gz
Algorithm Hash digest
SHA256 8c3bad1ee156ade7be0f1e6cff7d50d9c859016d4f87e27d0a5935939cc6d56c
MD5 fe95b291a25f071f23d267ecd10e1567
BLAKE2b-256 b26467b6663bf5f3a85625ca12ad85c94393183a4305d45f018eec8ebd2ef749

See more details on using hashes here.

File details

Details for the file dowsing-0.9.0b1-py3-none-any.whl.

File metadata

  • Download URL: dowsing-0.9.0b1-py3-none-any.whl
  • Upload date:
  • Size: 29.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.50.0 CPython/3.8.6

File hashes

Hashes for dowsing-0.9.0b1-py3-none-any.whl
Algorithm Hash digest
SHA256 ba4d11eb54586f95b0667daa80e0606f9bfe168bff9872b174e4fa88aaed3151
MD5 9709fc18b011138c07a52a38d4675ce7
BLAKE2b-256 f0cbf0176f2e16abdb2323ba7bc69a4fe127594631ccb6526919acbcbf35dffe

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page