You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm using ansible to inject new dependencies for package in pipx,
for example installing jmespath for pipx ansible-core
I've noticed that the venv created by pipx is different and uses shared for pip,
so there is no pip command in bin path
shared bin path
ls -l /usr/local/py-utils/shared/bin/
total 48
-rw-r--r-- 1 root pipx 1903 Mar 30 09:08 activate
-rw-r--r-- 1 root pipx 852 Mar 30 09:08 activate.csh
-rw-r--r-- 1 root pipx 1992 Mar 30 09:08 activate.fish
-rw-r--r-- 1 root pipx 8834 Mar 30 09:08 Activate.ps1
-rwxrwxr-x 1 root pipx 252 Mar 30 09:08 easy_install
-rwxrwxr-x 1 root pipx 252 Mar 30 09:08 easy_install-3.9
-rwxrwxr-x 1 root pipx 242 Mar 30 09:08 pip
-rwxrwxr-x 1 root pipx 242 Mar 30 09:08 pip3
-rwxrwxr-x 1 root pipx 242 Mar 30 09:08 pip3.10
-rwxrwxr-x 1 root pipx 242 Mar 30 09:08 pip3.9
lrwxrwxrwx 1 root pipx 7 Mar 30 09:08 python -> python3
lrwxrwxrwx 1 root pipx 16 Mar 30 09:08 python3 -> /usr/bin/python3
lrwxrwxrwx 1 root pipx 7 Mar 30 09:08 python3.9 -> python3
env ansible-core bin path
ls -l /usr/local/py-utils/venvs/ansible-core/bin
total 80
-rw-r--r-- 1 root pipx 1921 Mar 30 09:08 activate
-rw-r--r-- 1 root pipx 870 Mar 30 09:08 activate.csh
-rw-r--r-- 1 root pipx 2010 Mar 30 09:08 activate.fish
-rw-r--r-- 1 root pipx 8834 Mar 30 09:08 Activate.ps1
-rwxrwxr-x 1 root pipx 249 Mar 30 09:08 ansible
-rwxrwxr-x 1 root pipx 269 Mar 30 09:09 ansible-community
-rwxrwxr-x 1 root pipx 250 Mar 30 09:08 ansible-config
-rwxrwxr-x 1 root pipx 279 Mar 30 09:08 ansible-connection
-rwxrwxr-x 1 root pipx 251 Mar 30 09:08 ansible-console
-rwxrwxr-x 1 root pipx 247 Mar 30 09:08 ansible-doc
-rwxrwxr-x 1 root pipx 250 Mar 30 09:08 ansible-galaxy
-rwxrwxr-x 1 root pipx 253 Mar 30 09:08 ansible-inventory
-rwxrwxr-x 1 root pipx 252 Mar 30 09:08 ansible-playbook
-rwxrwxr-x 1 root pipx 248 Mar 30 09:08 ansible-pull
-rwxrwxr-x 1 root pipx 1733 Mar 30 09:08 ansible-test
-rwxrwxr-x 1 root pipx 249 Mar 30 09:08 ansible-vault
-rwxr-xr-x 1 vscode pipx 1728 Apr 9 01:43 jp.py
drwxr-sr-x 2 vscode pipx 4096 Apr 9 01:43 __pycache__
lrwxrwxrwx 1 root pipx 7 Mar 30 09:08 python -> python3
lrwxrwxrwx 1 root pipx 16 Mar 30 09:08 python3 -> /usr/bin/python3
lrwxrwxrwx 1 root pipx 7 Mar 30 09:08 python3.9 -> python3
Describe the solution you'd like
This is a problem for the ansible.builtin.pip module,
as it can't use calls like 'python -m pip', but only the pip command,
Maybe add a soft link to pip command for pipx venv to reach compatibility?
Here's an ansible example
- name: case1 create venv and install jmespathansible.builtin.pip:
name: jmespathvirtualenv: /usr/local/py-utils/venvs/test1virtualenv_command: /usr/local/py-utils/venvs/pipx/bin/python -m venv
- name: case2 install jmespath with existing venv created by pipxansible.builtin.pip:
name: jmespathvirtualenv: /usr/local/py-utils/venvs/ansible-corevirtualenv_command: /usr/local/py-utils/venvs/pipx/bin/python -m venvignore_errors: yes
- name: ansible cant support python -m pipansible.builtin.pip:
name: jmespathexecutable: /usr/local/py-utils/venvs/ansible-core/bin/python -m pipignore_errors: yes
output
TASK [Gathering Facts] *****************************************************************************************************************************************************************************************
ok: [localhost]
TASK [case1 create venv and install jmespath] ******************************************************************************************************************************************************************
ok: [localhost]
TASK [case2 install jmespath with existing venv created by pipx] ***********************************************************************************************************************************************
fatal: [localhost]: FAILED! => {"changed": false, "msg": "Unable to find pip in the virtualenv, /usr/local/py-utils/venvs/ansible-core, under any of these names: pip3, pip. Make sure pip is present in the virtualenv."}
...ignoring
TASK [ansible cant support python -m pip] **********************************************************************************************************************************************************************
fatal: [localhost]: FAILED! => {"changed": false, "cmd": "'/usr/local/py-utils/venvs/ansible-core/bin/python -m pip' install jmespath", "msg": "[Errno 2] No such file or directory: b'/usr/local/py-utils/venvs/ansible-core/bin/python -m pip'", "rc": 2, "stderr": "", "stderr_lines": [], "stdout": "", "stdout_lines": []}
...ignoring
case1 test1 success, case2 ansible-core fail, because test1 added the pip command.
$ . /usr/local/py-utils/venvs/test1/bin/activate
(test1) $ which pip
/usr/local/py-utils/venvs/test1/bin/pip
Describe alternatives you've considered
Currently I'm using a bash wrapper script that will emulate the python -m pip command, not sure if there are any other issues with that.
How would this feature be useful?
I'm using ansible to inject new dependencies for package in pipx,
for example installing
jmespath
for pipxansible-core
I've noticed that the
venv
created bypipx
is different and uses shared forpip
,so there is no pip command in
bin
pathshared bin path
env
ansible-core
bin pathDescribe the solution you'd like
This is a problem for the
ansible.builtin.pip
module,as it can't use calls like 'python -m pip', but only the
pip
command,Maybe add a soft link to
pip
command for pipx venv to reach compatibility?Here's an ansible example
output
case1
test1
success, case2ansible-core
fail, becausetest1
added the pip command.$ . /usr/local/py-utils/venvs/test1/bin/activate (test1) $ which pip /usr/local/py-utils/venvs/test1/bin/pip
Describe alternatives you've considered
Currently I'm using a bash wrapper script that will emulate the python -m pip command, not sure if there are any other issues with that.
The text was updated successfully, but these errors were encountered: