Expand description
§use-python
Facade crate for the focused RustUse Python ecosystem primitives.
§Experimental
use-python is experimental while the workspace remains below 0.3.0. Expect small API adjustments during the first release wave.
§Example
use use_python::{
PipRequirement, PythonIdentifier, PythonImplementation, PythonPrimitiveValue, PythonVersion,
PytestNodeId,
};
let version: PythonVersion = "Python 3.12.1".parse()?;
let identifier = PythonIdentifier::new("async_task")?;
let requirement = PipRequirement::new("requests>=2")?;
let node_id = PytestNodeId::new("tests/test_app.py::test_smoke")?;
assert!(version.is_python3());
assert_eq!(identifier.as_str(), "async_task");
assert_eq!(PythonImplementation::CPython.as_str(), "cpython");
assert_eq!(PythonPrimitiveValue::None.type_name(), "NoneType");
assert!(!requirement.is_editable());
assert!(node_id.has_scope_separator());§Scope
- Thin re-exports over the focused crates in this workspace.
- One dependency when consumer ergonomics matter more than the narrowest possible dependency graph.
- Primitive metadata and validation helpers for Python ecosystem concepts.
§Non-goals
- Python runtime behavior or object semantics.
- Full source, TOML, requirement, lockfile, or test-file parsing.
- Shelling out to Python ecosystem tools.
- Package resolution, installation, virtual environment creation, linting, formatting, testing, or project generation.
§License
Licensed under either Apache-2.0 or MIT.
Structs§
- PipEditable
Install - pip editable install metadata.
- PipIndex
Url - pip package index URL metadata.
- PipInstall
Target - PipPackage
Spec - PipRequirement
- Validated pip requirement text.
- PipRequirement
File - pip requirements-file metadata.
- PyProject
- Partial
pyproject.tomlmetadata. - PyProject
Build System - Partial
[build-system]metadata. - PyProject
Dependency - PyProject
Entry Point - PyProject
Optional Dependency Group - PyProject
Project Metadata - Partial
[project]metadata. - PyProject
Script - PyProject
Tool Section - Pytest
Fixture Name - Pytest
Marker Name - Pytest
Node Id - pytest node ID metadata.
- Pytest
Test Name - Python
AbiTag - Python
Bytes Value - Python bytes value metadata.
- Python
Compatibility Tag - Python
Dunder Name - Validated Python dunder name metadata.
- Python
Ellipsis - Python ellipsis metadata marker.
- Python
Identifier - Validated ASCII-safe Python identifier.
- Python
Import Name - Python
Major Version - Python major version component.
- Python
Minor Version - Python minor version component.
- Python
Module Name - Python
Module Path - Python module path metadata.
- Python
None - Python
Nonemetadata marker. - Python
Package Name - Python
Patch Version - Python patch version component.
- Python
Platform Tag - Python
Private Name - Validated Python private-name metadata.
- Python
Version - Lightweight Python version metadata.
- Python
Virtual Env - Python virtual environment metadata.
- Python
Virtual EnvName - Validated virtual environment name metadata.
- Python
Virtual EnvPath - Virtual environment path metadata.
- UvPackage
Spec - UvWorkspace
Enums§
- PipCommand
- Common pip command labels.
- PipText
Error - Error returned when pip metadata text is invalid.
- PyProject
Build Backend - Common Python build backends.
- PyProject
Config File - Common pyproject config file labels.
- PyProject
Text Error - Error returned when pyproject metadata text is invalid.
- Pytest
Config File - Common pytest config file labels.
- Pytest
File Kind - pytest file-kind labels.
- Pytest
Name Error - Error returned when pytest metadata names are invalid.
- Pytest
Outcome - pytest outcome labels.
- Pytest
Scope - pytest fixture scope labels.
- Python
Activation Shell - Activation shell labels.
- Python
EnvVar - Python environment variable labels.
- Python
File Kind - Python file-kind metadata.
- Python
Identifier Error - Error returned when an ASCII Python identifier is invalid.
- Python
Implementation - Python implementation label.
- Python
Import Kind - Python import statement kind metadata.
- Python
Keyword - Common hard Python keywords.
- Python
Keyword Parse Error - Error returned when a Python keyword label is empty or unknown.
- Python
Module Name Error - Error returned when Python module name metadata is invalid.
- Python
Number Value - Primitive Python number value metadata.
- Python
Package Layout - Python package layout metadata.
- Python
Primitive Value - Primitive Python-like values for metadata and validation helpers.
- Python
Reserved Word - A hard or soft reserved Python word.
- Python
Soft Keyword - Python soft keywords used by pattern matching and newer syntax contexts.
- Python
String Kind - Python string literal kind metadata.
- Python
Value Parse Error - Error returned when Python value metadata labels are invalid.
- Python
Version Family - Python version family label.
- Python
Version Parse Error - Error returned while parsing Python version metadata.
- Python
Virtual EnvError - Error returned when virtual environment metadata is invalid.
- Python
Virtual EnvKind - Python virtual environment manager kind.
- UvCommand
- Common uv command labels.
- UvConfig
File - uv config file labels.
- UvLockfile
- uv lockfile labels.
- UvProject
Command - uv project subcommand labels.
- UvPython
Command - uv python subcommand labels.
- UvText
Error - Error returned when uv metadata text is invalid.
- UvTool
Command - uv tool subcommand labels.
Functions§
- is_
ascii_ python_ identifier_ continue - Returns whether
characteris accepted after the first identifier character. - is_
ascii_ python_ identifier_ start - Returns whether
characteris accepted as an ASCII Python identifier start. - is_
dunder_ name - Returns whether
inputlooks like a Python dunder name such as__init__. - is_
editable - Returns whether
inputlooks like an editable install option. - is_
private_ name - Returns whether
inputlooks like a single-underscore private name. - is_
python_ keyword - Returns whether
inputis a hard Python keyword. - is_
python_ reserved_ word - Returns whether
inputis either a hard or soft Python reserved word. - is_
python_ soft_ keyword - Returns whether
inputis a Python soft keyword. - is_
requirements_ file - Returns whether
inputlooks like a requirements-file option. - is_
valid_ ascii_ python_ identifier - Returns whether
inputis an ASCII-safe Python identifier and not a hard keyword.