Merge ~woutervb/snapstore-client:move_to_setuptools into snapstore-client:master

Proposed by Wouter van Bommel
Status: Merged
Approved by: Wouter van Bommel
Approved revision: ab0f962925b7ec3b57b02ac75c205a0c0dc983e2
Merge reported by: Otto Co-Pilot
Merged at revision: not available
Proposed branch: ~woutervb/snapstore-client:move_to_setuptools
Merge into: snapstore-client:master
Prerequisite: ~woutervb/snapstore-client:modernize
Diff against target: 256 lines (+88/-66)
4 files modified
Makefile (+1/-1)
setup.py (+17/-0)
snap/snapcraft.yaml (+7/-16)
snapstore_client/main.py (+63/-49)
Reviewer Review Type Date Requested Status
Maximiliano Bertacchini Approve
Review via email: mp+414491@code.launchpad.net

Commit message

Move the project to setuptool

By being a proper setuptools based application, the snap building becomes simpler and it is needed to move to click for commandline parsing

To post a comment you must log in.
Revision history for this message
Maximiliano Bertacchini (maxiberta) wrote :

LGTM! +1

review: Approve
Revision history for this message
Maximiliano Bertacchini (maxiberta) wrote :

Please check comment on the package name.

Revision history for this message
Otto Co-Pilot (otto-copilot) wrote :
Revision history for this message
Otto Co-Pilot (otto-copilot) wrote :

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/Makefile b/Makefile
2index 19eeaa7..76ddd0a 100644
3--- a/Makefile
4+++ b/Makefile
5@@ -25,7 +25,7 @@ $(ENV)/dev: $(ENV)/prod
6 bootstrap: $(ENV)/prod
7
8 snap:
9- snapcraft build
10+ snapcraft
11
12 test: $(ENV)/dev
13 $(PYTHON3) -m unittest $(TESTS) 2>&1
14diff --git a/setup.py b/setup.py
15new file mode 100644
16index 0000000..7ff4d8a
17--- /dev/null
18+++ b/setup.py
19@@ -0,0 +1,17 @@
20+from setuptools import find_namespace_packages, setup
21+
22+
23+with open("requirements.txt") as f:
24+ install_requires = f.read().splitlines()
25+
26+setup(
27+ name="snap-store-proxy-client-admin",
28+ version="1.1.0",
29+ packages=find_namespace_packages(),
30+ install_requires=install_requires,
31+ entry_points={
32+ "console_scripts": [
33+ "snapstore = snapstore_client.main:main",
34+ ],
35+ },
36+)
37diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml
38index 8811c64..6139474 100644
39--- a/snap/snapcraft.yaml
40+++ b/snap/snapcraft.yaml
41@@ -1,36 +1,27 @@
42 name: snap-store-proxy-client
43 base: core20
44-version: "1.1"
45 summary: Canonical snap store proxy administration client.
46 description: |
47 The Canonical snapstore client is used to manage a snap store proxy.
48
49-# Defaults, but snapcraft prints ugly yellow messages without them.
50 confinement: strict
51 grade: stable
52+adopt-info: snap-store-proxy-client
53
54 architectures:
55 - build-on: amd64
56
57 apps:
58 snap-store-proxy-client:
59- command: ./snapstore
60+ command: bin/snapstore
61 plugs:
62 - network
63
64 parts:
65- deps:
66+ snap-store-proxy-client:
67 plugin: python
68 source: .
69- requirements:
70- - ${SNAPCRAFT_PART_SRC}/requirements.txt
71- source:
72- plugin: dump
73- source: .
74- stage:
75- - snapstore
76- - snapstore_client/
77- override-prime: |
78- snapcraftctl prime
79- python3 -m compileall -q -j0 snapstore_client
80-
81+ override-build: |
82+ snapcraftctl build
83+ version="$(python3 setup.py --version)"
84+ snapcraftctl set-version "$version"
85diff --git a/snapstore b/snapstore_client/main.py
86similarity index 53%
87rename from snapstore
88rename to snapstore_client/main.py
89index cd67b71..d3d9c8c 100755
90--- a/snapstore
91+++ b/snapstore_client/main.py
92@@ -20,7 +20,7 @@ from snapstore_client.logic.overrides import (
93 from snapstore_client.logic.push import push_snap
94
95
96-DEFAULT_SSO_URL = 'https://login.ubuntu.com/'
97+DEFAULT_SSO_URL = "https://login.ubuntu.com/"
98
99
100 def main():
101@@ -37,87 +37,101 @@ def main():
102
103 def parse_args():
104 parser = argparse.ArgumentParser()
105- subparsers = parser.add_subparsers(help='sub-command help')
106+ subparsers = parser.add_subparsers(help="sub-command help")
107
108 login_parser = subparsers.add_parser(
109- 'login', help='Sign into a store.',
110- formatter_class=argparse.ArgumentDefaultsHelpFormatter)
111- login_parser.add_argument('store_url', help='Store URL')
112- login_parser.add_argument('email', help='Ubuntu One SSO email', nargs='?')
113- login_parser.add_argument('--sso-url', help='Ubuntu One SSO URL',
114- default=DEFAULT_SSO_URL)
115- login_parser.add_argument('--offline', help="Use offline mode interaction",
116- action='store_true')
117+ "login",
118+ help="Sign into a store.",
119+ formatter_class=argparse.ArgumentDefaultsHelpFormatter,
120+ )
121+ login_parser.add_argument("store_url", help="Store URL")
122+ login_parser.add_argument("email", help="Ubuntu One SSO email", nargs="?")
123+ login_parser.add_argument(
124+ "--sso-url", help="Ubuntu One SSO URL", default=DEFAULT_SSO_URL
125+ )
126+ login_parser.add_argument(
127+ "--offline", help="Use offline mode interaction", action="store_true"
128+ )
129 login_parser.set_defaults(func=login)
130
131 list_overrides_parser = subparsers.add_parser(
132- 'list-overrides', help='List channel map overrides.',
133+ "list-overrides",
134+ help="List channel map overrides.",
135 )
136 list_overrides_parser.add_argument(
137- '--series', default='16',
138- help='The series within which to list overrides.')
139+ "--series", default="16", help="The series within which to list overrides."
140+ )
141 list_overrides_parser.add_argument(
142- 'snap_name',
143- help='The name of the snap whose channel map should be listed.')
144+ "snap_name", help="The name of the snap whose channel map should be listed."
145+ )
146 list_overrides_parser.add_argument(
147- '--password',
148- help='Password for interacting with an offline proxy',
149- default=os.environ.get('SNAP_PROXY_PASSWORD')
150+ "--password",
151+ help="Password for interacting with an offline proxy",
152+ default=os.environ.get("SNAP_PROXY_PASSWORD"),
153 )
154 list_overrides_parser.set_defaults(func=list_overrides)
155
156 override_parser = subparsers.add_parser(
157- 'override', help='Set channel map overrides.',
158+ "override",
159+ help="Set channel map overrides.",
160 )
161 override_parser.add_argument(
162- '--series', default='16',
163- help='The series within which to set overrides.')
164+ "--series", default="16", help="The series within which to set overrides."
165+ )
166 override_parser.add_argument(
167- 'snap_name',
168- help='The name of the snap whose channel map should be modified.')
169+ "snap_name", help="The name of the snap whose channel map should be modified."
170+ )
171 override_parser.add_argument(
172- 'channel_map_entries', nargs='+', metavar='channel_map_entry',
173- help='A channel map override, in the form <channel>=<revision>.')
174+ "channel_map_entries",
175+ nargs="+",
176+ metavar="channel_map_entry",
177+ help="A channel map override, in the form <channel>=<revision>.",
178+ )
179 override_parser.add_argument(
180- '--password',
181- help='Password for interacting with an offline proxy',
182- default=os.environ.get('SNAP_PROXY_PASSWORD')
183+ "--password",
184+ help="Password for interacting with an offline proxy",
185+ default=os.environ.get("SNAP_PROXY_PASSWORD"),
186 )
187 override_parser.set_defaults(func=override)
188
189 delete_override_parser = subparsers.add_parser(
190- 'delete-override', help='Delete channel map overrides.',
191+ "delete-override",
192+ help="Delete channel map overrides.",
193 )
194 delete_override_parser.add_argument(
195- '--series', default='16',
196- help='The series within which to delete overrides.')
197+ "--series", default="16", help="The series within which to delete overrides."
198+ )
199 delete_override_parser.add_argument(
200- 'snap_name',
201- help='The name of the snap whose channel map should be modified.')
202+ "snap_name", help="The name of the snap whose channel map should be modified."
203+ )
204 delete_override_parser.add_argument(
205- 'channels', nargs='+', metavar='channel',
206- help='A channel whose overrides should be deleted.')
207+ "channels",
208+ nargs="+",
209+ metavar="channel",
210+ help="A channel whose overrides should be deleted.",
211+ )
212 delete_override_parser.add_argument(
213- '--password',
214- help='Password for interacting with an offline proxy',
215- default=os.environ.get('SNAP_PROXY_PASSWORD')
216+ "--password",
217+ help="Password for interacting with an offline proxy",
218+ default=os.environ.get("SNAP_PROXY_PASSWORD"),
219 )
220 delete_override_parser.set_defaults(func=delete_override)
221
222 push_snap_parser = subparsers.add_parser(
223- 'push-snap', help='push a snap to an offline proxy')
224+ "push-snap", help="push a snap to an offline proxy"
225+ )
226 push_snap_parser.add_argument(
227- 'snap_tar_file',
228- help='The .tar.gz file of a bundled downloaded snap')
229+ "snap_tar_file", help="The .tar.gz file of a bundled downloaded snap"
230+ )
231 push_snap_parser.add_argument(
232- '--push-channel-map',
233- action='store_true',
234- help="Force push of the channel map,"
235- " removing any existing overrides")
236+ "--push-channel-map",
237+ action="store_true",
238+ help="Force push of the channel map," " removing any existing overrides",
239+ )
240 push_snap_parser.add_argument(
241- '--password',
242- help='Password for interacting with an offline proxy',
243- default=os.environ.get('SNAP_PROXY_PASSWORD')
244+ "--password",
245+ help="Password for interacting with an offline proxy",
246+ default=os.environ.get("SNAP_PROXY_PASSWORD"),
247 )
248 push_snap_parser.set_defaults(func=push_snap)
249
250@@ -129,5 +143,5 @@ def parse_args():
251 return parser.parse_args()
252
253
254-if __name__ == '__main__':
255+if __name__ == "__main__":
256 sys.exit(main())

Subscribers

People subscribed via source and target branches

to all changes: