Skip to content

Commit

Permalink
fix pip install -e . for focal (older pip) (Infra) (#713)
Browse files Browse the repository at this point in the history
* fix `pip install -e .` for focal (older pip)

PIP, when run in editable mode requires the projects to have `setup.py`,
it cannot do it just with setup.cfg and pyproject.toml.

This patch makes it so checkbox can be deployed and used from source.

* remove dynamic setup.py generation
  • Loading branch information
kissiel authored Sep 11, 2023
1 parent c647272 commit 7bdf634
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 19 deletions.
4 changes: 0 additions & 4 deletions checkbox-core-snap/series16/snap/snapcraft.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,6 @@ parts:
override-build: |
# this is a bodge to be backward compatible
snapcraftctl build
# setup.py is necessary for this old pip verision
echo "from setuptools import setup; setup()" > setup.py
# update pip and setuptools (+deps) because the directive
# is ignored in pyproject (and pip on xenial is preinstalled 8.x)
$SNAPCRAFT_PART_INSTALL/usr/bin/python3 -m pip install "pip<21" "setuptools<48" "setuptools_scm[toml]>=3.4" "importlib_metadata==1.0.0" "zipp<2"
Expand Down Expand Up @@ -216,8 +214,6 @@ parts:
override-build: |
# this is a bodge to be backward compatible
snapcraftctl build
# setup.py is necessary for this old pip verision
echo "from setuptools import setup; setup()" > setup.py
# update pip and setuptools (+deps) because the directive
# is ignored in pyproject (and pip on xenial is preinstalled 8.x)
$SNAPCRAFT_PART_INSTALL/usr/bin/python3 -m pip install "pip<21" "setuptools<48" "setuptools_scm[toml]>=3.4" "importlib_metadata==1.0.0" "zipp<2"
Expand Down
4 changes: 0 additions & 4 deletions checkbox-core-snap/series18/snap/snapcraft.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,6 @@ parts:
# 22.04 (i.e base: core22)
sed -i 's|except OSError: # Command not found|except subprocess.CalledProcessError: # Command not found|g' $SNAPCRAFT_STAGE/lib/python3.*/site-packages/**/**/distro.py
override-build: |
# this is a bodge to be backward compatible
echo "from setuptools import setup; setup()" > setup.py
snapcraftctl build
# also use build to ensure install (pip is not compinat to pyproject)
# on this version
Expand Down Expand Up @@ -206,8 +204,6 @@ parts:
- SETUPTOOLS_SCM_PRETEND_VERSION: "$(cat $SNAPCRAFT_STAGE/version.txt)"
after: [checkbox-support]
override-build: |
# this is a bodge to be backward compatible
echo "from setuptools import setup; setup()" > setup.py
snapcraftctl build
# also use build to ensure install (pip is not compinat to pyproject)
# on this version
Expand Down
4 changes: 0 additions & 4 deletions checkbox-core-snap/series20/snap/snapcraft.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -186,8 +186,6 @@ parts:
- PYTHONPATH: $SNAPCRAFT_PART_INSTALL/usr/lib/python3/dist-packages:${PYTHONPATH:-}
- SETUPTOOLS_SCM_PRETEND_VERSION: "$(cat $SNAPCRAFT_STAGE/version.txt)"
override-build: |
# this is a bodge to be backward compatible
echo "from setuptools import setup; setup();" > setup.py
snapcraftctl build
################################################################################
checkbox-ng:
Expand Down Expand Up @@ -232,8 +230,6 @@ parts:
- READTHEDOCS: 'True' # simplifies picamera install
- SETUPTOOLS_SCM_PRETEND_VERSION: "$(cat $SNAPCRAFT_STAGE/version.txt)"
override-build: |
# this is a bodge to be backward compatible
echo "from setuptools import setup; setup();" > setup.py
snapcraftctl build
################################################################################
checkbox-provider-resource:
Expand Down
4 changes: 0 additions & 4 deletions checkbox-core-snap/series22/snap/snapcraft.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,6 @@ parts:
- PYTHONPATH: $SNAPCRAFT_PART_INSTALL/usr/lib/python3/dist-packages:${PYTHONPATH:-}
- SETUPTOOLS_SCM_PRETEND_VERSION: "$(cat $SNAPCRAFT_STAGE/version.txt)"
override-build: |
# this is a bodge to be backward compatible
echo "from setuptools import setup; setup();" > setup.py
snapcraftctl build
################################################################################
checkbox-ng:
Expand Down Expand Up @@ -236,8 +234,6 @@ parts:
- READTHEDOCS: 'True' # simplifies picamera install
- SETUPTOOLS_SCM_PRETEND_VERSION: "$(cat $SNAPCRAFT_STAGE/version.txt)"
override-build: |
# this is a bodge to be backward compatible
echo "from setuptools import setup; setup();" > setup.py
snapcraftctl build
################################################################################
checkbox-provider-resource:
Expand Down
6 changes: 6 additions & 0 deletions checkbox-ng/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# This helps older pip version properly install editable version of checkbox
# inside the venv with `pip install -e .`

from setuptools import setup

setup()
6 changes: 6 additions & 0 deletions checkbox-support/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# This helps older pip version properly install editable version of checkbox
# inside the venv with `pip install -e .`

from setuptools import setup

setup()
3 changes: 0 additions & 3 deletions metabox/metabox/core/machine.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,16 +308,13 @@ def _get_install_dependencies_cmds(self):

def _get_install_source_cmds(self):
if self.config.alias in ["xenial", "bionic"]:
# pip<20 does not support editable install without a setup.py file
return [
(
"bash -c 'pushd /home/ubuntu/checkbox/checkbox-ng ; "
'echo "from setuptools import setup; setup()" > setup.py;'
"sudo python3 -m pip install -e .'"
),
(
"bash -c 'pushd /home/ubuntu/checkbox/checkbox-support ; "
'echo "from setuptools import setup; setup()" > setup.py;'
"sudo python3 -m pip install -e .'"
),
# ensure these two are at the correct version to support xenial
Expand Down

0 comments on commit 7bdf634

Please sign in to comment.