Skip to content

Commit

Permalink
setup: replace the last remnant of pbr with setuptools_scm
Browse files Browse the repository at this point in the history
setuptools_scm is a standard and robust tool for dynamically getting
version numbers from e.g. git; among its features is the ability to
write the results to a python module that the application can then
import from. This removes the overhead of large modules which introspect
the dist-info to get the version, in favor of importing a frozen string.
  • Loading branch information
eli-schwartz committed Dec 19, 2021
1 parent 6114fb6 commit cd2d902
Show file tree
Hide file tree
Showing 10 changed files with 9 additions and 37 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ ChangeLog
guake/data/gschemas.compiled
.pytest_cache/
releasenotes/notes/reno.cache
guake/_version.py
guake/paths.py
guake/paths.py.dev
RELEASENOTES.rst
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ black:
checks: black-check flake8 pylint reno-lint

black-check:
PIPENV_IGNORE_VIRTUALENVS=1 pipenv run black --check $(MODULE)
PIPENV_IGNORE_VIRTUALENVS=1 pipenv run black --check $(MODULE) --extend-exclude $(MODULE)/_version.py

flake8:
PIPENV_IGNORE_VIRTUALENVS=1 pipenv run flake8 guake
Expand Down
1 change: 0 additions & 1 deletion docs/source/contributing/packaging.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ Here are the system dependencies of Guake for its execution:
- ``python3-cairo``
- ``python3-dbus``
- ``python3-gi``
- ``python3-pbr``

Optional dependencies:

Expand Down
1 change: 0 additions & 1 deletion docs/source/user/installing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ You need to ensure the following points are met in your configuration:
- ``python3-cairo``
- ``python3-dbus``
- ``python3-gi``
- ``python3-pbr``
- ``python3-pip``
- ``python3``

Expand Down
16 changes: 3 additions & 13 deletions guake/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,9 @@


def guake_version():
# Do not import in the module root to speed up the dbus communication as much as possible
# That being said, importlib.metadata is pretty speedy unlike pbr/pkg_resources
try:
import importlib.metadata as importlib_metadata
except ImportError:
try:
import importlib_metadata
except ImportError:
import pbr.version # Fallback for python < 3.8 unable to install importlib_metadata

return pbr.version.VersionInfo("guake").version_string()

return importlib_metadata.version("guake")
from ._version import version

return version


def vte_version():
Expand Down
1 change: 0 additions & 1 deletion guake/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,6 @@ def main():
" python3 \\\n"
" python3-dbus \\\n"
" python3-gi \\\n"
" python3-pbr \\\n"
" python3-pip"
)
sys.exit(1)
Expand Down
2 changes: 1 addition & 1 deletion scripts/bootstrap-dev-arch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ if [[ $RUN == "1" ]]; then
python-cairo \
python-dbus \
python-gobject \
python-pbr \
python-setuptools-scm \
vte3
fi

Expand Down
2 changes: 1 addition & 1 deletion scripts/bootstrap-dev-debian.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ if [[ $RUN == "1" ]]; then
python3-cairo \
python3-dbus \
python3-gi \
python3-pbr \
python3-setuptools-scm \
python3-pip \
libgirepository1.0-dev
fi
Expand Down
5 changes: 1 addition & 4 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ classifier =
packages =
guake
setup_requires =
pbr
setuptools>=57.5.0
setuptools_scm
install_requires =
importlib_metadata; python_version < '3.8'
typing; python_version < '3.5'
Expand All @@ -47,9 +47,6 @@ all_files = 1
[upload_sphinx]
upload-dir = doc/build/html

[pbr]
warnerrors = True

[wheel]
universal = 1

Expand Down
15 changes: 1 addition & 14 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,4 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals

import setuptools

# In python < 2.7.4, a lazy loading of package `pbr` will break
# setuptools if some other modules registered functions in `atexit`.
# solution from: http://bugs.python.org/issue15881#msg170215
try:
import multiprocessing # noqa
except ImportError:
pass

setuptools.setup(pbr=True)
setuptools.setup(use_scm_version={"write_to": "guake/_version.py"})

0 comments on commit cd2d902

Please sign in to comment.