Install & Compatibility
Where this runs
tested against v0.2.1 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslpy 3.10–3.920 runs
installs and imports cleanly · install 0.0s · import 0.000s · 19MB
glibcpy 3.10–3.920 runs
installs and imports cleanly · install 1.8s · import 0.000s · 20MB
17MB installed
● package 17MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
from_source_checkout
✓ from metadata_please import from_source_checkout
✗ from metadata_please import get_metadata
from_wheel
✓ from metadata_please import from_wheel
from_tar_sdist
✓ from metadata_please import from_tar_sdist
The `get_metadata` function is the primary entry point for `metadata-please`. It takes a `Path` object pointing to a Python artifact (sdist, wheel) or a project source directory (containing `pyproject.toml` or `setup.py`) and returns a metadata object. The example demonstrates usage for project source directories.
from metadata_please import get_metadata
from pathlib import Path
import tempfile
import shutil
# Create dummy files for demonstration
def create_dummy_sdist(path):
path.mkdir(parents=True, exist_ok=True)
with open(path / 'setup.py', 'w') as f:
f.write("from setuptools import setup; setup(name='dummy_sdist', version='0.1.0')")
# In a real scenario, you'd run `python setup.py sdist`
# For this example, we'll just point to the dir as if it were an sdist source
def create_dummy_pyproject_toml(path):
path.mkdir(parents=True, exist_ok=True)
with open(path / 'pyproject.toml', 'w') as f:
f.write('[project]\nname = "dummy-toml"\nversion = "0.2.0"')
with tempfile.TemporaryDirectory() as tmpdir:
tmp_path = Path(tmpdir)
# Example 1: Project directory with setup.py (simplified as source dir)
sdist_source_dir = tmp_path / "dummy_sdist_project"
create_dummy_sdist(sdist_source_dir)
metadata_sdist = get_metadata(sdist_source_dir)
print(f"sdist project Name: {metadata_sdist.name}, Version: {metadata_sdist.version}")
# Example 2: Project directory with pyproject.toml
pyproject_source_dir = tmp_path / "dummy_toml_project"
create_dummy_pyproject_toml(pyproject_source_dir)
metadata_toml = get_metadata(pyproject_source_dir)
print(f"pyproject.toml project Name: {metadata_toml.name}, Version: {metadata_toml.version}")
# Note: For actual .tar.gz (sdist) or .whl (wheel) files,
# you would replace the paths with your actual artifact files.
# Creating real sdist/wheel files dynamically for a quickstart is complex.
# The library is designed to work with these file types directly.
# Example (conceptual for artifact files):
# real_sdist_path = Path("path/to/your_package-1.0.0.tar.gz")
# metadata_real_sdist = get_metadata(real_sdist_path)
# print(f"Real sdist Name: {metadata_real_sdist.name}")
Upgrade
Version history
0.2.1latest on PyPI · released Nov 15, 2024
Audit
Dependencies
No dependency data recorded yet.