Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to 24.2, use pip source to install itself #30

Merged
merged 5 commits into from
Aug 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions recipe/bld.bat
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
%PYTHON% setup.py install --single-version-externally-managed --record record.txt
set PYTHONPATH=%SRC_DIR%\src
%PYTHON% -m pip install --no-deps --no-build-isolation . -vv
if errorlevel 1 exit 1

cd %SCRIPTS%
del *.exe
del *.exe.manifest
del pip2*
del pip3*

:: del %SP_DIR%\__pycache__\pkg_res*
5 changes: 3 additions & 2 deletions recipe/build.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
#!/bin/bash

$PYTHON setup.py install --single-version-externally-managed --record record.txt
# use the pip source to install itself
PYTHONPATH="./src" $PYTHON -m pip install --no-deps --no-build-isolation . -vv
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Neat!

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how does that work? the pip program is loaded into memory then the version in memory installs the version on disc?

Copy link

@danpetry danpetry Aug 7, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does that remove the need to set CONDA_ADD_PIP_AS_PYTHON_DEPENDENCY=0?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how does that work? the pip program is loaded into memory then the version in memory installs the version on disc?

Well, everything is always loaded in memory... What it does is just rely on the non-installed (so in-tree) pip to install itself. -m pip will call src/pip/__main__.py which is the CLI entrypoint.

Copy link
Author

@jjhelmus jjhelmus Aug 7, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When importing packages, Python will search and load modules from various location on disk, such as from the site-packages directory. The PYTHONPATH variable can be use to add locations to the search path.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does that remove the need to set CONDA_ADD_PIP_AS_PYTHON_DEPENDENCY=0?

No, CONDA_ADD_PIP_AS_PYTHON_DEPENDENCY prevents conda from installing the pip conda package when python is listed as a requirement in the recipe. The environment variable is the same as setting add_pip_as_python_dependency: false in .condarc.


cd $PREFIX/bin
rm -f pip2* pip3*
rm -f $SP_DIR/__pycache__/pkg_res*
# Remove all bundled .exe files courtesy of distlib.
rm -f $SP_DIR/pip/_vendor/distlib/*.exe
rm -f $SP_DIR/pip/_vendor/distlib/*.exe
6 changes: 3 additions & 3 deletions recipe/meta.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{% set version = "24.0" %}
{% set version = "24.2" %}

# make sure to set CONDA_ADD_PIP_AS_PYTHON_DEPENDENCY=0 environ-variable before building it

Expand All @@ -8,12 +8,12 @@ package:

source:
url: https://pypi.io/packages/source/p/pip/pip-{{ version }}.tar.gz
sha256: ea9bd1a847e8c5774a5777bb398c19e80bcd4e2aa16a4b301b718fe6f593aba2
sha256: 5b5e490b5e9cb275c879595064adce9ebd31b854e3e803740b72f9ccf34a45b8

build:
number: 0
disable_pip: true
skip: True # [py<37]
skip: True # [py<38]
entry_points:
- pip = pip._internal.cli.main:main
- pip3 = pip._internal.cli.main:main
Expand Down