Skip to content

Package provider "pip" not fully functional with network urls on Ubuntu 22.04 #9237

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

Closed
spicyprogramming opened this issue Feb 1, 2024 · 3 comments
Labels
bug Something isn't working triaged Jira issue has been created for this

Comments

@spicyprogramming
Copy link

Describe the Bug

The package provider "pip" does not handle correctly the installation of python modules via network urls (e.g. "git+https://github.com/") on Ubuntu 22.04: this is because on newer pip versions the output of pip freeze --all (which is used by puppet to test if a python module is already installed) is generated in an unexpected format:

# Parse lines of output from `pip freeze`, which are structured as:
# _package_==_version_ or _package_===_version_
def self.parse(line)
if line.chomp =~ /^([^=]+)===?([^=]+)$/
{ :ensure => $2, :name => $1, :provider => name }
end
end

root@831e7bc5baed:/# lsb_release -a
No LSB modules are available.
Distributor ID:	Ubuntu
Description:	Ubuntu 22.04 LTS
Release:	22.04
Codename:	jammy
root@831e7bc5baed:/# pip --version
pip 22.0.2 from /usr/lib/python3/dist-packages/pip (python 3.10)
root@831e7bc5baed:/# pip freeze --all | grep -i ^vSphere-Automation-SDK
vsphere-automation-sdk @ git+https://github.com/vmware/vsphere-automation-sdk-python.git@199b26f1d523023927c172afa6f5b2ebb85dd8f9
root@831e7bc5baed:/# 

On Ubuntu 20.04 this issue does not happen:

root@70b080cc5203:/# lsb_release -a
No LSB modules are available.
Distributor ID:	Ubuntu
Description:	Ubuntu 20.04.6 LTS
Release:	20.04
Codename:	focal
root@70b080cc5203:/# pip --version
pip 20.0.2 from /usr/lib/python3/dist-packages/pip (python 3.8)
root@70b080cc5203:/# pip freeze --all | grep -i ^vSphere-Automation-SDK
vsphere-automation-sdk==1.86.0
root@70b080cc5203:/# 

Expected Behavior

puppet apply should skip installing the python module when run a second time since it's already installed

Steps to Reproduce

From an empty Docker container, image ubuntu:22.04:

# install puppet
apt update
apt install --yes lsb-release wget python3-pip git
wget https://apt.puppetlabs.com/puppet8-release-$(lsb_release -sc).deb
dpkg -i puppet8-release-$(lsb_release -sc).deb
apt update
apt install --yes puppet-agent

# apply manifest
cat > pip_freeze_issue.pp <<'EOF'
package { 'vSphere-Automation-SDK':
  ensure   => 'present',
  provider => 'pip',
  source   => 'git+https://github.com/vmware/vsphere-automation-sdk-python.git'
}
EOF
/opt/puppetlabs/bin/puppet apply pip_freeze_issue.pp

# check python module
pip freeze --all | grep -i ^vSphere-Automation-SDK
pip list --format=freeze | grep -i ^vSphere-Automation-SDK

# apply a second time, should not install the python module again
/opt/puppetlabs/bin/puppet apply pip_freeze_issue.pp

Environment

root@831e7bc5baed:/# /opt/puppetlabs/bin/puppet agent --version
8.4.0
root@831e7bc5baed:/# lsb_release -a
No LSB modules are available.
Distributor ID:	Ubuntu
Description:	Ubuntu 22.04 LTS
Release:	22.04
Codename:	jammy
root@831e7bc5baed:/# 

Additional Context

The package provider for "pip" should use pip list --format=freeze instead of pip freeze --all, when supported (sorry i don't know the exact version)

@spicyprogramming spicyprogramming added the bug Something isn't working label Feb 1, 2024
@joshcooper
Copy link
Contributor

This should be fixed in #9280

@joshcooper joshcooper added the triaged Jira issue has been created for this label Mar 12, 2024
Copy link

Migrated issue to PUP-12027

@joshcooper
Copy link
Contributor

Fixed in #9280 and backported to 7.x in #9311

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working triaged Jira issue has been created for this
Projects
None yet
Development

No branches or pull requests

2 participants