Merge lp:~cjwatson/turnip/virtualenv into lp:turnip

Proposed by Colin Watson
Status: Merged
Merged at revision: 184
Proposed branch: lp:~cjwatson/turnip/virtualenv
Merge into: lp:turnip
Diff against target: 150 lines (+80/-10)
5 files modified
.bzrignore (+3/-1)
Makefile (+69/-9)
bootstrap-requirements.txt (+2/-0)
deploy-requirements.txt (+5/-0)
test-requirements.txt (+1/-0)
To merge this branch: bzr merge lp:~cjwatson/turnip/virtualenv
Reviewer Review Type Date Requested Status
Kit Randel (community) Approve
Review via email: mp+274701@code.launchpad.net

Commit message

Add targets to build a virtualenv and to build a tarball with included pip cache.

Description of the change

Add targets to build a virtualenv and to build a tarball with included pip cache.

This is the first step towards making our deployment system more sensible: it will eventually allow us to have a mojo manifest that builds the entire code asset in an appropriate container, virtualenv and all, run tests the whole thing, and upload it to swift for the charm to deploy. This will involve less downtime on upgrades and will support the autodeployment scheme currently being trialled by Canonical IS. As a bonus, since the intended use of this is to run the build step in an environment that matches the deployment target, we can switch to installing pygit2 from pip like everything else; 0.22.1 includes our current set of local patches.

This of course requires some additions to turnip-dependencies (pbr-1.8.1.tar.gz, pip-7.1.2.tar.gz, pygit2-0.22.1.tar.gz, setuptools-18.4.tar.gz), which I'll commit if this is accepted, and I'll also commit a similar change to turnipcake in that case so that the charms can remain consistent.

The turnip charm will need to be updated to use this, and that update will involve quite a bit of refactoring, but this part of it can be landed in advance of that, and as a bonus it makes "make check" much more reliable.

To post a comment you must log in.
lp:~cjwatson/turnip/virtualenv updated
185. By Colin Watson

Ship a pip cache in the tarball rather than a full virtualenv.

186. By Colin Watson

Switch order of env and pip-cache construction, since we need to do the downloads with a modern pip.

187. By Colin Watson

Quieten pip.

188. By Colin Watson

Use revision IDs rather than revnos to construct build labels.

189. By Colin Watson

Install turnip itself in editable mode, for the sake of gunicorn.

190. By Colin Watson

Fix turnip dependencies URL.

Revision history for this message
Kit Randel (blr) wrote :

This is great, and I'll be updating rutabaga to reflect this shortly!

I did wonder however if it would be worth providing a similar warning to `make build-tarball`, when PIP_SOURCE_DIR is not set for the `make` target? The `pip install` will fail without it.

review: Approve
Revision history for this message
Colin Watson (cjwatson) wrote :

Oh, right, I was thinking it'd use PyPI in that case but indeed it fails when it gets to our python-openid fork. I'll add the warning.

lp:~cjwatson/turnip/virtualenv updated
191. By Colin Watson

Move PIP_SOURCE_DIR check from build-tarball to $(ENV), since we need the dependencies checkout for our python-openid fork.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file '.bzrignore'
2--- .bzrignore 2015-05-20 23:32:18 +0000
3+++ .bzrignore 2015-10-29 10:59:31 +0000
4@@ -4,10 +4,12 @@
5 dist
6 download-cache
7 eggs
8+env
9+pip-cache
10 *.egg*
11 *.egg-info
12 .installed.cfg
13 *.log
14 parts
15 tags
16-TAGS
17\ No newline at end of file
18+TAGS
19
20=== modified file 'Makefile'
21--- Makefile 2015-03-12 07:51:28 +0000
22+++ Makefile 2015-10-29 10:59:31 +0000
23@@ -1,18 +1,57 @@
24 # Copyright 2005-2015 Canonical Ltd. This software is licensed under the
25 # GNU Affero General Public License version 3 (see the file LICENSE).
26
27-PYTHON=python
28-PSERVE=pserve
29-FLAKE8=flake8
30-
31-check:
32+ENV = $(CURDIR)/env
33+PIP_CACHE = $(CURDIR)/pip-cache
34+
35+PYTHON = $(ENV)/bin/python
36+PSERVE = $(ENV)/bin/pserve
37+FLAKE8 = $(ENV)/bin/flake8
38+
39+PIP_CACHE_ARGS := -q --no-use-wheel
40+ifneq ($(PIP_SOURCE_DIR),)
41+PIP_CACHE_ARGS += --no-index --find-links=file://$(realpath $(PIP_SOURCE_DIR))/
42+endif
43+
44+# Create archives in labelled directories (e.g.
45+# <rev-id>/$(PROJECT_NAME).tar.gz)
46+TARBALL_BUILD_LABEL ?= $(shell bzr log -rlast: --show-ids | sed -n 's/^revision-id: //p')
47+TARBALL_FILE_NAME = turnip.tar.gz
48+TARBALL_BUILDS_DIR ?= build
49+TARBALL_BUILD_DIR = $(TARBALL_BUILDS_DIR)/$(TARBALL_BUILD_LABEL)
50+TARBALL_BUILD_PATH = $(TARBALL_BUILD_DIR)/$(TARBALL_FILE_NAME)
51+
52+build: $(ENV)
53+
54+$(ENV):
55+ifeq ($(PIP_SOURCE_DIR),)
56+ @echo "Set PIP_SOURCE_DIR to the path of a checkout of" >&2
57+ @echo "lp:~canonical-launchpad-branches/turnip/dependencies." >&2
58+ @exit 1
59+endif
60+ mkdir -p $(ENV)
61+ (echo '[easy_install]'; \
62+ echo "allow_hosts = ''"; \
63+ echo 'find_links = file://$(realpath $(PIP_SOURCE_DIR))/') \
64+ >$(ENV)/.pydistutils.cfg
65+ virtualenv $(ENV)
66+ $(ENV)/bin/pip install $(PIP_CACHE_ARGS) \
67+ -r bootstrap-requirements.txt
68+ $(ENV)/bin/pip install $(PIP_CACHE_ARGS) \
69+ -r requirements.txt \
70+ -r deploy-requirements.txt \
71+ -r test-requirements.txt \
72+ -e .
73+
74+check: $(ENV)
75 $(PYTHON) -m unittest discover turnip
76
77 clean:
78 find turnip -name '*.py[co]' -exec rm '{}' \;
79+ rm -rf $(ENV) $(PIP_CACHE)
80
81 dist:
82- $(PYTHON) ./setup.py sdist
83+ python ./setup.py sdist
84
85 TAGS:
86 ctags -e -R turnip
87@@ -20,10 +59,31 @@
88 tags:
89 ctags -R turnip
90
91-lint:
92+lint: $(ENV)
93 @$(FLAKE8) turnip
94
95-run-api:
96+run-api: $(ENV)
97 $(PSERVE) api.ini --reload
98
99-.PHONY: check clean dist lint run-api
100+$(PIP_CACHE): $(ENV)
101+ mkdir -p $(PIP_CACHE)
102+ $(ENV)/bin/pip install $(PIP_CACHE_ARGS) -d $(PIP_CACHE) \
103+ -r bootstrap-requirements.txt \
104+ -r requirements.txt \
105+ -r deploy-requirements.txt \
106+ -r test-requirements.txt
107+
108+# XXX cjwatson 2015-10-16: limit to only interesting files
109+build-tarball:
110+ @echo "Creating deployment tarball at $(TARBALL_BUILD_PATH)"
111+ rm -rf $(PIP_CACHE)
112+ $(MAKE) $(PIP_CACHE)
113+ mkdir -p $(TARBALL_BUILD_DIR)
114+ tar -czf $(TARBALL_BUILD_PATH) \
115+ --exclude-vcs \
116+ --exclude build \
117+ --exclude dist \
118+ --exclude env \
119+ ./
120+
121+.PHONY: build check clean dist lint run-api build-tarball
122
123=== added file 'bootstrap-requirements.txt'
124--- bootstrap-requirements.txt 1970-01-01 00:00:00 +0000
125+++ bootstrap-requirements.txt 2015-10-29 10:59:31 +0000
126@@ -0,0 +1,2 @@
127+pip==7.1.2
128+setuptools==18.4
129
130=== added file 'deploy-requirements.txt'
131--- deploy-requirements.txt 1970-01-01 00:00:00 +0000
132+++ deploy-requirements.txt 2015-10-29 10:59:31 +0000
133@@ -0,0 +1,5 @@
134+# This will be merged into requirements.txt once the turnip charm uses the
135+# new tarball construction code.
136+envdir==0.7
137+gunicorn==19.3.0
138+pygit2==0.22.1
139
140=== modified file 'test-requirements.txt'
141--- test-requirements.txt 2015-06-16 07:03:32 +0000
142+++ test-requirements.txt 2015-10-29 10:59:31 +0000
143@@ -4,6 +4,7 @@
144 flake8==2.4.0
145 linecache2==1.0.0
146 mccabe==0.3
147+pbr==1.8.1
148 pep8==1.5.7
149 pyflakes==0.8.1
150 python-mimeparse==0.1.4

Subscribers

People subscribed via source and target branches

to all changes: