@@ -56,24 +56,51 @@ init_sudo() {
5656 fi
5757}
5858
59- # Install missing Python venv support only when the runtime does not already have it .
60- install_venv_support () {
59+ # Install Python packaging support using the system package manager when ensurepip is not available .
60+ install_python_support () {
6161 local distro_family=" $1 "
6262
63- log " Attempting to install Python venv support for $distro_family ..."
63+ log " Attempting to install Python packaging support for $distro_family ..."
6464 case " $distro_family " in
6565 arch)
66- $SUDO pacman -Sy --noconfirm python > /dev/null 2>&1 || return 1
66+ $SUDO pacman -Sy --noconfirm python python-pip > /dev/null 2>&1 || return 1
6767 ;;
6868 debian)
6969 $SUDO apt-get update -y > /dev/null 2>&1 || true
70- $SUDO apt-get install -y python3-venv > /dev/null 2>&1 || return 1
70+ $SUDO apt-get install -y python3-venv python3-pip > /dev/null 2>&1 || return 1
7171 ;;
7272 fedora)
73- $SUDO dnf install -y python3-virtualenv > /dev/null 2>&1 || return 1
73+ $SUDO dnf install -y python3-pip python3- virtualenv > /dev/null 2>&1 || return 1
7474 ;;
7575 suse)
76- $SUDO zypper install -y python3-virtualenv > /dev/null 2>&1 || return 1
76+ $SUDO zypper install -y python3-pip python3-virtualenv > /dev/null 2>&1 || return 1
77+ ;;
78+ * )
79+ return 1
80+ ;;
81+ esac
82+
83+ return 0
84+ }
85+
86+ # Install pipx so the CLI's self-update and development workflows work on minimal systems.
87+ install_pipx_support () {
88+ local distro_family=" $1 "
89+
90+ log " Attempting to install pipx for $distro_family ..."
91+ case " $distro_family " in
92+ arch)
93+ $SUDO pacman -Sy --noconfirm pipx > /dev/null 2>&1 || return 1
94+ ;;
95+ debian)
96+ $SUDO apt-get update -y > /dev/null 2>&1 || true
97+ $SUDO apt-get install -y pipx > /dev/null 2>&1 || return 1
98+ ;;
99+ fedora)
100+ $SUDO dnf install -y pipx > /dev/null 2>&1 || return 1
101+ ;;
102+ suse)
103+ $SUDO zypper install -y pipx > /dev/null 2>&1 || return 1
77104 ;;
78105 * )
79106 return 1
@@ -128,19 +155,48 @@ ensure_python() {
128155 fi
129156
130157 if ! python3 -m pip --version > /dev/null 2>&1 ; then
131- die " pip is not available for this Python installation."
158+ local distro_family
159+ distro_family=" $( detect_distro_family) "
160+ init_sudo
161+ log " ensurepip failed, trying system package manager for pip..."
162+ if ! install_python_support " $distro_family " ; then
163+ die " pip is not available. Install python3-pip and python3-venv with your system package manager and rerun the installer."
164+ fi
132165 fi
133166
134167 if ! python3 -m venv --help > /dev/null 2>&1 ; then
135168 local distro_family
136169 distro_family=" $( detect_distro_family) "
137170 init_sudo
138- if ! install_venv_support " $distro_family " ; then
171+ if ! install_python_support " $distro_family " ; then
139172 die " python3-venv support is missing. Install your distro's Python venv package and rerun the installer."
140173 fi
141174 fi
142175}
143176
177+ ensure_pipx () {
178+ if command -v pipx > /dev/null 2>&1 ; then
179+ log " pipx is already installed"
180+ return 0
181+ fi
182+
183+ local distro_family
184+ distro_family=" $( detect_distro_family) "
185+ init_sudo
186+
187+ log " pipx is missing, attempting to install it..."
188+ if ! install_pipx_support " $distro_family " ; then
189+ die " pipx is not available. Install pipx with your system package manager and rerun the installer."
190+ fi
191+
192+ if command -v pipx > /dev/null 2>&1 ; then
193+ pipx ensurepath > /dev/null 2>&1 || true
194+ return 0
195+ fi
196+
197+ die " pipx installation completed but the command is still not available in PATH."
198+ }
199+
144200ensure_source () {
145201 if [ -f " $SCRIPT_DIR /pyproject.toml" ]; then
146202 SOURCE_SPEC=" $SCRIPT_DIR "
@@ -158,12 +214,31 @@ create_venv() {
158214 log " Creating virtual environment in $VENV_DIR "
159215 python3 -m venv " $VENV_DIR "
160216 fi
217+
218+ # Some minimal environments create the venv without an immediately usable pip.
219+ if [ ! -x " $VENV_DIR /bin/pip" ]; then
220+ log " Bootstrapping pip inside the virtual environment..."
221+ " $VENV_DIR /bin/python" -m ensurepip --upgrade > /dev/null 2>&1 || true
222+ fi
223+
224+ if [ ! -x " $VENV_DIR /bin/pip" ]; then
225+ die " Could not prepare pip inside the virtual environment. Install python3-pip and python3-venv, then rerun the installer."
226+ fi
161227}
162228
163229# Install ArchPkg and the GUI dependency into the private venv.
164230install_package () {
165231 local pip_bin=" $VENV_DIR /bin/pip"
166232
233+ if [ ! -x " $pip_bin " ]; then
234+ log " pip is missing from the virtual environment, trying to bootstrap it..."
235+ " $VENV_DIR /bin/python" -m ensurepip --upgrade > /dev/null 2>&1 || true
236+ fi
237+
238+ if [ ! -x " $pip_bin " ]; then
239+ die " pip is still unavailable inside the virtual environment."
240+ fi
241+
167242 log " Upgrading packaging tools..."
168243 " $pip_bin " install --upgrade pip setuptools wheel > /dev/null
169244
@@ -333,6 +408,7 @@ main() {
333408
334409 ensure_python
335410 ensure_git
411+ ensure_pipx
336412 ensure_source
337413 create_venv
338414 install_package
0 commit comments