Merge lp:~cjwatson/launchpadlib/faster-version into lp:launchpadlib

Proposed by Colin Watson
Status: Merged
Merged at revision: 184
Proposed branch: lp:~cjwatson/launchpadlib/faster-version
Merge into: lp:launchpadlib
Diff against target: 89 lines (+16/-12)
4 files modified
NEWS.rst (+5/-0)
setup.py (+2/-5)
src/launchpadlib/__init__.py (+6/-3)
src/launchpadlib/docs/conf.py (+3/-4)
To merge this branch: bzr merge lp:~cjwatson/launchpadlib/faster-version
Reviewer Review Type Date Requested Status
Cristian Gonzalez (community) Approve
Review via email: mp+408473@code.launchpad.net

Commit message

Adjust versioning strategy to avoid importing pkg_resources, which is slow in large environments.

To post a comment you must log in.
Revision history for this message
Cristian Gonzalez (cristiangsp) wrote :

Looks good!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'NEWS.rst'
2--- NEWS.rst 2020-04-19 09:31:44 +0000
3+++ NEWS.rst 2021-09-13 09:53:10 +0000
4@@ -2,6 +2,11 @@
5 NEWS for launchpadlib
6 =====================
7
8+1.10.14
9+=======
10+- Adjust versioning strategy to avoid importing pkg_resources, which is slow
11+ in large environments.
12+
13 1.10.13 (2020-04-19)
14 ====================
15 - Fix test runs under sudo.
16
17=== modified file 'setup.py'
18--- setup.py 2020-04-19 09:29:20 +0000
19+++ setup.py 2021-09-13 09:53:10 +0000
20@@ -38,11 +38,9 @@
21 return '\n'.join(res)
22 # end generic helpers
23
24-with open("src/launchpadlib/version.txt") as version_file:
25- __version__ = version_file.read().strip()
26-
27 install_requires = [
28 'httplib2',
29+ 'importlib-metadata; python_version < "3.8"',
30 'keyring',
31 'lazr.restfulclient>=0.9.19',
32 'lazr.uri',
33@@ -56,10 +54,9 @@
34
35 setup(
36 name='launchpadlib',
37- version=__version__,
38+ version='1.10.14',
39 packages=find_packages('src'),
40 package_dir={'':'src'},
41- package_data={'launchpadlib': ['version.txt']},
42 include_package_data=True,
43 zip_safe=False,
44 author='The Launchpad developers',
45
46=== modified file 'src/launchpadlib/__init__.py'
47--- src/launchpadlib/__init__.py 2019-11-07 17:40:56 +0000
48+++ src/launchpadlib/__init__.py 2021-09-13 09:53:10 +0000
49@@ -14,6 +14,9 @@
50 # You should have received a copy of the GNU Lesser General Public License
51 # along with launchpadlib. If not, see <http://www.gnu.org/licenses/>.
52
53-import pkg_resources
54-__version__ = pkg_resources.resource_string(
55- "launchpadlib", "version.txt").strip()
56+try:
57+ import importlib.metadata as importlib_metadata
58+except ImportError:
59+ import importlib_metadata
60+
61+__version__ = importlib_metadata.version("launchpadlib")
62
63=== modified file 'src/launchpadlib/docs/conf.py'
64--- src/launchpadlib/docs/conf.py 2019-11-07 17:40:56 +0000
65+++ src/launchpadlib/docs/conf.py 2021-09-13 09:53:10 +0000
66@@ -12,8 +12,7 @@
67 # All configuration values have a default; values that are commented out
68 # serve to show the default.
69
70-with open('../version.txt') as version_file:
71- _version = version_file.read().strip()
72+from launchpadlib import __version__
73
74 # If extensions (or modules to document with autodoc) are in another directory,
75 # add these directories to sys.path here. If the directory is relative to the
76@@ -57,9 +56,9 @@
77 # built documents.
78 #
79 # The short X.Y version.
80-version = _version
81+version = __version__
82 # The full version, including alpha/beta/rc tags.
83-release = _version
84+release = __version__
85
86 # The language for content autogenerated by Sphinx. Refer to documentation
87 # for a list of supported languages.
88
89=== removed file 'src/launchpadlib/version.txt'

Subscribers

People subscribed via source and target branches