quaint-gold-40000
07/27/2021, 12:31 PMfresh-cat-90827
07/27/2021, 12:35 PMfresh-cat-90827
07/27/2021, 12:36 PMquaint-gold-40000
07/27/2021, 12:38 PMpip install
ed). Foir example, this fails:
pkg_resources.get_distribution("<my-package-name>")
fresh-cat-90827
07/27/2021, 12:41 PMquaint-gold-40000
07/27/2021, 12:41 PM.dist-info
directory in lib/site-packages
which stores package metadata.quaint-gold-40000
07/27/2021, 12:41 PMfresh-cat-90827
07/27/2021, 12:47 PMsite-packages
? The directory of your interest will be added automatically thanks to the dependency inference (happening by reading the import
statement) if the test(s) need it.fresh-cat-90827
07/27/2021, 12:48 PMimportlib.import_module
and thus Pants doesn’t include that package in the test environment?quaint-gold-40000
07/27/2021, 12:56 PMcurved-television-6568
07/27/2021, 1:03 PMproud-dentist-22844
07/27/2021, 3:05 PMwitty-crayon-22786
07/27/2021, 5:52 PMPEX
, and the default execution mode of PEX
is to create a virtualenv containing the package contents.
but for pytest
, only 3rdparty code is packaged inside the PEX
, while the sources are added via a scrubbed sys.path as you all have mentioned: https://github.com/pantsbuild/pants/blob/fcb5b5cc71301465c4a0f87807191f75011e24f6/src/python/pants/backend/python/goals/pytest_runner.py#L261-L302 … so this is quite a bit more isolated than typical PYTHONPATH usage.
i believe that we add loose sources for performance reasons, to avoid wrapping a PEX
around the sources. but we also began doing this before PEX
even supported a virtualenv execution mode, so it’s possible that we could 1) add support to PEX for adding sources as installed in “editable” mode, 2) have Pants use that support rather than adding via PEX_EXTRA_SYS_PATH
cc @enough-analyst-54434happy-kitchen-89482
07/27/2021, 8:18 PMpython_distribution
target then that distribution will be built and placed in the test's sandbox. But it won't be installed. That is something we can possibly add, if important. I have actually started looking at a similar problem for installing those sources in editable mode for run
enough-analyst-54434
07/29/2021, 4:43 PMpex .
instead of pex -D ...
(https://github.com/pantsbuild/pex/blob/100b687938293a022e5bb842118b662f5037069e/scripts/package.py#L25-L57). The problem @quaint-gold-40000 is running into is Pants does neither of these currently:
1. If you have defined a python_distribution
target owning some set of source files, when generating a PEX to run tests with or what have you, expose an option (say on python_library
) to use the owning distribution instead of the sources when creating any venvs to run Pants actions in.
2. If you have not defined a python_distribution
, allow the same configuration as in 1, but with Pants auto-generting a distribution based on the owning target name? and with a fake version.
I think though @quaint-gold-40000 probably just needs #1. Either way, these can both be purely accomplished from the Pants side with Pex as-is today.enough-analyst-54434
07/29/2021, 4:45 PMquaint-gold-40000
07/30/2021, 8:40 AMcurved-television-6568
07/30/2021, 8:43 AMwitty-crayon-22786
07/30/2021, 3:09 PMhappy-kitchen-89482
07/30/2021, 3:26 PMdevelop
modehappy-kitchen-89482
07/30/2021, 3:27 PMpython_distribution
targetenough-analyst-54434
07/30/2021, 3:52 PMhappy-kitchen-89482
07/30/2021, 4:06 PMhappy-kitchen-89482
07/30/2021, 4:07 PMenough-analyst-54434
07/30/2021, 4:09 PMenough-analyst-54434
07/30/2021, 4:09 PMhappy-kitchen-89482
07/30/2021, 4:09 PMhappy-kitchen-89482
07/30/2021, 4:09 PMenough-analyst-54434
07/30/2021, 4:10 PMenough-analyst-54434
07/30/2021, 4:20 PMenough-analyst-54434
07/30/2021, 4:20 PMenough-analyst-54434
07/30/2021, 4:21 PMhappy-kitchen-89482
07/30/2021, 4:33 PMdevelop
mode? Possibly never?enough-analyst-54434
07/30/2021, 4:34 PMenough-analyst-54434
07/30/2021, 4:34 PMenough-analyst-54434
07/30/2021, 4:36 PMquaint-gold-40000
08/02/2021, 9:15 AMenough-analyst-54434
08/02/2021, 6:24 PM