future-oxygen-10553
10/26/2022, 7:14 PMimportlib.metadata.version
to get the installed version of my packages at runtime from the installation metadata. Unfortunately, pants doesn’t install packages into its hermetic environment when the package is under test, so importing the package fails because importlib.metadata
cannot find the package. Is there any way around this other than try/except
in the __init__.py
for the package?enough-analyst-54434
10/26/2022, 7:35 PMfuture-oxygen-10553
10/26/2022, 7:53 PMmy-package.dist-info/METADATA
, but that has a lot more than just the name and version in itenough-analyst-54434
10/26/2022, 7:57 PMpython_distribution
target(s) to tests? IIUC that should work. May be not fun, but easy to try for 1 dist + 1 test file anyhow.future-oxygen-10553
10/26/2022, 8:00 PMMETADATA
file out of the built wheel, then add a dependency for my tests on that dist-info
, that works. Let me try adding a dependency on the distributionenough-analyst-54434
10/26/2022, 8:01 PMfuture-oxygen-10553
10/26/2022, 8:02 PMfuture-oxygen-10553
10/26/2022, 8:02 PMpex.environment.ResolveError: Failed to resolve requirements from PEX environment @ /Users/bweber/.cache/pants/named_caches/pex_root/unzipped_pexes/6a3825aa222710ffabd3d0bafb0d95ce6f002e0e.
Needed cp39-cp39-macosx_12_0_arm64 compatible dependencies for:
1: scikit-learn>=1.1.2
Required by:
chuck_norris 0.0.2
But this pex had no ProjectName(raw='scikit-learn', normalized='scikit-learn') distributions.
enough-analyst-54434
10/26/2022, 8:02 PMenough-analyst-54434
10/26/2022, 8:02 PMenough-analyst-54434
10/26/2022, 8:02 PMenough-analyst-54434
10/26/2022, 8:02 PMfuture-oxygen-10553
10/26/2022, 8:02 PMtry/except
in __init__.py
future-oxygen-10553
10/26/2022, 8:02 PMenough-analyst-54434
10/26/2022, 8:02 PMfuture-oxygen-10553
10/26/2022, 8:02 PMenough-analyst-54434
10/26/2022, 8:05 PMfuture-oxygen-10553
10/26/2022, 8:07 PM