canonical / checkbox

Checkbox
https://checkbox.readthedocs.io
GNU General Public License v3.0
30 stars 44 forks source link

Use version manually in setup.py when provided (infra) #1253

Closed Hook25 closed 1 month ago

Hook25 commented 1 month ago

Description

By default we adopt the package version via setuptools scm. This tool reads the SETUPTOOLS_SCM_PRETEND_VERSION environment variable and, if it is provided, it adopts it as the version without doing any further calculation. This is useful to pre-compute the version before building like we do in snaps and debs. This mechanism seems to not be used on some versions of pybuild (the debian plugin we use to build the package) that ignores the setuptools-scm version and simply uses a 0.0.0 version string.

This PR adopts the version from the variable in setup.py manually. Note that if the variable is not provided setuptools-scm is still used, preserving the functionality of "source" installs.

Resolved issues

Fixes: https://warthogs.atlassian.net/browse/CHECKBOX-1444 Fixes: https://github.com/canonical/checkbox/issues/1250

Documentation

This also adds a comment to explain why this is done.

Tests

To try this start a lxd container and build the package:

$ add-apt-repository ppa:checkbox-dev/edge
$ apt update
$ apt install dpkg-dev
$ cd checkbox
$ mv checkbox-ng/debian .  
$ dpkg-buildpackage -S
[...]  # this it will complain about missing build deps
$ apt install debhelper dh-python pybuild-plugin-pyproject python3-all python3-distutils-extra python3-docutils python3-importlib-metadata python3-packaging python3-padme python3-psutil python3-requests-oauthlib python3-setuptools python3-setuptools-scm python3-sphinx python3-tk python3-tqdm python3-urwid python3-xlsxwriter
$ dpkg-buildpackage -S
$ dpkg-buildpackage -b
$ cd ..
$ dpkg -i python3-checkbox-ng_2.8_all.deb checkbox-ng_2.8_all.deb

To verify that all went well run:

$ checkbox-cli --version
2.8

Note: the version is adopted from the debian changelog that is automatically updated by launchpad. Locally the version will always be 2.8 (as that is the last version that was "manually" updated).

codecov[bot] commented 1 month ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 43.38%. Comparing base (ba754d6) to head (16eaf7d). Report is 10 commits behind head on main.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #1253 +/- ## ======================================= Coverage 43.37% 43.38% ======================================= Files 357 357 Lines 38693 38686 -7 Branches 6561 6561 ======================================= Hits 16784 16784 + Misses 21245 21238 -7 Partials 664 664 ``` | [Flag](https://app.codecov.io/gh/canonical/checkbox/pull/1253/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=canonical) | Coverage Δ | | |---|---|---| | [checkbox-ng](https://app.codecov.io/gh/canonical/checkbox/pull/1253/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=canonical) | `67.54% <ø> (ø)` | | | [checkbox-support](https://app.codecov.io/gh/canonical/checkbox/pull/1253/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=canonical) | `52.22% <ø> (ø)` | | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=canonical#carryforward-flags-in-the-pull-request-comment) to find out more.

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.