Merge lp:~frankban/juju-quickstart/add-tox into lp:juju-quickstart

Proposed by Francesco Banconi
Status: Merged
Merged at revision: 116
Proposed branch: lp:~frankban/juju-quickstart/add-tox
Merge into: lp:juju-quickstart
Diff against target: 765 lines (+414/-171)
9 files modified
.bzrignore (+3/-1)
HACKING.rst (+85/-45)
MANIFEST.in (+5/-4)
Makefile (+76/-45)
requirements.pip (+0/-31)
setup.cfg (+20/-0)
setup.py (+110/-22)
test-requirements.pip (+0/-23)
tox.ini (+115/-0)
To merge this branch: bzr merge lp:~frankban/juju-quickstart/add-tox
Reviewer Review Type Date Requested Status
Juju GUI Hackers Pending
Review via email: mp+246761@code.launchpad.net

Description of the change

Introduce tox for testing multiple sets of deps.

Quickstart must be run on several platforms/Ubuntu series,
each one with its own versions of the packages that
Quickstart depends on. The tox utility is used for both:
- handling those kind of separate scenarios;
- creating the development virtual environments.
The latter was previously done using virtualenv directly
in the Makefile. The new infrastructure should be
more flexible.

Update the relevant parts of the Makefile, also handling
the automatic installation of system dependencies.

Implement the ability to calculate the requirements
for the PyPI package automatically by parsing the
tox.ini file. I am not really sure about the method I
used (take a look at the setup.py file), but the
alternative is to manually update those and violate DRY.
I think we could give it a try and fall back to the
manual approach if required.

Also implement a correct behavior for
"python setup.py test", which now runs all the tests.

To test and QA this branch, run `make clean` and then
follow what described in the HACKING.rst file, in the
following paragraphs:
- Creating a development environment
- Testing and debugging the application
- Requirements
- Updating application and test dependencies

Thank you!

https://codereview.appspot.com/189580044/

To post a comment you must log in.
Revision history for this message
Francesco Banconi (frankban) wrote :

Reviewers: mp+246761_code.launchpad.net,

Message:
Please take a look.

Description:
Introduce tox for testing multiple sets of deps.

Quickstart must be run on several platforms/Ubuntu series,
each one with its own versions of the packages that
Quickstart depends on. The tox utility is used for both:
- handling those kind of separate scenarios;
- creating the development virtual environments.
The latter was previously done using virtualenv directly
in the Makefile. The new infrastructure should be
more flexible.

Update the relevant parts of the Makefile, also handling
the automatic installation of system dependencies.

Implement the ability to calculate the requirements
for the PyPI package automatically by parsing the
tox.ini file. I am not really sure about the method I
used (take a look at the setup.py file), but the
alternative is to manually update those and violate DRY.
I think we could give it a try and fall back to the
manual approach if required.

Also implement a correct behavior for
"python setup.py test", which now runs all the tests.

To test and QA this branch, run `make clean` and then
follow what described in the HACKING.rst file, in the
following paragraphs:
- Creating a development environment
- Testing and debugging the application
- Requirements
- Updating application and test dependencies

Thank you!

https://code.launchpad.net/~frankban/juju-quickstart/add-tox/+merge/246761

(do not edit description out of merge proposal)

Please review this at https://codereview.appspot.com/189580044/

Affected files (+409, -171 lines):
   M .bzrignore
   M HACKING.rst
   M MANIFEST.in
   M Makefile
   A [revision details]
   D requirements.pip
   A setup.cfg
   M setup.py
   D test-requirements.pip
   A tox.ini

Revision history for this message
Brad Crittenden (bac) wrote :

LGTM. Did not try to QA yet. Tox may be very interesting for lots of our
projects.

https://codereview.appspot.com/189580044/diff/1/HACKING.rst
File HACKING.rst (right):

https://codereview.appspot.com/189580044/diff/1/HACKING.rst#newcode356
HACKING.rst:356: parsing ``tox.ini``, dependencies must be listed with
the following rules:
Could you try to re-word that sentence? I'm not sure what you're saying.

https://codereview.appspot.com/189580044/diff/1/HACKING.rst#newcode358
HACKING.rst:358: - each scenario must at least include a
"{[testenv]deps}" line in its deps:
Change the : to ; or ,

https://codereview.appspot.com/189580044/diff/1/MANIFEST.in
File MANIFEST.in (right):

https://codereview.appspot.com/189580044/diff/1/MANIFEST.in#newcode24
MANIFEST.in:24: # tox.ini file, removing it from this list will break
the source distribution
Again, this could be worded better.

https://codereview.appspot.com/189580044/diff/1/setup.py
File setup.py (right):

https://codereview.appspot.com/189580044/diff/1/setup.py#newcode43
setup.py:43: """Return Juju Quickstart package data by walking through
the project."""
A better explanation of what "package data" is would be nice.

https://codereview.appspot.com/189580044/diff/1/setup.py#newcode74
setup.py:74: for requirement in deps:
Maybe add

requirement = requirement.strip()

https://codereview.appspot.com/189580044/diff/1/tox.ini
File tox.ini (right):

https://codereview.appspot.com/189580044/diff/1/tox.ini#newcode42
tox.ini:42: basepython = python2.7
Is it required to repeat here?

https://codereview.appspot.com/189580044/

lp:~frankban/juju-quickstart/add-tox updated
130. By Francesco Banconi

Changes as per review.

Revision history for this message
Francesco Banconi (frankban) wrote :

Please take a look.

https://codereview.appspot.com/189580044/diff/1/HACKING.rst
File HACKING.rst (right):

https://codereview.appspot.com/189580044/diff/1/HACKING.rst#newcode356
HACKING.rst:356: parsing ``tox.ini``, dependencies must be listed with
the following rules:
On 2015/01/22 16:15:27, bac wrote:
> Could you try to re-word that sentence? I'm not sure what you're
saying.

Done.

https://codereview.appspot.com/189580044/diff/1/HACKING.rst#newcode358
HACKING.rst:358: - each scenario must at least include a
"{[testenv]deps}" line in its deps:
On 2015/01/22 16:15:27, bac wrote:
> Change the : to ; or ,

Done.

https://codereview.appspot.com/189580044/diff/1/MANIFEST.in
File MANIFEST.in (right):

https://codereview.appspot.com/189580044/diff/1/MANIFEST.in#newcode24
MANIFEST.in:24: # tox.ini file, removing it from this list will break
the source distribution
On 2015/01/22 16:15:27, bac wrote:
> Again, this could be worded better.

Done.

https://codereview.appspot.com/189580044/diff/1/setup.py
File setup.py (right):

https://codereview.appspot.com/189580044/diff/1/setup.py#newcode43
setup.py:43: """Return Juju Quickstart package data by walking through
the project."""
On 2015/01/22 16:15:27, bac wrote:
> A better explanation of what "package data" is would be nice.

Done.

https://codereview.appspot.com/189580044/diff/1/setup.py#newcode74
setup.py:74: for requirement in deps:
On 2015/01/22 16:15:27, bac wrote:
> Maybe add

> requirement = requirement.strip()

Done.

https://codereview.appspot.com/189580044/diff/1/tox.ini
File tox.ini (right):

https://codereview.appspot.com/189580044/diff/1/tox.ini#newcode42
tox.ini:42: basepython = python2.7
On 2015/01/22 16:15:27, bac wrote:
> Is it required to repeat here?

No it's not. Good catch!

https://codereview.appspot.com/189580044/

Revision history for this message
Brad Crittenden (bac) wrote :

Code is LGTM with the one suggestion for the Makefile.

QA OK on trusty

On OS X, the 'make sysdeps' suggests you use brew to install python-dev
python-setuptools and python-pip. Those package names are not the same
in brew and pip is installed via 'brew install python'. I'm not sure if
the equivalent of python-dev gets installed but 'make check' ran fine.

Perhaps you can adjust the message to be less misleading.

https://codereview.appspot.com/189580044/diff/20001/Makefile
File Makefile (right):

https://codereview.appspot.com/189580044/diff/20001/Makefile#newcode44
Makefile:44:
It is a bit odd to touch the canary on an non-Debian system when the
sysdeps were not installed.

https://codereview.appspot.com/189580044/

Revision history for this message
Jeff Pihach (hatch) wrote :

LGTM Thanks for all that this should help simplify testing quite a bit

https://codereview.appspot.com/189580044/

Revision history for this message
Francesco Banconi (frankban) wrote :

Thanks for the reviews!

https://codereview.appspot.com/189580044/diff/20001/Makefile
File Makefile (right):

https://codereview.appspot.com/189580044/diff/20001/Makefile#newcode44
Makefile:44:
On 2015/01/30 15:38:52, bac wrote:
> It is a bit odd to touch the canary on an non-Debian system when the
sysdeps
> were not installed.

I modified the message to be more clear. We need to touch the file so
that OSX users having all the required sysdeps installed can still
proceed without seeing the message each time.

https://codereview.appspot.com/189580044/

lp:~frankban/juju-quickstart/add-tox updated
131. By Francesco Banconi

Improve sysdeps message in Makefile.

Revision history for this message
Francesco Banconi (frankban) wrote :

*** Submitted:

Introduce tox for testing multiple sets of deps.

Quickstart must be run on several platforms/Ubuntu series,
each one with its own versions of the packages that
Quickstart depends on. The tox utility is used for both:
- handling those kind of separate scenarios;
- creating the development virtual environments.
The latter was previously done using virtualenv directly
in the Makefile. The new infrastructure should be
more flexible.

Update the relevant parts of the Makefile, also handling
the automatic installation of system dependencies.

Implement the ability to calculate the requirements
for the PyPI package automatically by parsing the
tox.ini file. I am not really sure about the method I
used (take a look at the setup.py file), but the
alternative is to manually update those and violate DRY.
I think we could give it a try and fall back to the
manual approach if required.

Also implement a correct behavior for
"python setup.py test", which now runs all the tests.

To test and QA this branch, run `make clean` and then
follow what described in the HACKING.rst file, in the
following paragraphs:
- Creating a development environment
- Testing and debugging the application
- Requirements
- Updating application and test dependencies

Thank you!

R=bac, benjamin.saller, jeff.pihach
CC=
https://codereview.appspot.com/189580044

https://codereview.appspot.com/189580044/

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file '.bzrignore'
--- .bzrignore 2013-11-06 10:16:42 +0000
+++ .bzrignore 2015-01-30 16:35:06 +0000
@@ -1,8 +1,10 @@
1.coverage1.coverage
2.DS_Store2.DS_Store
3.emacs*3.emacs*
4.venv4.sysdeps-installed
5.tox
5build6build
7devenv
6dist8dist
7juju_quickstart.egg-info9juju_quickstart.egg-info
8MANIFEST10MANIFEST
911
=== modified file 'HACKING.rst'
--- HACKING.rst 2015-01-13 12:03:15 +0000
+++ HACKING.rst 2015-01-30 16:35:06 +0000
@@ -11,35 +11,68 @@
11Creating a development environment11Creating a development environment
12~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~12~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1313
14The development environment is created in a virtualenv. The environment14The development environment is created using the
15creation requires the *make*, *pip* and *virtualenv* programs to be installed.15`tox <https://tox.readthedocs.org/en/latest/>`_ utility. To create the
16To do that, run the following::16environment, just run ``make``. The first time it is run, ``make`` also
1717installs the required system dependencies. For this reason sudo privileges can
18 $ make sysdeps18be asked in the process. When the command completes the development environment
1919is ready and placed in the ``devenv`` directory inside the project's root.
20At this point, from the root of this branch, run the command::20
2121At this point it is possible to start contributing to the project. The steps
22 $ make22for testing the application and running Juju Quickstart in development mode are
2323described below. Thanks for contributing!
24This command will create a ``.venv`` directory in the branch root, ignored
25by DVCSes, containing the development virtual environment with all the
26dependencies.
2724
28Testing and debugging the application25Testing and debugging the application
29~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~26~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3027
31Run the tests::28With the development environment correctly set up (after running ``make``), it
29is easy to run the tests with the following command::
3230
33 $ make test31 $ make test
3432
35Run the tests and lint/pep8 checks::33It is also possible to run a subset of the test suite by using nose directly,
34as it is already installed in the development environment, e.g.::
35
36 $ devenv/bin/nosetests quickstart/tests/test_app.py:TestWatch
37
38To run the development version of Juju Quickstart while making changes, or
39while reviewing a branch, use the following command::
40
41 $ devenv/bin/juju-quickstart
42
43The command above receives all usual Juju Quickstart arguments, so, for
44instance, to start the interactive session::
45
46 $ devenv/bin/juju-quickstart -i
47
48To run the Python linter and pep8 checks, use the following command::
49
50 $ make lint
51
52When a feature branch is ready, before proposing it, check that the code tests
53pass when Juju Quickstart is installed using the dependencies present in all
54supported platforms and Ubuntu series. To do that, run the following::
3655
37 $ make check56 $ make check
3857
39Display help about all the available make targets, including instructions on58The above leverages tox ability to create multiple virtual environments, each
40setting up and running the application in the development environment::59one with a specific set of requirements. The ``make check`` command is also
4160run automatically when proposing a branch with ``lbox propose``.
42 $ make help61
62As a final note, having the development environment ready, it is also possible
63to use the ``tox`` command directly on the project. For instance, to run the
64tests only on the ``vivid`` scenario, use the following::
65
66 $ tox -e vivid
67
68Run ``make help`` for more information about all the available make targets.
69
70Requirements
71~~~~~~~~~~~~
72
73The Python requirements for Juju Quickstart are dynamically generated by
74parsing the ``tox.ini`` file. To check the requirements list, run
75``make requirements``.
4376
44Installing the application77Installing the application
45~~~~~~~~~~~~~~~~~~~~~~~~~~78~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -67,12 +100,6 @@
67100
68 $ juju quickstart -e local101 $ juju quickstart -e local
69102
70If you have not installed the application using ``sudo make install``, as
71described above, you can run it locally using the virtualenv's Python
72installation::
73
74 $ .venv/bin/python juju-quickstart --help
75
76Project structure103Project structure
77~~~~~~~~~~~~~~~~~104~~~~~~~~~~~~~~~~~
78105
@@ -203,7 +230,8 @@
203packaging branch root. To print the version of the current Quickstart, from the230packaging branch root. To print the version of the current Quickstart, from the
204juju-quickstart branch root, run the following::231juju-quickstart branch root, run the following::
205232
206 $ .venv/bin/python juju-quickstart --version233 $ make
234 $ devenv/bin/juju-quickstart --version
207235
208If the ``debian/changelog`` file is outdated, install the ``devscripts``236If the ``debian/changelog`` file is outdated, install the ``devscripts``
209package and use ``dch`` to update the changelog, e.g.::237package and use ``dch`` to update the changelog, e.g.::
@@ -247,8 +275,8 @@
247Creating a Homebrew release275Creating a Homebrew release
248~~~~~~~~~~~~~~~~~~~~~~~~~~~276~~~~~~~~~~~~~~~~~~~~~~~~~~~
249277
250The brew formula fetches its source from PyPI, so it must be done after the PyPI278The brew formula fetches its source from PyPI, so it must be done after the
251release.279PyPI release.
252280
2531. Start with a fresh brew::2811. Start with a fresh brew::
254282
@@ -303,8 +331,8 @@
303#. Go to https://github.com/juju/homebrew to create a pull request.331#. Go to https://github.com/juju/homebrew to create a pull request.
304#. Copy the debian/changelog from the lp:juju-quickstart/packaging as the pull332#. Copy the debian/changelog from the lp:juju-quickstart/packaging as the pull
305 request comment. Keep the name simple, e.g. 'juju-quickstart 1.4.0'.333 request comment. Keep the name simple, e.g. 'juju-quickstart 1.4.0'.
306#. Watch the pull request and ensure it passes Jenkins. If changes must be made,334#. Watch the pull request and ensure it passes Jenkins. If changes must be
307 rebase the branch and squash commits before pushing.335 made, rebase the branch and squash commits before pushing.
308#. If the branch makes it through CI without errors it will be accepted and336#. If the branch makes it through CI without errors it will be accepted and
309 merged without human intervention. A recent branch took about two hours337 merged without human intervention. A recent branch took about two hours
310 from the time the pull request was made.338 from the time the pull request was made.
@@ -323,17 +351,19 @@
323Updating application and test dependencies351Updating application and test dependencies
324~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~352~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
325353
326Test dependencies are listed in the ``test-requirements.pip`` file in the354Test and application dependencies are listed in the ``tox.ini`` file in the
327branch root, application ones in the ``requirements.pip`` file. The former355branch root. Note that, since the source requirements are dynamically generated
328includes the latter, so any updates to the application requirements will also356parsing ``tox.ini``, when updating the list of dependencies in ``tox.ini``,
329update the test dependencies and therefore the testing virtual environment.357these rules must be followed:
330Note that, since the source requirements are dynamically generated parsing358
331``requirements.pip``, that file must only include ``PACKAGE==VERSION`` formatted359- each scenario must at least include a "{[testenv]deps}" line in its deps,
332dependencies, and not other pip specific requirement specifications.360 this way tests can be run correctly inside the virtualenv;
333361- keep each requirement in deps in its own line;
334Also ensure, before updating the application dependencies, that those packages362- always use specific revisions for environments (i.e. always use "==").
335are available in the main Ubuntu repositories for the series we support (from363
336precise to vivid), or in the `Juju Quickstart Beta PPA364Also ensure, before updating the application dependencies, that the package
365versions reflect the ones available for each supported platform and in the
366`Juju Quickstart Beta PPA
337<https://launchpad.net/~juju-gui/+archive/quickstart-beta/+packages>`_.367<https://launchpad.net/~juju-gui/+archive/quickstart-beta/+packages>`_.
338368
339Please also keep up to date the possible values for the environments.yaml369Please also keep up to date the possible values for the environments.yaml
@@ -341,6 +371,16 @@
341set of series supported by the Juju GUI charm371set of series supported by the Juju GUI charm
342(see ``quickstart.settings.JUJU_GUI_SUPPORTED_SERIES``).372(see ``quickstart.settings.JUJU_GUI_SUPPORTED_SERIES``).
343373
374When introducing a new supported platform, do the following:
375
376- add a new section in the ``tox.ini`` file with a sensible name and list the
377 dependencies that we expect to be found on that platform/series;
378- add the platform name to the envlist option (in the tox section of the file);
379- if required, update ``quickstart.settings.JUJU_GUI_SUPPORTED_SERIES``;
380- run ``make requirements`` and ensure that the dynamically generated list of
381 requirements make sense;
382- run ``make check`` and ensure all the tests pass.
383
344Debugging bundle support384Debugging bundle support
345~~~~~~~~~~~~~~~~~~~~~~~~385~~~~~~~~~~~~~~~~~~~~~~~~
346386
@@ -356,10 +396,10 @@
356information about what is going on. The GUI builtin server exposes some bundle396information about what is going on. The GUI builtin server exposes some bundle
357information in two places:397information in two places:
358398
359- ``https://<juju-gui-url>/gui-server-info`` displays in JSON format the current399- ``https://<juju-gui-url>/gui-server-info`` displays in JSON format the
360 status of all scheduled/started/completed bundle deployments;400 current status of all scheduled/started/completed bundle deployments;
361- ``/var/log/upstart/guiserver.log`` is the builtin server log file, which includes401- ``/var/log/upstart/guiserver.log`` is the builtin server log file, which
362 logs output from the juju-deployer library.402 includes logs output from the juju-deployer library.
363403
364Moreover, setting ``builtin-server-logging=debug`` gives more debugging404Moreover, setting ``builtin-server-logging=debug`` gives more debugging
365information, e.g. it prints to the log the contents of the WebSocket messages405information, e.g. it prints to the log the contents of the WebSocket messages
366406
=== modified file 'MANIFEST.in'
--- MANIFEST.in 2014-03-13 11:56:58 +0000
+++ MANIFEST.in 2015-01-30 16:35:06 +0000
@@ -19,8 +19,9 @@
19include MANIFEST.in19include MANIFEST.in
20include Makefile20include Makefile
21include README.rst21include README.rst
22include setup.cfg
22# Note: since the source requirements are dynamically generated parsing the23# Note: since the source requirements are dynamically generated parsing the
23# requirements.pip file, removing it from this list will break the source24# tox.ini file, removing the "include tox.ini" entry below from this list would
24# distribution and therefore the Debian package builds. Do not do that.25# break the source distribution and therefore the Debian package builds.
25include requirements.pip26# Do not do that.
26include test-requirements.pip27include tox.ini
2728
=== modified file 'Makefile'
--- Makefile 2014-09-05 14:54:31 +0000
+++ Makefile 2015-01-30 16:35:06 +0000
@@ -15,75 +15,106 @@
15# along with this program. If not, see <http://www.gnu.org/licenses/>.15# along with this program. If not, see <http://www.gnu.org/licenses/>.
1616
17PYTHON = python17PYTHON = python
18SYSDEPS = build-essential python-dev python-pip python-virtualenv18APT_SYSDEPS = python-dev python-pip python-setuptools
1919# Since the python-tox package in Ubuntu uses Python 3, use pip to install tox
20VENV = .venv20# instead. This also works on OSX where tox is not present in Homebrew.
21VENV_ACTIVATE = $(VENV)/bin/activate21PIP_SYSDEPS = tox
2222
2323SYSDEPS_INSTALLED = .sysdeps-installed
24$(VENV_ACTIVATE): test-requirements.pip requirements.pip24DEVENV = devenv
25 virtualenv --distribute -p $(PYTHON) $(VENV)25QUICKSTART = $(DEVENV)/bin/juju-quickstart
26 $(VENV)/bin/pip install -r test-requirements.pip || \26
27 (touch test-requirements.pip; exit 1)27.DEFAULT_GOAL := setup
28 @touch $(VENV_ACTIVATE)28
2929
30all: setup30$(QUICKSTART): juju-quickstart setup.py tox.ini
3131 @tox -e devenv
32check: test lint32
3333$(SYSDEPS_INSTALLED): Makefile
34ifeq ($(shell command -v apt-get > /dev/null; echo $$?),0)
35 sudo apt-get install --yes $(APT_SYSDEPS)
36else
37 @echo 'System dependencies can only be installed automatically on'
38 @echo 'systems with "apt-get". On OSX you can manually use Homebrew'
39 @echo 'if there are missing dependencies corresponding to the following'
40 @echo 'Debian packages:'
41 @echo '$(APT_SYSDEPS).'
42endif
43 sudo pip2 install $(PIP_SYSDEPS)
44 touch $(SYSDEPS_INSTALLED)
45
46
47.PHONY: check
48check: setup
49 @tox -e lint
50 @tox
51
52.PHONY: clean
34clean:53clean:
35 $(PYTHON) setup.py clean54 $(PYTHON) setup.py clean
36 rm -rfv build/ dist/ juju_quickstart.egg-info MANIFEST55 # Remove the development environments.
37 rm -rfv $(VENV)56 rm -rfv $(DEVENV) .tox/
57 # Remove distribution artifacts.
58 rm -rfv *.egg build/ dist/ juju_quickstart.egg-info/ MANIFEST
59 # Remove tests artifacts.
60 rm -fv .coverage
61 # Remove the sysdeps canary file.
62 rm -fv $(SYSDEPS_INSTALLED)
63 # Remove Python compiled bytecode.
38 find . -name '*.pyc' -delete64 find . -name '*.pyc' -delete
39 find . -name '__pycache__' -type d -delete65 find . -name '__pycache__' -type d -delete
4066 # Remove the virtualenv used in previous configurations.
41setup: $(VENV_ACTIVATE)67 rm -rfv .venv/
4268
69.PHONY: help
43help:70help:
44 @echo -e 'Juju Quickstart - list of make targets:\n'71 @echo -e 'Juju Quickstart - list of make targets:\n'
45 @echo 'make sysdeps - Install the development environment system packages.'
46 @echo 'make - Set up the development and testing environment.'72 @echo 'make - Set up the development and testing environment.'
47 @echo 'make test - Run tests.'73 @echo 'make test - Run tests.'
48 @echo 'make lint - Run linter and pep8.'74 @echo 'make lint - Run linter and pep8.'
49 @echo 'make check - Run tests, linter and pep8.'75 @echo 'make check - Run all the tests and lint in all supported scenarios.'
50 @echo 'make source - Create source package.'76 @echo 'make source - Create source package.'
51 @echo 'make install - Install on local system.'77 @echo 'make install - Install on local system.'
52 @echo 'make run - Run the application in the development environment.\n'78 @echo 'make clean - Get rid of bytecode files, build and dist dirs, venvs.'
53 @echo ' If "juju switch" has been used to set a default environment, that'
54 @echo ' environment will be used. It is possible to override the default'
55 @echo ' Juju environment by setting the JUJU_ENV environment variable,'
56 @echo ' e.g.: "make run JUJU_ENV=ec2".'
57 @echo 'make debug - Same as the "run" target but with the --debug flag.\n'
58 @echo 'make clean - Get rid of bytecode files, build and dist dirs, venv.'
59 @echo 'make release - Register and upload a release on PyPI.'79 @echo 'make release - Register and upload a release on PyPI.'
80 @echo 'make requirements - Print out the application requirements.'
81 @echo -e '\nAfter creating the development environment with "make", it is'
82 @echo 'also possible to do the following:'
83 @echo '- run the development version of Juju Quickstart by invoking'
84 @echo ' "$(QUICKSTART)";'
85 @echo '- run a specific subset of the test suite, e.g. with'
86 @echo ' "$(DEVENV)/bin/nosetests quickstart/tests/test_app.py:TestWatch";'
87 @echo '- use tox as usual on this project;'
88 @echo ' see https://tox.readthedocs.org/en/latest/'
6089
90.PHONY: install
61install:91install:
62 $(PYTHON) setup.py install92 $(PYTHON) setup.py install
63 rm -rfv ./build ./dist ./juju_quickstart.egg-info93 rm -rfv ./build ./dist ./juju_quickstart.egg-info
6494
95.PHONY: lint
65lint: setup96lint: setup
66 @$(VENV)/bin/flake8 --show-source --exclude=$(VENV) ./quickstart97 @$(DEVENV)/bin/flake8 --show-source quickstart
6798
99.PHONY: release
68release: check100release: check
69 $(PYTHON) setup.py register sdist upload101 $(PYTHON) setup.py register sdist upload
70102
71run: setup103.PHONY: requirements
72 $(VENV)/bin/python ./juju-quickstart104requirements:
73105 $(PYTHON) setup.py requirements
74debug: setup106
75 $(VENV)/bin/python ./juju-quickstart --debug107.PHONY: setup
76108setup: $(SYSDEPS_INSTALLED) $(QUICKSTART)
109
110.PHONY: source
77source:111source:
78 $(PYTHON) setup.py sdist112 $(PYTHON) setup.py sdist
79113
80sysdeps:114.PHONY: sysdeps
81 sudo apt-get install --yes $(SYSDEPS)115sysdeps: $(SYSDEPS_INSTALLED)
82116
117.PHONY: test
83test: setup118test: setup
84 @$(VENV)/bin/nosetests -s --verbosity=2 \119 @$(DEVENV)/bin/nosetests \
85 --with-coverage --cover-package=quickstart quickstart120 --with-coverage --cover-erase --cover-package quickstart
86 @rm .coverage
87
88.PHONY: all clean check debug help install lint release run setup source \
89 sysdeps test
90121
=== removed file 'requirements.pip'
--- requirements.pip 2014-09-05 14:54:31 +0000
+++ requirements.pip 1970-01-01 00:00:00 +0000
@@ -1,31 +0,0 @@
1# Juju Quickstart application requirements.
2
3# This file is part of the Juju Quickstart Plugin, which lets users set up a
4# Juju environment in very few steps (https://launchpad.net/juju-quickstart).
5# Copyright (C) 2013 Canonical Ltd.
6#
7# This program is free software: you can redistribute it and/or modify it under
8# the terms of the GNU Affero General Public License version 3, as published by
9# the Free Software Foundation.
10#
11# This program is distributed in the hope that it will be useful, but WITHOUT
12# ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
13# SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14# Affero General Public License for more details.
15#
16# You should have received a copy of the GNU Affero General Public License
17# along with this program. If not, see <http://www.gnu.org/licenses/>.
18
19# Note: since the source requirements are dynamically generated parsing the
20# requirements.pip file, the list below must only include PACKAGE==VERSION
21# formatted dependencies. Do not include other pip specific requirement
22# specifications (e.g. -e ... or -r ...).
23
24# XXX: BradCrittenden 2014-05-23: jujuclient 0.17.5 does not specify the
25# version of websocket-client to use. Remove websocket-client as a dependency
26# here when moving to a newer jujuclient that correctly specifies the
27# version.
28websocket-client==0.18.0
29jujuclient==0.18.4
30PyYAML==3.11
31urwid==1.2.1
320
=== added file 'setup.cfg'
--- setup.cfg 1970-01-01 00:00:00 +0000
+++ setup.cfg 2015-01-30 16:35:06 +0000
@@ -0,0 +1,20 @@
1# This file is part of the Juju Quickstart Plugin, which lets users set up a
2# Juju environment in very few steps (https://launchpad.net/juju-quickstart).
3# Copyright (C) 2015 Canonical Ltd.
4#
5# This program is free software: you can redistribute it and/or modify it under
6# the terms of the GNU Affero General Public License version 3, as published by
7# the Free Software Foundation.
8#
9# This program is distributed in the hope that it will be useful, but WITHOUT
10# ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
11# SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12# Affero General Public License for more details.
13#
14# You should have received a copy of the GNU Affero General Public License
15# along with this program. If not, see <http://www.gnu.org/licenses/>.
16
17[nosetests]
18detailed-errors=1
19nocapture=1
20verbosity=2
021
=== modified file 'setup.py'
--- setup.py 2014-01-29 15:25:06 +0000
+++ setup.py 2015-01-30 16:35:06 +0000
@@ -16,52 +16,140 @@
1616
17"""Juju Quickstart distribution file."""17"""Juju Quickstart distribution file."""
1818
19from __future__ import print_function
20
21import ConfigParser
22from distutils.core import Command
23from distutils.version import StrictVersion
19import os24import os
25import shlex
26import sys
2027
21from setuptools import (28from setuptools import (
22 find_packages,29 find_packages,
23 setup,30 setup,
24)31)
32from setuptools.command.test import test as TestCommand
2533
2634
27ROOT = os.path.abspath(os.path.dirname(__file__))35ROOT = os.path.abspath(os.path.dirname(__file__))
28PROJECT_NAME = 'quickstart'36PROJECT_NAME = 'quickstart'
2937
38os.chdir(ROOT)
30project = __import__(PROJECT_NAME)39project = __import__(PROJECT_NAME)
31description_path = os.path.join(ROOT, 'README.rst')40
3241
33requirements_path = os.path.join(ROOT, 'requirements.pip')42def get_package_data():
34requirements = [i.strip() for i in open(requirements_path).readlines()]43 """Return Juju Quickstart package data by walking through the project.
35install_requires = [i for i in requirements if i and not i.startswith('#')]44
3645 The package data includes all non-python files that must be included in
37os.chdir(ROOT)46 the source distribution.
3847 """
39data_files = []48 data_files = []
40for dirpath, dirnames, filenames in os.walk(PROJECT_NAME):49 for dirpath, dirnames, filenames in os.walk(PROJECT_NAME):
41 for i, dirname in enumerate(dirnames):50 for i, dirname in enumerate(dirnames):
42 if dirname.startswith('.'):51 if dirname.startswith('.'):
43 del dirnames[i]52 del dirnames[i]
44 if '__init__.py' in filenames:53 if '__init__.py' in filenames:
45 continue54 continue
46 elif filenames:55 elif filenames:
47 for f in filenames:56 for f in filenames:
48 data_files.append(os.path.join(57 data_files.append(os.path.join(
49 dirpath[len(PROJECT_NAME) + 1:], f))58 dirpath[len(PROJECT_NAME) + 1:], f))
59 return {PROJECT_NAME: data_files}
60
61
62def get_long_description():
63 """Retrieve the project long description from the README.rst file."""
64 with open(os.path.join(ROOT, 'README.rst')) as readme_file:
65 return readme_file.read()
66
67
68def get_install_requires():
69 """Dynamically generate the requirements list by parsing the tox file."""
70 config = ConfigParser.ConfigParser()
71 config.read(os.path.join(ROOT, 'tox.ini'))
72 all_versions = {}
73 test_requirements = '{[testenv]deps}'
74 platforms = config.get('tox', 'envlist').split(',')
75 for platform in platforms:
76 section = 'testenv:{}'.format(platform)
77 deps = filter(None, config.get(section, 'deps').splitlines())
78 for requirement in deps:
79 requirement = requirement.strip()
80 if requirement.startswith('#') or requirement == test_requirements:
81 continue
82 name, version = requirement.split('==')
83 versions = all_versions.setdefault(name, set())
84 versions.add(version)
85 requirements = []
86 for name, versions in all_versions.items():
87 if len(versions) == 1:
88 requirements.append('{}=={}'.format(name, versions.pop()))
89 continue
90 versions = list(sorted(versions, key=StrictVersion))
91 requirements.append(
92 '{}>={},<={}'.format(name, versions[0], versions[-1]))
93 return requirements
94
95
96class RequirementsCommand(Command):
97 """Set up the requirements command."""
98
99 description = 'output program requirements'
100 user_options = []
101
102 def initialize_options(self):
103 pass
104
105 def finalize_options(self):
106 pass
107
108 def run(self):
109 requirements = get_install_requires()
110 print('\n{}'.format('\n'.join(requirements)))
111
112
113class ToxCommand(TestCommand):
114 """Set up the tox testing command."""
115
116 user_options = [('tox-args=', 'a', 'Arguments to pass to tox')]
117
118 def initialize_options(self):
119 TestCommand.initialize_options(self)
120 self.tox_args = None
121
122 def finalize_options(self):
123 TestCommand.finalize_options(self)
124 self.test_args = []
125 self.test_suite = True
126
127 def run_tests(self):
128 # Import here, cause outside the eggs aren't loaded.
129 import tox
130 args = [] if self.tox_args is None else shlex.split(self.tox_args)
131 errno = tox.cmdline(args=args)
132 sys.exit(errno)
50133
51134
52setup(135setup(
53 name='juju-quickstart',136 name='juju-quickstart',
54 version=project.get_version(),137 version=project.get_version(),
55 description=project.__doc__,138 description=project.__doc__,
56 long_description=open(description_path).read(),139 long_description=get_long_description(),
57 author='The Juju GUI team',140 author='The Juju GUI team',
58 author_email='juju-gui@lists.ubuntu.com',141 author_email='juju-gui@lists.ubuntu.com',
59 url='https://launchpad.net/juju-quickstart',142 url='https://launchpad.net/juju-quickstart',
60 keywords='juju quickstart plugin',143 keywords='juju quickstart plugin',
61 packages=find_packages(),144 packages=find_packages(),
62 package_data={PROJECT_NAME: data_files},145 package_data=get_package_data(),
63 scripts=['juju-quickstart'],146 scripts=['juju-quickstart'],
64 install_requires=install_requires,147 install_requires=get_install_requires(),
148 tests_require=['tox'],
149 cmdclass = {
150 'requirements': RequirementsCommand,
151 'test': ToxCommand,
152 },
65 zip_safe=False,153 zip_safe=False,
66 classifiers=[154 classifiers=[
67 'Development Status :: 5 - Production/Stable',155 'Development Status :: 5 - Production/Stable',
68156
=== removed file 'test-requirements.pip'
--- test-requirements.pip 2014-09-05 14:54:31 +0000
+++ test-requirements.pip 1970-01-01 00:00:00 +0000
@@ -1,23 +0,0 @@
1# Juju Quickstart test requirements.
2
3# This file is part of the Juju Quickstart Plugin, which lets users set up a
4# Juju environment in very few steps (https://launchpad.net/juju-quickstart).
5# Copyright (C) 2013 Canonical Ltd.
6#
7# This program is free software: you can redistribute it and/or modify it under
8# the terms of the GNU Affero General Public License version 3, as published by
9# the Free Software Foundation.
10#
11# This program is distributed in the hope that it will be useful, but WITHOUT
12# ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
13# SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14# Affero General Public License for more details.
15#
16# You should have received a copy of the GNU Affero General Public License
17# along with this program. If not, see <http://www.gnu.org/licenses/>.
18
19coverage==3.7.1
20flake8==2.2.3
21mock==1.0.1
22nose==1.3.4
23-r requirements.pip
240
=== added file 'tox.ini'
--- tox.ini 1970-01-01 00:00:00 +0000
+++ tox.ini 2015-01-30 16:35:06 +0000
@@ -0,0 +1,115 @@
1# This file is part of the Juju Quickstart Plugin, which lets users set up a
2# Juju environment in very few steps (https://launchpad.net/juju-quickstart).
3# Copyright (C) 2015 Canonical Ltd.
4#
5# This program is free software: you can redistribute it and/or modify it under
6# the terms of the GNU Affero General Public License version 3, as published by
7# the Free Software Foundation.
8#
9# This program is distributed in the hope that it will be useful, but WITHOUT
10# ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
11# SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12# Affero General Public License for more details.
13#
14# You should have received a copy of the GNU Affero General Public License
15# along with this program. If not, see <http://www.gnu.org/licenses/>.
16
17[tox]
18# The envlist option must only include platform scenarios. In essence, those
19# are used to test Juju Quickstart with the specific dependencies present in
20# each supported OS platform.
21envlist = pypi,ppa,vivid
22# XXX frankban: currently tests do not pass on trusty and utopic scenarios.
23# Fix the tests, then remove the line above and uncomment the line below.
24# envlist = pypi,ppa,trusty,utopic,vivid
25
26
27# Define the base requirements and commands to use when testing the program.
28
29[testenv]
30basepython = python2.7
31deps =
32 mock==1.0.1
33 nose==1.3.4
34commands =
35 nosetests {posargs:--quiet}
36
37
38# Set up the development environment.
39
40[testenv:devenv]
41envdir = devenv
42usedevelop = True
43deps =
44 {[testenv]deps}
45 {[testenv:lint]deps}
46 coverage==3.7.1
47commands =
48
49
50# Set up different scenarios for each Juju Quickstart source repository.
51# Note that the setup.py distribution file calculates Juju Quickstart
52# requirements based on this file. For this reason, when updating dependencies,
53# respect the following rules:
54# - all scenarios must be listed in the envlist above (in the tox section);
55# - each scenario must at least include a "{[testenv]deps}" line in its deps;
56# - keep each requirement in deps in its own line;
57# - always use specific revisions for environments (i.e. use "==").
58# After updating this file, run "make requirements" and ensure the general
59# dependency rules in the output make sense.
60
61[testenv:pypi]
62# Always recreate the virtualenv here so that old installed dependencies are
63# not reused and a fresh pip install can be accurately simulated.
64recreate = True
65deps =
66 {[testenv]deps}
67 # All the dependencies are installed by Juju Quickstart itself, using
68 # the dynamically generated "install_requires" setup field.
69 # Note that, since Homebrew internally uses pip when installing Quickstart,
70 # this scenario also covers OSX installations.
71
72[testenv:ppa]
73deps =
74 {[testenv]deps}
75 # Dependencies present in ppa:juju/stable.
76 # See https://launchpad.net/~juju/+archive/ubuntu/stable.
77 websocket-client==0.18.0
78 jujuclient==0.18.4
79 urwid==1.2.1
80 # The distribution PyYAML requirement is used in this case.
81
82[testenv:trusty]
83deps =
84 {[testenv]deps}
85 # Ubuntu 14.04 (trusty) distro dependencies.
86 websocket-client==0.12.0
87 jujuclient==0.17.5
88 PyYAML==3.10
89 urwid==1.1.1
90
91[testenv:utopic]
92deps =
93 {[testenv]deps}
94 # Ubuntu 14.10 (utopic) distro dependencies.
95 websocket-client==0.12.0
96 jujuclient==0.17.5
97 PyYAML==3.11
98 urwid==1.2.1
99
100[testenv:vivid]
101deps =
102 {[testenv]deps}
103 # Ubuntu 15.04 (vivid) distro dependencies.
104 websocket-client==0.18.0
105 jujuclient==0.18.5
106 PyYAML==3.11
107 urwid==1.2.1
108
109
110# Define additional tox targets to be used to validate and lint the code.
111
112[testenv:lint]
113usedevelop = True
114deps = flake8==2.3.0
115commands = flake8 --show-source quickstart

Subscribers

People subscribed via source and target branches