Merge lp:~ericsnowcurrently/fake-juju/python-lib-init into lp:~landscape/fake-juju/trunk-old

Proposed by Eric Snow
Status: Merged
Approved by: Eric Snow
Approved revision: 38
Merged at revision: 37
Proposed branch: lp:~ericsnowcurrently/fake-juju/python-lib-init
Merge into: lp:~landscape/fake-juju/trunk-old
Diff against target: 344 lines (+318/-0)
5 files modified
python/LICENSE (+191/-0)
python/Makefile (+9/-0)
python/README.md (+1/-0)
python/fakejuju/__init__.py (+48/-0)
python/setup.py (+69/-0)
To merge this branch: bzr merge lp:~ericsnowcurrently/fake-juju/python-lib-init
Reviewer Review Type Date Requested Status
Chad Smith Approve
Free Ekanayaka (community) Approve
🤖 Landscape Builder test results Approve
Review via email: mp+307889@code.launchpad.net

Commit message

Init the Python project for a fake-juju library.

Description of the change

Init the Python project for a fake-juju library.

To post a comment you must log in.
Revision history for this message
🤖 Landscape Builder (landscape-builder) :
review: Abstain (executing tests)
Revision history for this message
🤖 Landscape Builder (landscape-builder) wrote :

Command: make ci-test
Result: Success
Revno: 38
Branch: lp:~ericsnowcurrently/fake-juju/python-lib-init
Jenkins: https://ci.lscape.net/job/latch-test-xenial/14/

review: Approve (test results)
Revision history for this message
Free Ekanayaka (free.ekanayaka) wrote :

Nice job, thanks for the diligence. +1

review: Approve
Revision history for this message
Chad Smith (chad.smith) wrote :

I'll probably need a bit of guidance on intent here.

# seems to pull in fakejuju/__init__.py fine into the build directory.
cd python; python setup.py build

although python setup.py test chokes trying to find a distribution of txjuju, how will we be pulling txjuju dependencies?

Revision history for this message
Chad Smith (chad.smith) :
review: Needs Information
Revision history for this message
Eric Snow (ericsnowcurrently) wrote :

> I'll probably need a bit of guidance on intent here.

The intent is to pull the fake-juju bits out of txjuju.testing and into a more useful fakejuju library here.

> # seems to pull in fakejuju/__init__.py fine into the build directory.
> cd python; python setup.py build
>
>
> although python setup.py test chokes trying to find a distribution of txjuju,
> how will we be pulling txjuju dependencies?

"python setup.py test"? Does that come for free? There aren't any tests in this patch. You are correct that setup.py won't work as-is. I'm okay with that. :) As long as the deb package works we're fine. The setup.py is mostly informational and useful for building the initial deb packaging code.

Revision history for this message
Eric Snow (ericsnowcurrently) :
Revision history for this message
Chad Smith (chad.smith) wrote :

Thanks for the IRC discussion on this. I wrapped myself around the axle actually trying to build a deb package from this new setup.py as I thought it implied you wanted to use this in the future to generate deb packages.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added directory 'python'
2=== added file 'python/LICENSE'
3--- python/LICENSE 1970-01-01 00:00:00 +0000
4+++ python/LICENSE 2016-10-06 21:47:41 +0000
5@@ -0,0 +1,191 @@
6+All files in this repository are licensed as follows. If you contribute
7+to this repository, it is assumed that you license your contribution
8+under the same license unless you state otherwise.
9+
10+All files Copyright (C) 2012-2016 Canonical Ltd. unless otherwise specified in the file.
11+
12+This software is licensed under the LGPLv3, included below.
13+
14+As a special exception to the GNU Lesser General Public License version 3
15+("LGPL3"), the copyright holders of this Library give you permission to
16+convey to a third party a Combined Work that links statically or dynamically
17+to this Library without providing any Minimal Corresponding Source or
18+Minimal Application Code as set out in 4d or providing the installation
19+information set out in section 4e, provided that you comply with the other
20+provisions of LGPL3 and provided that you meet, for the Application the
21+terms and conditions of the license(s) which apply to the Application.
22+
23+Except as stated in this special exception, the provisions of LGPL3 will
24+continue to comply in full to this Library. If you modify this Library, you
25+may apply this exception to your version of this Library, but you are not
26+obliged to do so. If you do not wish to do so, delete this exception
27+statement from your version. This exception does not (and cannot) modify any
28+license terms which apply to the Application, with which you must still
29+comply.
30+
31+
32+ GNU LESSER GENERAL PUBLIC LICENSE
33+ Version 3, 29 June 2007
34+
35+ Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
36+ Everyone is permitted to copy and distribute verbatim copies
37+ of this license document, but changing it is not allowed.
38+
39+
40+ This version of the GNU Lesser General Public License incorporates
41+the terms and conditions of version 3 of the GNU General Public
42+License, supplemented by the additional permissions listed below.
43+
44+ 0. Additional Definitions.
45+
46+ As used herein, "this License" refers to version 3 of the GNU Lesser
47+General Public License, and the "GNU GPL" refers to version 3 of the GNU
48+General Public License.
49+
50+ "The Library" refers to a covered work governed by this License,
51+other than an Application or a Combined Work as defined below.
52+
53+ An "Application" is any work that makes use of an interface provided
54+by the Library, but which is not otherwise based on the Library.
55+Defining a subclass of a class defined by the Library is deemed a mode
56+of using an interface provided by the Library.
57+
58+ A "Combined Work" is a work produced by combining or linking an
59+Application with the Library. The particular version of the Library
60+with which the Combined Work was made is also called the "Linked
61+Version".
62+
63+ The "Minimal Corresponding Source" for a Combined Work means the
64+Corresponding Source for the Combined Work, excluding any source code
65+for portions of the Combined Work that, considered in isolation, are
66+based on the Application, and not on the Linked Version.
67+
68+ The "Corresponding Application Code" for a Combined Work means the
69+object code and/or source code for the Application, including any data
70+and utility programs needed for reproducing the Combined Work from the
71+Application, but excluding the System Libraries of the Combined Work.
72+
73+ 1. Exception to Section 3 of the GNU GPL.
74+
75+ You may convey a covered work under sections 3 and 4 of this License
76+without being bound by section 3 of the GNU GPL.
77+
78+ 2. Conveying Modified Versions.
79+
80+ If you modify a copy of the Library, and, in your modifications, a
81+facility refers to a function or data to be supplied by an Application
82+that uses the facility (other than as an argument passed when the
83+facility is invoked), then you may convey a copy of the modified
84+version:
85+
86+ a) under this License, provided that you make a good faith effort to
87+ ensure that, in the event an Application does not supply the
88+ function or data, the facility still operates, and performs
89+ whatever part of its purpose remains meaningful, or
90+
91+ b) under the GNU GPL, with none of the additional permissions of
92+ this License applicable to that copy.
93+
94+ 3. Object Code Incorporating Material from Library Header Files.
95+
96+ The object code form of an Application may incorporate material from
97+a header file that is part of the Library. You may convey such object
98+code under terms of your choice, provided that, if the incorporated
99+material is not limited to numerical parameters, data structure
100+layouts and accessors, or small macros, inline functions and templates
101+(ten or fewer lines in length), you do both of the following:
102+
103+ a) Give prominent notice with each copy of the object code that the
104+ Library is used in it and that the Library and its use are
105+ covered by this License.
106+
107+ b) Accompany the object code with a copy of the GNU GPL and this license
108+ document.
109+
110+ 4. Combined Works.
111+
112+ You may convey a Combined Work under terms of your choice that,
113+taken together, effectively do not restrict modification of the
114+portions of the Library contained in the Combined Work and reverse
115+engineering for debugging such modifications, if you also do each of
116+the following:
117+
118+ a) Give prominent notice with each copy of the Combined Work that
119+ the Library is used in it and that the Library and its use are
120+ covered by this License.
121+
122+ b) Accompany the Combined Work with a copy of the GNU GPL and this license
123+ document.
124+
125+ c) For a Combined Work that displays copyright notices during
126+ execution, include the copyright notice for the Library among
127+ these notices, as well as a reference directing the user to the
128+ copies of the GNU GPL and this license document.
129+
130+ d) Do one of the following:
131+
132+ 0) Convey the Minimal Corresponding Source under the terms of this
133+ License, and the Corresponding Application Code in a form
134+ suitable for, and under terms that permit, the user to
135+ recombine or relink the Application with a modified version of
136+ the Linked Version to produce a modified Combined Work, in the
137+ manner specified by section 6 of the GNU GPL for conveying
138+ Corresponding Source.
139+
140+ 1) Use a suitable shared library mechanism for linking with the
141+ Library. A suitable mechanism is one that (a) uses at run time
142+ a copy of the Library already present on the user's computer
143+ system, and (b) will operate properly with a modified version
144+ of the Library that is interface-compatible with the Linked
145+ Version.
146+
147+ e) Provide Installation Information, but only if you would otherwise
148+ be required to provide such information under section 6 of the
149+ GNU GPL, and only to the extent that such information is
150+ necessary to install and execute a modified version of the
151+ Combined Work produced by recombining or relinking the
152+ Application with a modified version of the Linked Version. (If
153+ you use option 4d0, the Installation Information must accompany
154+ the Minimal Corresponding Source and Corresponding Application
155+ Code. If you use option 4d1, you must provide the Installation
156+ Information in the manner specified by section 6 of the GNU GPL
157+ for conveying Corresponding Source.)
158+
159+ 5. Combined Libraries.
160+
161+ You may place library facilities that are a work based on the
162+Library side by side in a single library together with other library
163+facilities that are not Applications and are not covered by this
164+License, and convey such a combined library under terms of your
165+choice, if you do both of the following:
166+
167+ a) Accompany the combined library with a copy of the same work based
168+ on the Library, uncombined with any other library facilities,
169+ conveyed under the terms of this License.
170+
171+ b) Give prominent notice with the combined library that part of it
172+ is a work based on the Library, and explaining where to find the
173+ accompanying uncombined form of the same work.
174+
175+ 6. Revised Versions of the GNU Lesser General Public License.
176+
177+ The Free Software Foundation may publish revised and/or new versions
178+of the GNU Lesser General Public License from time to time. Such new
179+versions will be similar in spirit to the present version, but may
180+differ in detail to address new problems or concerns.
181+
182+ Each version is given a distinguishing version number. If the
183+Library as you received it specifies that a certain numbered version
184+of the GNU Lesser General Public License "or any later version"
185+applies to it, you have the option of following the terms and
186+conditions either of that published version or of any later version
187+published by the Free Software Foundation. If the Library as you
188+received it does not specify a version number of the GNU Lesser
189+General Public License, you may choose any version of the GNU Lesser
190+General Public License ever published by the Free Software Foundation.
191+
192+ If the Library as you received it specifies that a proxy can decide
193+whether future versions of the GNU Lesser General Public License shall
194+apply, that proxy's public statement of acceptance of any version is
195+permanent authorization for you to choose that version for the
196+Library.
197
198=== added file 'python/Makefile'
199--- python/Makefile 1970-01-01 00:00:00 +0000
200+++ python/Makefile 2016-10-06 21:47:41 +0000
201@@ -0,0 +1,9 @@
202+PYTHON = python
203+
204+.PHONY: test
205+test:
206+ $(PYTHON) -m unittest discover -t $(shell pwd) -s $(shell pwd)/fakejuju
207+
208+.PHONY: install-dev
209+install-dev:
210+ ln -s $(shell pwd)/fakejuju /usr/local/lib/python2.7/dist-packages/fakejuju
211
212=== added file 'python/README.md'
213--- python/README.md 1970-01-01 00:00:00 +0000
214+++ python/README.md 2016-10-06 21:47:41 +0000
215@@ -0,0 +1,1 @@
216+# fakejuju
217
218=== added directory 'python/fakejuju'
219=== added file 'python/fakejuju/__init__.py'
220--- python/fakejuju/__init__.py 1970-01-01 00:00:00 +0000
221+++ python/fakejuju/__init__.py 2016-10-06 21:47:41 +0000
222@@ -0,0 +1,48 @@
223+# Copyright 2016 Canonical Limited. All rights reserved.
224+
225+"""Support for interaction with fake-juju.
226+
227+"fake-juju" is a combination of the juju and jujud commands that is
228+suitable for use in integration tests. It exposes a limited subset
229+of the standard juju subcommands (see FakeJuju in this module for
230+specifics). When called without any arguments it runs jujud (using
231+the dummy provider) with extra logging and testing hooks available to
232+control failures. See https://launchpad.net/fake-juju for the project.
233+
234+The binary is named with the Juju version for which it was built.
235+For example, for version 1.25.6 the file is named "fake-juju-1.25.6".
236+
237+fake-juju uses the normal Juju local config directory. This defaults
238+to ~/.local/shared/juju and may be set using the JUJU_DATA environment
239+variable (in 2.x, for 1.x it is JUJU_HOME).
240+
241+In addition to all the normal Juju environment variables (e.g.
242+JUJU_DATA), fake-juju uses the following:
243+
244+ FAKE_JUJU_FAILURES - the path to the failures file
245+ The Failures class below sets this to $JUJU_DATA/juju-failures.
246+ FAKE_JUJU_LOGS_DIR - the path to the logs directory
247+ This defaults to $JUJU_DATA.
248+
249+fake-juju also creates several extra files:
250+
251+ $FAKE_JUJU_LOGS_DIR/fake-juju.log - where fake-juju logs are written
252+ $JUJU_DATA/fakejuju - fake-juju's data cache
253+ $JUJU_DATA/fifo - a FIFO file that triggers jujud shutdown
254+ $JUJU_DATA/cert.ca - the API's CA certificate
255+
256+Normal Juju logging for is written to $JUJU_DATA/fake-juju.log.
257+
258+Failures may be injected into a running fake-juju (or set before
259+running). They may be injected by adding them to the file identified
260+by $FAKE_JUJU_FAILURES. The format is a single failure definition per
261+line. The syntax of the failure definition depends on the failure.
262+The currently supported failures (with their definition syntax) are
263+listed here:
264+
265+ * when adding a unit with a specific ID
266+ format: "unit-<ID>" (e.g. unit-mysql/0)
267+
268+"""
269+
270+__version__ = "0.9.0b1"
271
272=== added file 'python/setup.py'
273--- python/setup.py 1970-01-01 00:00:00 +0000
274+++ python/setup.py 2016-10-06 21:47:41 +0000
275@@ -0,0 +1,69 @@
276+import os
277+from importlib import import_module
278+try:
279+ from setuptools import setup
280+except ImportError:
281+ from distutils.core import setup
282+
283+
284+basedir = os.path.abspath(os.path.dirname(__file__) or '.')
285+
286+# required data
287+
288+package_name = 'fakejuju'
289+NAME = package_name
290+SUMMARY = 'A limited adaptation of Juju\'s client, with testing hooks.'
291+AUTHOR = 'Canonical Landscape team'
292+EMAIL = 'juju@lists.ubuntu.com'
293+PROJECT_URL = 'https://launchpad.net/fake-juju'
294+LICENSE = 'LGPLv3'
295+
296+with open(os.path.join(basedir, 'README.md')) as readme_file:
297+ DESCRIPTION = readme_file.read()
298+
299+# dymanically generated data
300+
301+VERSION = import_module(package_name).__version__
302+
303+# set up packages
304+
305+exclude_dirs = [
306+ 'tests',
307+ ]
308+
309+PACKAGES = []
310+for path, dirs, files in os.walk(package_name):
311+ if "__init__.py" not in files:
312+ continue
313+ path = path.split(os.sep)
314+ if path[-1] in exclude_dirs:
315+ continue
316+ PACKAGES.append(".".join(path))
317+
318+# dependencies
319+
320+DEPS = ['yaml',
321+ # for testing
322+ 'txjuju',
323+ 'fixtures',
324+ 'testtools',
325+ ]
326+
327+
328+if __name__ == "__main__":
329+ setup(name=NAME,
330+ version=VERSION,
331+ author=AUTHOR,
332+ author_email=EMAIL,
333+ url=PROJECT_URL,
334+ license=LICENSE,
335+ description=SUMMARY,
336+ long_description=DESCRIPTION,
337+ packages=PACKAGES,
338+
339+ # for distutils
340+ requires=DEPS,
341+
342+ # for setuptools
343+ install_requires=DEPS,
344+ )

Subscribers

People subscribed via source and target branches

to all changes: