Skip to content

Commit

Permalink
Fix PIP dependencies installation on bionic and older (Infra) (#712)
Browse files Browse the repository at this point in the history
* use proper install_requires in setup.cfg

This patch changes the `requires` to `install_requires` to be compliant
with: https://packaging.python.org/en/latest/discussions/install-requires-vs-requirements
Which also fixes installation behaviour on bionic.

* Removed dependency installation hack from metabox

* metabox: remove workarounds for xenial and bionic

---------

Co-authored-by: Hook25 <massimiliano.girardi@canonical.com>
  • Loading branch information
kissiel and Hook25 authored Sep 20, 2023
1 parent e81837f commit 9be7d86
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 44 deletions.
2 changes: 1 addition & 1 deletion checkbox-ng/setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ sign=true
[options]
packages=find_namespace:
include_package_data=true
requires=
install_requires=
packaging
requests >= 1.0
urwid >= 1.1.1
Expand Down
2 changes: 1 addition & 1 deletion checkbox-support/setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ sign = True
[options]
packages=find_namespace:
include_package_data=true
requires=
install_requires=
pyparsing >= 2.2.0
requests >= 1.0
distro >= 1.0
Expand Down
58 changes: 16 additions & 42 deletions metabox/metabox/core/machine.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,52 +282,17 @@ def get_early_dir_transfer(self):

def _get_install_dependencies_cmds(self):
# We need any pip version >20 because we use pyproject.toml
if self.config.alias in ["xenial", "bionic"]:
# Use <21 to get the latest 20 as 21+ is not supported here
return [
"bash -c 'sudo python3 -m pip install -U \"pip<21\"'",
(
# This is here because this pip version does not support
# installing dependencies from pyproject.toml
"bash -c 'sudo python3 -m pip install "
'"pyparsing<3.0.0" "requests<2.26.0" "distro<1.7.0" '
'"requests_unixsocket<=0.3.0" "importlib_metadata<=1.0.0"'
'"packaging<21.0" "psutil<=5.9.5" "requests<2.26.0" '
'"urwid<=2.1.2" "Jinja2<=2.11.3" "XlsxWriter<=3.0.3" '
'"tqdm<4.65.0" "importlib_metadata<=1.0.0"'
"'"
),
]
if self.config.alias not in ["focal", "jammy"]:
logger.warning(
"Unknown revision dependencies version, installing latest"
)
pip_version = (
'"pip<21"'
if self.config.alias in ["xenial", "bionic"]
else '"pip>20"'
)
return [
"bash -c 'sudo python3 -m pip install -U \"pip>20\"'",
"bash -c 'sudo python3 -m pip install -U {}'".format(pip_version),
]

def _get_install_source_cmds(self):
if self.config.alias in ["xenial", "bionic"]:
return [
(
"bash -c 'pushd /home/ubuntu/checkbox/checkbox-ng ; "
"sudo python3 -m pip install -e .'"
),
(
"bash -c 'pushd /home/ubuntu/checkbox/checkbox-support ; "
"sudo python3 -m pip install -e .'"
),
# ensure these two are at the correct version to support xenial
(
"bash -c 'sudo python3 -m "
'pip install importlib_metadata==1.0.0 "zipp<2"\''
),
]
if self.config.alias not in ["focal", "jammy"]:
logger.warning(
"Unknown revision dependencies version, installing latest"
)
return [
commands = [
(
"bash -c 'pushd /home/ubuntu/checkbox/checkbox-ng ; "
"sudo python3 -m pip install -e .'"
Expand All @@ -337,6 +302,15 @@ def _get_install_source_cmds(self):
"sudo python3 -m pip install -e .'"
),
]
if self.config.alias in ["xenial", "bionic"]:
commands.append(
# ensure these two are at the correct version to support xenial
(
"bash -c 'sudo python3 -m "
'pip install importlib_metadata==1.0.0 "zipp<2"\''
)
)
return commands

def _get_provider_setup_cmds(self):
# This installs the providers. This is based on the fact
Expand Down

0 comments on commit 9be7d86

Please sign in to comment.