livery.extensions.python¶
livery.extensions.python ¶
The python extension's names another extension reads to stamp, build and test wheels.
The python extension builds, versions, publishes and tests a package
whose set holds python. An extension that builds such a package's
wheels with a tool of its own, as nanobind builds them with
cibuildwheel, reads three of its functions.
livery.extensions.python.stamp writes a release's version into the
package's pyproject.toml and every __version__, and raises
there the floors on the members released with it.
livery.extensions.python.module_docs copies the package's docs/
into its source tree as the wheel's embedded _docs for one build,
and removes the copy after it. livery.extensions.python.run_isolated_test
installs a built wheel into a fresh venv and runs the package's tests
against the installed copy.
Functions:
| Name | Description |
|---|---|
module_docs |
The wheel-embedded |
run_isolated_test |
Install the built wheel into a fresh venv and test the installed copy. |
stamp |
Write version and raise package's floors in its manifests; the files changed. |
Attributes:
| Name | Type | Description |
|---|---|---|
__version__ |
|
module_docs ¶
The wheel-embedded _docs, in the source tree for one build alone.
On entry the package's docs/ is copied whole to _docs in
the shallowest of its module roots, the importable package its
wheel ships, replacing any older copy. On exit the copy is
removed, after a failed build too. A copy left behind puts the
docs' example files under the package's source, where every
checker that walks the tree judges them as the package's own code.
Yields:
| Type | Description |
|---|---|
Generator[Path | None]
|
The copy's path; None when the package has no module to carry |
Generator[Path | None]
|
it, or no |
Source code in packages/extensions/python/src/livery/extensions/python/_backend.py
run_isolated_test ¶
run_isolated_test(package: Package, root: Path, *, release_dirs: tuple[Path, ...] = (), resolution: str = 'latest', wheels_dir: Path | None = None) -> dict[str, str]
Install the built wheel into a fresh venv and test the installed copy.
One leg of the release's isolated test, at resolution: floor
puts every direct dependency at its declared floor, so a floor
lying about compatibility fails here; latest resolves the
newest, the world a fresh consumer gets; head installs at the
versions the workspace lock pins, read as it stands, and refuses
in a workspace without a lock.
--find-links is limited to release_dirs, the co-released
set's dist/ directories: a leftover wheel from a non-released
package must never mask that the release needs an unpublished
dependency version. Everything else resolves from the repo's
configured indexes, like a real consumer.
Each distribution those directories carry is refreshed in uv's
cache, so a member rebuilt at the same version installs the wheel
just built and never an earlier build of the same filename.
The toolchain installs after the wheel, at the lock's dev-group pins where a lock exists (bare pytest otherwise), and a probe then re-reads the package's own direct dependencies: the second install is pip-shaped and moves versions without erroring, so a toolchain pin that overlaps a floored dependency would silently undo the starvation. Movement is a taught refusal.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
package
|
Package
|
The member whose wheel is installed and tested. |
required |
root
|
Path
|
The workspace root, whose lock and indexes the install reads. |
required |
release_dirs
|
tuple[Path, ...]
|
The co-released set's |
()
|
resolution
|
str
|
|
'latest'
|
wheels_dir
|
Path | None
|
Where the wheel to install is, for a leg that built
one outside the collected |
None
|
Returns:
| Type | Description |
|---|---|
dict[str, str]
|
The resolved version per distribution, the report's raw |
dict[str, str]
|
material ("floor leg: livery-forge 0.1.0"). |
Raises:
| Type | Description |
|---|---|
Failed
|
when resolution is none of the three, when no wheel is there to install, when the head leg finds no lock, when an install fails, when the toolchain install moves a direct dependency the leg resolved, and when the tests fail. |
Source code in packages/extensions/python/src/livery/extensions/python/_backend.py
1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 | |
stamp ¶
Write version and raise package's floors in its manifests; the files changed.
The version goes into pyproject.toml and every __version__
(stamp_version), and each requirement on one of floors, the
members released with package, takes that member's version
(raise_floors). Each file once, relative to the package's
directory.
Source code in packages/extensions/python/src/livery/extensions/python/_backend.py
__getattr__ ¶
Serve a public name from its module, each time it is read.
The value is never kept here, so a test that patches the name in its module is read through.