Merge ~cjwatson/launchpad:gi-is-optional into launchpad:master

Proposed by Colin Watson
Status: Merged
Approved by: Colin Watson
Approved revision: c184718bf0f692adffed347c28859700b0efcbd7
Merge reported by: Otto Co-Pilot
Merged at revision: not available
Proposed branch: ~cjwatson/launchpad:gi-is-optional
Merge into: launchpad:master
Diff against target: 67 lines (+21/-5)
2 files modified
system-packages.txt (+6/-2)
utilities/link-system-packages.py (+15/-3)
Reviewer Review Type Date Requested Status
Ioana Lasc (community) Approve
Review via email: mp+382990@code.launchpad.net

Commit message

Make the system "gi" package optional

Description of the change

The gi (gobject-introspection) package is only used in the test suite, and isn't installed by launchpad-dependencies. Make it optional.

To post a comment you must log in.
Revision history for this message
Ioana Lasc (ilasc) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/system-packages.txt b/system-packages.txt
2index 1737888..5fe7918 100644
3--- a/system-packages.txt
4+++ b/system-packages.txt
5@@ -3,6 +3,10 @@
6 # Python dependency is impossible or unreliable (perhaps due to frequent ABI
7 # changes in system libraries they depend on, or frequent security updates
8 # managed by the distribution's security team).
9+#
10+# Package names that end with "?" are optional, in that link-system-packages
11+# will not fail if they are missing; this should be reserved for packages
12+# only used by the test suite.
13
14 # Used by launchpad-buildd.
15 apt
16@@ -19,7 +23,7 @@ convoy
17 GeoIP
18
19 # lp.testing.html5browser
20-gi
21+gi?
22
23 # lp.services.fields, lp.services.spriteutils
24 PIL
25@@ -28,5 +32,5 @@ PIL
26 sqlite
27 _sqlite
28
29-# Optional dependency of bzr-git and bzr-svn.
30+# Used by bzr-git and bzr-svn.
31 tdb
32diff --git a/utilities/link-system-packages.py b/utilities/link-system-packages.py
33index 07d0f9b..18b863b 100755
34--- a/utilities/link-system-packages.py
35+++ b/utilities/link-system-packages.py
36@@ -14,8 +14,15 @@ import os.path
37 import re
38
39
40-def link_module(name, virtualenv_libdir):
41- module = importlib.import_module(name)
42+def link_module(name, virtualenv_libdir, optional=False):
43+ try:
44+ module = importlib.import_module(name)
45+ except ImportError:
46+ if optional:
47+ print("Skipping missing optional module %s." % name)
48+ return
49+ else:
50+ raise
51 path = module.__file__
52 if os.path.basename(path).startswith("__init__."):
53 path = os.path.dirname(path)
54@@ -40,7 +47,12 @@ def main():
55 line = re.sub(r"#.*", "", line).strip()
56 if not line:
57 continue
58- link_module(line, args.virtualenv_libdir)
59+ if line.endswith("?"):
60+ line = line[:-1]
61+ optional = True
62+ else:
63+ optional = False
64+ link_module(line, args.virtualenv_libdir, optional=optional)
65
66
67 if __name__ == "__main__":

Subscribers

People subscribed via source and target branches

to status/vote changes: