Merge lp:~cjwatson/turnip/turnipcake-virtualenv into lp:~canonical-launchpad-branches/turnip/turnipcake

Proposed by Colin Watson on 2015-10-22
Status: Merged
Merged at revision: 24
Proposed branch: lp:~cjwatson/turnip/turnipcake-virtualenv
Merge into: lp:~canonical-launchpad-branches/turnip/turnipcake
Diff against target: 140 lines (+81/-15)
4 files modified
.bzrignore (+4/-1)
Makefile (+72/-14)
bootstrap-requirements.txt (+2/-0)
deploy-requirements.txt (+3/-0)
To merge this branch: bzr merge lp:~cjwatson/turnip/turnipcake-virtualenv
Reviewer Review Type Date Requested Status
Colin Watson Approve on 2015-10-29
Review via email: mp+275466@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 parallels https://code.launchpad.net/~cjwatson/turnip/virtualenv/+merge/274701, and takes basically the same approach. While we only need this for development, it greatly simplifies updating the Mojo spec if we can treat both turnip and turnipcake more or less the same way.

To post a comment you must log in.
28. By Colin Watson on 2015-10-23

Fix turnip dependencies URL.

29. By Colin Watson on 2015-10-29

Move PIP_SOURCE_DIR check from build-tarball to $(ENV).

Colin Watson (cjwatson) wrote :
review: Approve

Preview Diff

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

Subscribers

People subscribed via source and target branches

to all changes: