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
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 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 | |
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.