From 2b49645a3164e98bda89069be6c2a07b35bffdbe Mon Sep 17 00:00:00 2001 From: DD <72048428+dadastoor@users.noreply.github.com> Date: Thu, 18 Jan 2024 14:47:43 -0800 Subject: [PATCH 1/2] add envvar to upgrade pip before def pkg install --- README.md | 11 +++++++++++ bin/install | 4 ++++ 2 files changed, 15 insertions(+) diff --git a/README.md b/README.md index 7badb74..e597f57 100644 --- a/README.md +++ b/README.md @@ -70,3 +70,14 @@ pipenv ``` You can specify a non-default location of this file by setting a `ASDF_PYTHON_DEFAULT_PACKAGES_FILE` variable. + +### Upgrade pip before installing Default Python packages + +In some cases (older verisons of pip - which come with older versions of Python) unpinned package versions in `$HOME/.default-python-packages` (or `ASDF_PYTHON_DEFAULT_PACKAGES_FILE` environment variable) may cause errors during pip install - due to latest package dependency versions not being available. + +You can set the environment variable `ASDF_PYTHON_PKGS_UPGRADE_PIP_FIRST` (to any value) to first upgrade your pip version, before installing pacakges from `$HOME/.default-python-packages` (or `ASDF_PYTHON_DEFAULT_PACKAGES_FILE` environment variable): + +``` +export ASDF_PYTHON_PKGS_UPGRADE_PIP_FIRST="true" +asdf install python 3.6.15 +``` diff --git a/bin/install b/bin/install index 3c4219c..5b0531a 100755 --- a/bin/install +++ b/bin/install @@ -34,6 +34,10 @@ install_default_python_packages() { local packages_file="${ASDF_PYTHON_DEFAULT_PACKAGES_FILE:-$HOME/.default-python-packages}" if [ -f "$packages_file" ]; then + if [[ -n "${ASDF_PYTHON_PKGS_UPGRADE_PIP_FIRST:-}" ]]; then + echo "pip install --upgrade pip" + PATH="$ASDF_INSTALL_PATH/bin:$PATH" pip install --upgrade pip + fi echo -ne "\nInstalling default python packages..." PATH="$ASDF_INSTALL_PATH/bin:$PATH" pip install -U -r "$packages_file" fi From 03683c08badbc7525f90d1944071c086cdaef59a Mon Sep 17 00:00:00 2001 From: DD <72048428+dadastoor@users.noreply.github.com> Date: Fri, 19 Jan 2024 11:51:00 -0800 Subject: [PATCH 2/2] restrict envvar to t|True --- README.md | 4 ++-- bin/install | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index e597f57..988c058 100644 --- a/README.md +++ b/README.md @@ -75,9 +75,9 @@ You can specify a non-default location of this file by setting a `ASDF_PYTHON_DE In some cases (older verisons of pip - which come with older versions of Python) unpinned package versions in `$HOME/.default-python-packages` (or `ASDF_PYTHON_DEFAULT_PACKAGES_FILE` environment variable) may cause errors during pip install - due to latest package dependency versions not being available. -You can set the environment variable `ASDF_PYTHON_PKGS_UPGRADE_PIP_FIRST` (to any value) to first upgrade your pip version, before installing pacakges from `$HOME/.default-python-packages` (or `ASDF_PYTHON_DEFAULT_PACKAGES_FILE` environment variable): +You can set the environment variable `ASDF_PYTHON_PKGS_UPGRADE_PIP_FIRST` (to either `true` or `True`) to first upgrade your pip version, before installing pacakges from `$HOME/.default-python-packages` (or `ASDF_PYTHON_DEFAULT_PACKAGES_FILE` environment variable): ``` -export ASDF_PYTHON_PKGS_UPGRADE_PIP_FIRST="true" +export ASDF_PYTHON_PKGS_UPGRADE_PIP_FIRST=true asdf install python 3.6.15 ``` diff --git a/bin/install b/bin/install index 5b0531a..2963508 100755 --- a/bin/install +++ b/bin/install @@ -34,7 +34,7 @@ install_default_python_packages() { local packages_file="${ASDF_PYTHON_DEFAULT_PACKAGES_FILE:-$HOME/.default-python-packages}" if [ -f "$packages_file" ]; then - if [[ -n "${ASDF_PYTHON_PKGS_UPGRADE_PIP_FIRST:-}" ]]; then + if [[ "${ASDF_PYTHON_PKGS_UPGRADE_PIP_FIRST:-}" =~ ^t|True ]]; then echo "pip install --upgrade pip" PATH="$ASDF_INSTALL_PATH/bin:$PATH" pip install --upgrade pip fi