If the latter, I don’t quite get how it works, doe...
# pex
If the latter, I don’t quite get how it works, does that mean the transitive context does not matter then, in case req A and req B needs different version of req X?
Pex does the right thing. 1st, an educational note: Unlike the jvm where resolve metadata is separated from artifacts, python resolution requires: 1. download the distribution 2. if a wheel, extract its metadata to find requirements 3. if an sdist, partially build it to get requirements metadata (
python setup.py egg-info
)! 4. recurse Now, how Pex does it: 1. run
pip download
- this performs the wholistic resolve. 2. 1 results in wheels and sdists, in parallel, build any sdists into wheels (
pip wheel
). 3. in parallel install wheels into individual chroots so they can be composed individually later (in a multiplatofrm pex you'll likely only want to activate a subset of wheels for the current platform at runtime) (
pip install
) 4. in parallel gather platform information mentioned in 3 to add to pex metadata
Thanks, John! Just catching up on this. a) Does it mean that the actual version conflict resolution doesn’t show up until step 3 under Pex? For example,
Copy code
A==1.0 depends on C <= 2.0 (latest C is 3.0)
B==1.0 depends on C >=1.0

Step 1 & 2, 
pip download A: the corresponding wheels for A==1.0 C==2.0 
pip download B: the corresponding wheels for B==1.0 C==3.0

Step 3: `pip install A==1.0 B==1.0` grabs the local wheels of A==1.0, B==1.0, C==2.0 and put them into the chroot
b) Does
mean the concurrent workers for step 1 and 2
a.) No. It fails fast. Try it:
Copy code
python -mpex -v pex==1.0.0 pex>1 -c pex -o pex
pex: Building pex :: Resolving distributions (['pex==1.0.0', 'pex']) :: Resolving for:
pex: Isolating pex: 96.0ms                                                                                                                                                                                                                            
pex:   Extracting pex to /home/jsirois/.pex/isolated/84df006b0d25370188d4b3bba51a37795214f814: 65.8ms
pex: PEX.run invoking /usr/bin/python3.8 /tmp/tmpjcf4swsz --disable-pip-version-check --isolated --no-python-version-warning -q --cache-dir /home/jsirois/.pex download --dest /tmp/tmp_mg1duna/resolved_dists/cp38-cp38 pex==1.0.0 pex
pex: Found site-library: /usr/lib/python3.8/site-packages
pex: Tainted path element: /usr/lib/python3.8/site-packages
pex: Scrubbing from user site: /home/jsirois/.local/lib/python3.8/site-packages
pex: Scrubbing from site-packages: /usr/lib/python3.8/site-packages
pex: Activating PEX virtual environment from /tmp/tmpjcf4swsz: 7.0ms
pex: Bootstrap complete, performing final sys.path modifications...
pex: PYTHONPATH contains:
pex:     /tmp/tmpjcf4swsz
pex:   * /usr/lib/python38.zip
pex:     /usr/lib/python3.8
pex:     /usr/lib/python3.8/lib-dynload
pex:     /tmp/tmpjcf4swsz/.deps/pip
pex:     /tmp/tmpjcf4swsz/.deps/setuptools
pex:     /tmp/tmpjcf4swsz/.deps/wheel
pex:     /tmp/tmpjcf4swsz/.bootstrap
pex:   * - paths that do not exist or will be imported via zipimport
ERROR: Double requirement given: pex (already in pex==1.0.0, name='pex')
pid: 74515 -> /usr/bin/python3.8 /tmp/tmpjcf4swsz --disable-pip-version-check --isolated --no-python-version-warning -q --cache-dir /home/jsirois/.pex download --dest /tmp/tmp_mg1duna/resolved_dists/cp38-cp38 pex==1.0.0 pex raised Executing /usr/bin/python3.8 /tmp/tmpjcf4swsz --disable-pip-version-check --isolated --no-python-version-warning -q --cache-dir /home/jsirois/.pex download --dest /tmp/tmp_mg1duna/resolved_dists/cp38-cp38 pex==1.0.0 pex failed with 1
Note the pip command there is download - aka step 1. b.) Per the above "Pex does the right thing." - all the steps that can be parallelized are. The fundamental resolve cannot be parallelized, that's handled by
pip download
. With all this curiosity it might be good to read the code, all self-contained in https://github.com/pantsbuild/pex/blob/b6681fbafe30b36b40349f4869bada4ff757f152/pex/resolver.py#L467 Note as you read that although
is used for all steps, in the 1st step it runs exactly 1 job "in parallel",
which is a single pip download job: https://github.com/pantsbuild/pex/blob/b6681fbafe30b36b40349f4869bada4ff757f152/pex/resolver.py#L396
Thank you! will do.