Merge lp:~bjornt/lazr-js/buildoutification into lp:lazr-js

Proposed by Björn Tillenius
Status: Merged
Approved by: Gary Poster
Approved revision: 123
Merged at revision: not available
Proposed branch: lp:~bjornt/lazr-js/buildoutification
Merge into: lp:lazr-js
Diff against target: 808 lines
12 files modified
.bzrignore (+9/-0)
MANIFEST.in (+5/-0)
Makefile (+27/-4)
README.txt (+14/-0)
bootstrap.py (+170/-0)
buildout.cfg (+32/-0)
ez_setup.py (+275/-0)
setup.py (+47/-0)
src-py/lazr/__init__.py (+8/-0)
src-py/lazr/js/build.py (+23/-11)
src-py/lazr/js/jslint.py (+2/-3)
src-py/lazr/js/scaffold.py (+2/-3)
To merge this branch: bzr merge lp:~bjornt/lazr-js/buildoutification
Reviewer Review Type Date Requested Status
Gary Poster (community) Approve
Canonical Launchpad Engineering Pending
Review via email: mp+13003@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Björn Tillenius (bjornt) wrote :

This branch makes lazr-js use buildout to handle dependencies, and makes
it possible for LP to use lazr-js as an egg (via an sdist of course).

There are quite a lot of changes in this branch, and there as still a
few unknowns. First of all, don't be fooled by the diff size. It's over
800 lines, but if you remove bootstrap.py and ez_setup.py (which are
simple copies from LP trun), it's down to a more managable 375 lines.

I've moved all the python code that was lying around into the src-py
directory (I used src-py, since we also have js files, which are in
src-js). All of our code is in a lazr.js package, and the form tools are
now in bin/. I modified them to have a main() function, so it's easy to
generate these scripts using buildout.

Please review the setup.py extra carefully. I wasn't quite sure how to
get the javascript files included, but at least it's working now. Maybe
there is some better way of doing it?

Another thing I'm not sure about is the versions specified in
buildout.cfg. I simply copied the versions from LP's buildout.cfg.

I also modified build.py to include the yui when building the javascript
files. It's only included when building the lazr-js widgets. If
bin/build is used to build other javascript files, it's not included.

Not that I haven't bother about explaining how to set up the
download-cache if it doesn't exist. I used LP's one when testing, but I
intend to make sure that we have a special one of lazr. There is
already a branch for it, but I wanted to get this one landed first,
since we don't need to for LP.

See also lp:~bjornt/launchpad/lazrjs-buildout, which is the branch that
makes use of lazr-js using buildout, and removes it from sourcecode/.

--
Björn Tillenius | https://launchpad.net/~bjornt

Revision history for this message
Björn Tillenius (bjornt) wrote :
Revision history for this message
Gary Poster (gary) wrote :
Download full text (16.0 KiB)

Hi Bjorn. This is great to see.

I think we can simplify the setup. I don't know if we need as many of the tricks that Launchpad uses. Here's a diff that removes a lot of them. This should be regarded as a conversation starter, rather than as a concrete suggestion. I'll call out the ideas here, and then you can see them concretely in the diff. I've marked the items that I strongly think are valid with three stars (***).

- Launchpad keeps a separate, shared download-cache and eggs. That makes sense if the build is happening on a machine that does not allow network access, or if we want to prevent being exposed to PyPI service interruptions, or if we want to use custom distributions. On the other hand, if we remove that, we can have a simpler build. If developers want shared eggs, they can set up a global cache (https://dev.launchpad.net/HackingLazrLibraries#Global%20Cache). This change affects .bzrignore, and the Makefile (including the bin/buildout target).

- I don't see any reason to specify the BUILDOUT_CFG in the Makefile. There's only one.

- ``make clean`` might as well just trash the bin directory. ***

- We can just use the interpreter option for zc.recipe.egg to produce the py file, and remove the z3c.recipe.filetemplate dependency (and the buildout-templates directory). We made the py file in Launchpad like that because Launchpad's Makefile wanted to use the -t option. (I have a branch I'm working on for Launchpad that switches it to using the interpreter option also.) ***

- The entry points maybe ought to be in the setup.py file, so someone can use it without buildout. Maybe. Anyway, might as well put it in the expected place. ***

- No need to specify extra-paths in buildout.cfg. You are already doing the right thing in setup.py. ***

- If we change the Makefile to use -S whenever it calls Python, we don't need my custom releases of buildout that handle a system Python (which Jim still has on his queue to review), so we can just use released versions of the various packages. (On the other hand, if Jim approves my changes, we could arguably just get rid of the Makefile entirely and instruct people to run ``python bootstrap.py && bin/buildout && bin/build`` or something to get the build.)

- Including ez_setup.py was another artifact of wanting to be able to build on a machine that had no outside net access. If we don't need to support that, we can remove it (and the reference in setup.py).

If you agree with all of these thoughts, you can take the diff as is. Otherwise, hopefully it will still give us something to talk about it. If you just change the starred items, and push back convincingly on the rest, that will probably be fine.

Thanks!

Gary

=== modified file '.bzrignore'
--- .bzrignore 2009-09-23 13:25:32 +0000
+++ .bzrignore 2009-10-07 19:34:10 +0000
@@ -7,6 +7,4 @@
 parts
 src/inlineedit/assets/skins/sam/inlineedit.css
 src/lazr/assets/skins/sam/lazr.css
-./download-cache
-./eggs
 ./MANIFEST

=== modified file 'Makefile'
--- Makefile 2009-10-07 15:42:30 +0000
+++ Makefile 2009-10-07 19:58:20 +0000
@@ -5,35 +5,21 @@
 PYTHON=python${PYTHON_VERSION}
 WD:=$(shell pwd)
 PY=$(WD)/bin/py
-BUILDOUT_CFG=bu...

review: Needs Fixing
lp:~bjornt/lazr-js/buildoutification updated
119. By Björn Tillenius

Don't specify BUILDOUT_CFG in the Makefile, since we have only one config.

120. By Björn Tillenius

Trash the whole bin/ directory in 'make clean'.

121. By Björn Tillenius

Get rid of buildout-templates.

122. By Björn Tillenius

Specify which scripts should be generated in setup.py instead of in buildout.cfg.

123. By Björn Tillenius

No need to depend on z.recipe.filetemplate anymore.

Revision history for this message
Björn Tillenius (bjornt) wrote :
Download full text (4.6 KiB)

On Wed, Oct 07, 2009 at 08:11:57PM -0000, Gary Poster wrote:
> Review: Needs Fixing
> Hi Bjorn. This is great to see.
>
> I think we can simplify the setup. I don't know if we need as many of
> the tricks that Launchpad uses. Here's a diff that removes a lot of
> them. This should be regarded as a conversation starter, rather than as
> a concrete suggestion. I'll call out the ideas here, and then you can
> see them concretely in the diff. I've marked the items that I strongly
> think are valid with three stars (***).

Right, I was meaning for this MP to be the start of a conversation, so
that we had a diff we could look at. Many of the things I simply took
from LP.

> - Launchpad keeps a separate, shared download-cache and eggs. That
> makes sense if the build is happening on a machine that does not allow
> network access, or if we want to prevent being exposed to PyPI service
> interruptions, or if we want to use custom distributions. On the other
> hand, if we remove that, we can have a simpler build. If developers
> want shared eggs, they can set up a global cache
> (https://dev.launchpad.net/HackingLazrLibraries#Global%20Cache). This
> change affects .bzrignore, and the Makefile (including the bin/buildout
> target).

There is some value in always using a download-cache. The main reason is
would be to help people remember adding things to the download-cache
branch, whenever they add a new dependencies. We do have want to run
tests using PQM or buildbot, and those machines won't have net access.
Although, I said I wanted to worry about this after landing this branch
(since for LP to use it it doesn't matter), so I guess I could remove it
for now, and we can decide what to do later.

> - I don't see any reason to specify the BUILDOUT_CFG in the Makefile.
> There's only one.

Right, this was copied from LP; removed.

> - ``make clean`` might as well just trash the bin directory. ***

Right, makes sense; done.

> - We can just use the interpreter option for zc.recipe.egg to produce
> the py file, and remove the z3c.recipe.filetemplate dependency (and the
> buildout-templates directory). We made the py file in Launchpad like
> that because Launchpad's Makefile wanted to use the -t option. (I have
> a branch I'm working on for Launchpad that switches it to using the
> interpreter option also.) ***

Indeed, this is simpler, this was another copy from LP. I've changed it
to use the interpreter option and removed the z3c.recipe.filetemplate
dependency.

> - The entry points maybe ought to be in the setup.py file, so someone
> can use it without buildout. Maybe. Anyway, might as well put it in
> the expected place. ***

Yep, having them in setup.py is better, I didn't know that it was
enough. Fixed.

> - No need to specify extra-paths in buildout.cfg. You are already
> doing the right thing in setup.py. ***

Yes. It was necessary at one point, but now it's not needed anymore, so
I've removed it.

> - If we change the Makefile to use -S whenever it calls Python, we
> don't need my custom releases of buildout that handle a system Python
> (which Jim still has on his queue to review), so we can just use
> released versions of the...

Read more...

=== modified file 'Makefile'
--- Makefile 2009-10-07 15:42:30 +0000
+++ Makefile 2009-10-08 13:20:27 +0000
@@ -5,7 +5,6 @@
5PYTHON=python${PYTHON_VERSION}5PYTHON=python${PYTHON_VERSION}
6WD:=$(shell pwd)6WD:=$(shell pwd)
7PY=$(WD)/bin/py7PY=$(WD)/bin/py
8BUILDOUT_CFG=buildout.cfg
98
10# Update the build directory9# Update the build directory
11build: $(PY)10build: $(PY)
@@ -29,11 +28,11 @@
29 --ez_setup-source=ez_setup.py \28 --ez_setup-source=ez_setup.py \
30 --download-base=download-cache/dist --eggs=eggs29 --download-base=download-cache/dist --eggs=eggs
3130
32$(PY): bin/buildout $(BUILDOUT_CFG) setup.py31$(PY): bin/buildout buildout.cfg setup.py
33 PYTHONPATH= ./bin/buildout -c $(BUILDOUT_CFG)32 PYTHONPATH= ./bin/buildout -c buildout.cfg
3433
3534
36clean:35clean:
37 rm -fr build/* bin/buildout36 rm -fr build/* bin
3837
39.PHONY: build lint clean38.PHONY: build lint clean
4039
=== removed directory 'buildout-templates'
=== removed directory 'buildout-templates/bin'
=== removed file 'buildout-templates/bin/py.in'
--- buildout-templates/bin/py.in 2009-09-23 12:17:15 +0000
+++ buildout-templates/bin/py.in 1970-01-01 00:00:00 +0000
@@ -1,2 +0,0 @@
1#!/bin/sh
2PYTHONPATH=${os-paths} exec ${buildout:executable} "$@"
30
=== modified file 'buildout.cfg'
--- buildout.cfg 2009-10-07 15:42:57 +0000
+++ buildout.cfg 2009-10-08 12:58:21 +0000
@@ -1,7 +1,6 @@
1[buildout]1[buildout]
2develop = .2develop = .
3parts =3parts =
4 filetemplates
5 scripts4 scripts
65
7unzip = true6unzip = true
@@ -23,19 +22,10 @@
2322
24versions = versions23versions = versions
2524
26[filetemplates]
27recipe = z3c.recipe.filetemplate
28eggs = lazr-js
29source-directory = buildout-templates
30
31[scripts]25[scripts]
32recipe = zc.recipe.egg26recipe = zc.recipe.egg
27interpreter = py
33eggs = lazr-js28eggs = lazr-js
34entry-points =
35 build=lazr.js.build:main
36 jslint=lazr.js.jslint:main
37 scaffold=lazr.js.scaffold:main
38extra-paths = ${buildout:directory}/src-py
3929
40[versions]30[versions]
41# Alphabetical, case-insensitive, please! :-)31# Alphabetical, case-insensitive, please! :-)
@@ -43,4 +33,3 @@
43setuptools = 0.6c933setuptools = 0.6c9
44zc.buildout = 1.5.0dev-gary-r10355334zc.buildout = 1.5.0dev-gary-r103553
45zc.recipe.egg = 1.3.0dev-gary-r10351535zc.recipe.egg = 1.3.0dev-gary-r103515
46z3c.recipe.filetemplate = 2.1dev-gary-r103545
4736
=== modified file 'setup.py'
--- setup.py 2009-10-07 15:43:55 +0000
+++ setup.py 2009-10-08 12:57:02 +0000
@@ -39,6 +39,9 @@
39 ),39 ),
40 entry_points=dict(40 entry_points=dict(
41 console_scripts=[41 console_scripts=[
42 'build=lazr.js.build:main',
43 'jslint=lazr.js.jslint:main',
44 'scaffold=lazr.js.scaffold:main',
42 ]45 ]
43 ),46 ),
44)47)
Revision history for this message
Gary Poster (gary) wrote :
Download full text (4.7 KiB)

On Oct 8, 2009, at 9:24 AM, Björn Tillenius wrote:

> On Wed, Oct 07, 2009 at 08:11:57PM -0000, Gary Poster wrote:
>> Review: Needs Fixing
>> Hi Bjorn. This is great to see.
>>
>> I think we can simplify the setup. I don't know if we need as many
>> of
>> the tricks that Launchpad uses. Here's a diff that removes a lot of
>> them. This should be regarded as a conversation starter, rather
>> than as
>> a concrete suggestion. I'll call out the ideas here, and then you
>> can
>> see them concretely in the diff. I've marked the items that I
>> strongly
>> think are valid with three stars (***).
>
> Right, I was meaning for this MP to be the start of a conversation, so
> that we had a diff we could look at. Many of the things I simply took
> from LP.

Cool.

>> - Launchpad keeps a separate, shared download-cache and eggs. That
>> makes sense if the build is happening on a machine that does not
>> allow
>> network access, or if we want to prevent being exposed to PyPI
>> service
>> interruptions, or if we want to use custom distributions. On the
>> other
>> hand, if we remove that, we can have a simpler build. If developers
>> want shared eggs, they can set up a global cache
>> (https://dev.launchpad.net/HackingLazrLibraries#Global%20Cache).
>> This
>> change affects .bzrignore, and the Makefile (including the bin/
>> buildout
>> target).
>
> There is some value in always using a download-cache.

Agreed. There are other ways to get some of the same value (a repo
managed by Canonical/Launchpad would give us the benefit of protection
from PyPI outages, for instance). But still agreed.

> The main reason is
> would be to help people remember adding things to the download-cache
> branch, whenever they add a new dependencies. We do have want to run
> tests using PQM or buildbot, and those machines won't have net access.

buildbot has net access, but PQM doesn't. Sometimes developers don't
have net access, also, and a download-cache lets them be productive
then.

> Although, I said I wanted to worry about this after landing this
> branch
> (since for LP to use it it doesn't matter), so I guess I could
> remove it
> for now, and we can decide what to do later.

I don't have a strong opinion about it. I just want to point out some
possible simplifications for your consideration.

...

>> - If we change the Makefile to use -S whenever it calls Python, we
>> don't need my custom releases of buildout that handle a system Python
>> (which Jim still has on his queue to review), so we can just use
>> released versions of the various packages. (On the other hand, if
>> Jim
>> approves my changes, we could arguably just get rid of the Makefile
>> entirely and instruct people to run ``python bootstrap.py &&
>> bin/buildout && bin/build`` or something to get the build.)
>
> So, I think this change sounds good, but could you expand a bit more
> on
> that the difference between 'python -S bin/build' and 'bin/build'
> is? I
> don't quite understand why the former is better.

Because not running site.py (python -S) means that site-packages are
not included, which means that we don't get complications from using a
...

Read more...

Revision history for this message
Gary Poster (gary) wrote :

Thank you again

review: Approve
lp:~bjornt/lazr-js/buildoutification updated
124. By Björn Tillenius

Use python -S.

125. By Björn Tillenius

Remove unused config options.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file '.bzrignore'
--- .bzrignore 2009-01-07 19:57:04 +0000
+++ .bzrignore 2009-10-27 09:01:09 +0000
@@ -1,3 +1,12 @@
1.installed.cfg
2./bin
1build/*3build/*
4develop-eggs
5dist
6lib/*.egg-info
7parts
2src/inlineedit/assets/skins/sam/inlineedit.css8src/inlineedit/assets/skins/sam/inlineedit.css
3src/lazr/assets/skins/sam/lazr.css9src/lazr/assets/skins/sam/lazr.css
10./download-cache
11./eggs
12./MANIFEST
413
=== added file 'MANIFEST.in'
--- MANIFEST.in 1970-01-01 00:00:00 +0000
+++ MANIFEST.in 2009-10-27 09:01:09 +0000
@@ -0,0 +1,5 @@
1include *.txt Makefile
2recursive-include examples/ *
3recursive-include src-py *
4recursive-include src-js *
5include ez_setup.py
06
=== modified file 'Makefile'
--- Makefile 2009-03-13 19:23:08 +0000
+++ Makefile 2009-10-27 09:01:09 +0000
@@ -1,15 +1,38 @@
1# Simple makefile for lazr-js.1# Simple makefile for lazr-js.
2#2#
3#3#
4PYTHON_VERSION=
5PYTHON=python${PYTHON_VERSION}
6WD:=$(shell pwd)
7PY=$(WD)/bin/py
48
5# Update the build directory9# Update the build directory
6build:10build: $(PY)
7 $(PYTHON) tools/build.py11 $(PYTHON) -S bin/build
812
9lint:13lint:
10 $(PYTHON) tools/jslint.py14 $(PYTHON) -S bin/jslint
15
16eggs:
17 mkdir eggs
18
19download-cache:
20 @$echo "Missing ./download-cache."
21 @exit 1
22
23# The download-cache dependency comes *before* eggs so that developers get the
24# warning before the eggs directory is made. The target for the eggs directory
25# is only there for deployment convenience.
26bin/buildout: download-cache eggs
27 $(SHHH) $(PYTHON) -S bootstrap.py\
28 --ez_setup-source=ez_setup.py \
29 --download-base=download-cache/dist --eggs=eggs
30
31$(PY): bin/buildout buildout.cfg setup.py
32 $(PYTHON) -S ./bin/buildout
33
1134
12clean:35clean:
13 rm -fr build/*36 rm -fr build/* bin
1437
15.PHONY: build lint clean38.PHONY: build lint clean
1639
=== added file 'README.txt'
--- README.txt 1970-01-01 00:00:00 +0000
+++ README.txt 2009-10-27 09:01:09 +0000
@@ -0,0 +1,14 @@
1Lazr-JS: Sleek and sexy AJAX widgets for the new web
2====================================================
3
4This is a collection of AJAX-ready widgets building on YUI3.
5
6 * anim:: useful animations.
7 * choiceedit:: picker for a small list of choices
8 * formoverlay:: AJAXIFY a regular web form
9 * inlineedit:: inline text editor
10 * lazr:: utility modules
11 * overlay:: a popup window
12 * picker:: searchable vocabulary picker
13 * testing:: test framework
14
015
=== added file 'bootstrap.py'
--- bootstrap.py 1970-01-01 00:00:00 +0000
+++ bootstrap.py 2009-10-27 09:01:09 +0000
@@ -0,0 +1,170 @@
1##############################################################################
2#
3# Copyright (c) 2006 Zope Corporation and Contributors.
4# All Rights Reserved.
5#
6# This software is subject to the provisions of the Zope Public License,
7# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
8# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
9# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
10# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
11# FOR A PARTICULAR PURPOSE.
12#
13##############################################################################
14"""Bootstrap a buildout-based project
15
16Simply run this script in a directory containing a buildout.cfg.
17The script accepts buildout command-line options, so you can
18use the -c option to specify an alternate configuration file.
19
20$Id: bootstrap.py 101930 2009-07-15 18:34:35Z gary $
21"""
22
23import os, re, shutil, sys, tempfile, textwrap, urllib, urllib2
24
25# We have to manually parse our options rather than using one of the stdlib
26# tools because we want to pass the ones we don't recognize along to
27# zc.buildout.buildout.main.
28
29configuration = {
30 '--ez_setup-source': 'http://peak.telecommunity.com/dist/ez_setup.py',
31 '--version': '',
32 '--download-base': None,
33 '--eggs': None}
34
35helpstring = __doc__ + textwrap.dedent('''
36 This script recognizes the following options itself. The first option it
37 encounters that is not one of these will cause the script to stop parsing
38 options and pass the rest on to buildout. Therefore, if you want to use
39 any of the following options *and* buildout command-line options like
40 -c, first use the following options, and then use the buildout options.
41
42 Options:
43 --version=ZC_BUILDOUT_VERSION
44 Specify a version number of the zc.buildout to use
45 --ez_setup-source=URL_OR_FILE
46 Specify a URL or file location for the ez_setup file.
47 Defaults to
48 %(--ez_setup-source)s
49 --download-base=URL_OR_DIRECTORY
50 Specify a URL or directory for downloading setuptools and
51 zc.buildout. Defaults to PyPI.
52 --eggs=DIRECTORY
53 Specify a directory for storing eggs. Defaults to a temporary
54 directory that is deleted when the bootstrap script completes.
55
56 By using --ez_setup-source and --download-base to point to local resources,
57 you can keep this script from going over the network.
58 ''' % configuration)
59match_equals = re.compile(r'(%s)=(.*)' % ('|'.join(configuration),)).match
60args = sys.argv[1:]
61if args == ['--help']:
62 print helpstring
63 sys.exit(0)
64
65# If we end up using a temporary directory for storing our eggs, this will
66# hold the path of that directory. On the other hand, if an explicit directory
67# is specified in the argv, this will remain None.
68tmpeggs = None
69
70while args:
71 val = args[0]
72 if val in configuration:
73 del args[0]
74 if not args or args[0].startswith('-'):
75 print "ERROR: %s requires an argument."
76 print helpstring
77 sys.exit(1)
78 configuration[val] = args[0]
79 else:
80 match = match_equals(val)
81 if match and match.group(1) in configuration:
82 configuration[match.group(1)] = match.group(2)
83 else:
84 break
85 del args[0]
86
87for name in ('--ez_setup-source', '--download-base'):
88 val = configuration[name]
89 if val is not None and '://' not in val: # We're being lazy.
90 configuration[name] = 'file://%s' % (
91 urllib.pathname2url(os.path.abspath(os.path.expanduser(val))),)
92
93if (configuration['--download-base'] and
94 not configuration['--download-base'].endswith('/')):
95 # Download base needs a trailing slash to make the world happy.
96 configuration['--download-base'] += '/'
97
98if not configuration['--eggs']:
99 configuration['--eggs'] = tmpeggs = tempfile.mkdtemp()
100else:
101 configuration['--eggs'] = os.path.abspath(
102 os.path.expanduser(configuration['--eggs']))
103
104# The requirement is what we will pass to setuptools to specify zc.buildout.
105requirement = 'zc.buildout'
106if configuration['--version']:
107 requirement += '==' + configuration['--version']
108
109try:
110 import setuptools # A flag. Sometimes pkg_resources is installed alone.
111 import pkg_resources
112except ImportError:
113 ez = {}
114 exec urllib2.urlopen(configuration['--ez_setup-source']).read() in ez
115 setuptools_args = dict(to_dir=configuration['--eggs'], download_delay=0)
116 if configuration['--download-base']:
117 setuptools_args['download_base'] = configuration['--download-base']
118 ez['use_setuptools'](**setuptools_args)
119 import pkg_resources
120 # This does not (always?) update the default working set. We will
121 # do it.
122 for path in sys.path:
123 if path not in pkg_resources.working_set.entries:
124 pkg_resources.working_set.add_entry(path)
125
126if sys.platform == 'win32':
127 def quote(c):
128 if ' ' in c:
129 return '"%s"' % c # work around spawn lamosity on windows
130 else:
131 return c
132else:
133 def quote (c):
134 return c
135cmd = [quote(sys.executable),
136 '-c',
137 quote('from setuptools.command.easy_install import main; main()'),
138 '-mqNxd',
139 quote(configuration['--eggs'])]
140
141if configuration['--download-base']:
142 cmd.extend(['-f', quote(configuration['--download-base'])])
143
144cmd.append(requirement)
145
146ws = pkg_resources.working_set
147env = dict(
148 os.environ,
149 PYTHONPATH=ws.find(pkg_resources.Requirement.parse('setuptools')).location)
150
151is_jython = sys.platform.startswith('java')
152if is_jython:
153 import subprocess
154 exitcode = subprocess.Popen(cmd, env=env).wait()
155else: # Windows needs this, apparently; otherwise we would prefer subprocess
156 exitcode = os.spawnle(*([os.P_WAIT, sys.executable] + cmd + [env]))
157if exitcode != 0:
158 sys.stdout.flush()
159 print ("An error occured when trying to install zc.buildout. "
160 "Look above this message for any errors that "
161 "were output by easy_install.")
162 sys.exit(exitcode)
163
164ws.add_entry(configuration['--eggs'])
165ws.require(requirement)
166import zc.buildout.buildout
167args.append('bootstrap')
168zc.buildout.buildout.main(args)
169if tmpeggs is not None:
170 shutil.rmtree(tmpeggs)
0171
=== added file 'buildout.cfg'
--- buildout.cfg 1970-01-01 00:00:00 +0000
+++ buildout.cfg 2009-10-27 09:01:09 +0000
@@ -0,0 +1,32 @@
1[buildout]
2develop = .
3parts =
4 scripts
5
6unzip = true
7eggs-directory = eggs
8download-cache = download-cache
9
10# Disable this option temporarily if you want buildout to find software
11# dependencies *other* than those in our download-cache. Once you have the
12# desired software, reenable this option (and check in the new software to
13# lp:lp-source-dependencies if this is going to be reviewed/merged/deployed.)
14install-from-cache = true
15
16allow-picked-versions = false
17
18prefer-final = true
19
20versions = versions
21
22[scripts]
23recipe = zc.recipe.egg
24interpreter = py
25eggs = lazr-js
26
27[versions]
28# Alphabetical, case-insensitive, please! :-)
29bzr = 2.0.0
30setuptools = 0.6c9
31zc.buildout = 1.4.1
32zc.recipe.egg = 1.2.2
033
=== added file 'ez_setup.py'
--- ez_setup.py 1970-01-01 00:00:00 +0000
+++ ez_setup.py 2009-10-27 09:01:09 +0000
@@ -0,0 +1,275 @@
1#!python
2"""Bootstrap setuptools installation
3
4If you want to use setuptools in your package's setup.py, just include this
5file in the same directory with it, and add this to the top of your setup.py::
6
7 from ez_setup import use_setuptools
8 use_setuptools()
9
10If you want to require a specific version of setuptools, set a download
11mirror, or use an alternate download directory, you can do so by supplying
12the appropriate options to ``use_setuptools()``.
13
14This file can also be run as a script to install or upgrade setuptools.
15"""
16import sys
17DEFAULT_VERSION = "0.6c9"
18DEFAULT_URL = "http://pypi.python.org/packages/%s/s/setuptools/" % sys.version[:3]
19
20md5_data = {
21 'setuptools-0.6b1-py2.3.egg': '8822caf901250d848b996b7f25c6e6ca',
22 'setuptools-0.6b1-py2.4.egg': 'b79a8a403e4502fbb85ee3f1941735cb',
23 'setuptools-0.6b2-py2.3.egg': '5657759d8a6d8fc44070a9d07272d99b',
24 'setuptools-0.6b2-py2.4.egg': '4996a8d169d2be661fa32a6e52e4f82a',
25 'setuptools-0.6b3-py2.3.egg': 'bb31c0fc7399a63579975cad9f5a0618',
26 'setuptools-0.6b3-py2.4.egg': '38a8c6b3d6ecd22247f179f7da669fac',
27 'setuptools-0.6b4-py2.3.egg': '62045a24ed4e1ebc77fe039aa4e6f7e5',
28 'setuptools-0.6b4-py2.4.egg': '4cb2a185d228dacffb2d17f103b3b1c4',
29 'setuptools-0.6c1-py2.3.egg': 'b3f2b5539d65cb7f74ad79127f1a908c',
30 'setuptools-0.6c1-py2.4.egg': 'b45adeda0667d2d2ffe14009364f2a4b',
31 'setuptools-0.6c2-py2.3.egg': 'f0064bf6aa2b7d0f3ba0b43f20817c27',
32 'setuptools-0.6c2-py2.4.egg': '616192eec35f47e8ea16cd6a122b7277',
33 'setuptools-0.6c3-py2.3.egg': 'f181fa125dfe85a259c9cd6f1d7b78fa',
34 'setuptools-0.6c3-py2.4.egg': 'e0ed74682c998bfb73bf803a50e7b71e',
35 'setuptools-0.6c3-py2.5.egg': 'abef16fdd61955514841c7c6bd98965e',
36 'setuptools-0.6c4-py2.3.egg': 'b0b9131acab32022bfac7f44c5d7971f',
37 'setuptools-0.6c4-py2.4.egg': '2a1f9656d4fbf3c97bf946c0a124e6e2',
38 'setuptools-0.6c4-py2.5.egg': '8f5a052e32cdb9c72bcf4b5526f28afc',
39 'setuptools-0.6c5-py2.3.egg': 'ee9fd80965da04f2f3e6b3576e9d8167',
40 'setuptools-0.6c5-py2.4.egg': 'afe2adf1c01701ee841761f5bcd8aa64',
41 'setuptools-0.6c5-py2.5.egg': 'a8d3f61494ccaa8714dfed37bccd3d5d',
42 'setuptools-0.6c6-py2.3.egg': '35686b78116a668847237b69d549ec20',
43 'setuptools-0.6c6-py2.4.egg': '3c56af57be3225019260a644430065ab',
44 'setuptools-0.6c6-py2.5.egg': 'b2f8a7520709a5b34f80946de5f02f53',
45 'setuptools-0.6c7-py2.3.egg': '209fdf9adc3a615e5115b725658e13e2',
46 'setuptools-0.6c7-py2.4.egg': '5a8f954807d46a0fb67cf1f26c55a82e',
47 'setuptools-0.6c7-py2.5.egg': '45d2ad28f9750e7434111fde831e8372',
48 'setuptools-0.6c8-py2.3.egg': '50759d29b349db8cfd807ba8303f1902',
49 'setuptools-0.6c8-py2.4.egg': 'cba38d74f7d483c06e9daa6070cce6de',
50 'setuptools-0.6c8-py2.5.egg': '1721747ee329dc150590a58b3e1ac95b',
51 'setuptools-0.6c9-py2.3.egg': 'a83c4020414807b496e4cfbe08507c03',
52 'setuptools-0.6c9-py2.4.egg': '260a2be2e5388d66bdaee06abec6342a',
53 'setuptools-0.6c9-py2.5.egg': 'fe67c3e5a17b12c0e7c541b7ea43a8e6',
54 'setuptools-0.6c9-py2.6.egg': 'ca37b1ff16fa2ede6e19383e7b59245a',
55}
56
57import sys, os
58try: from hashlib import md5
59except ImportError: from md5 import md5
60
61def _validate_md5(egg_name, data):
62 if egg_name in md5_data:
63 digest = md5(data).hexdigest()
64 if digest != md5_data[egg_name]:
65 print >>sys.stderr, (
66 "md5 validation of %s failed! (Possible download problem?)"
67 % egg_name
68 )
69 sys.exit(2)
70 return data
71
72def use_setuptools(
73 version=DEFAULT_VERSION, download_base=DEFAULT_URL, to_dir=os.curdir,
74 download_delay=15
75):
76 """Automatically find/download setuptools and make it available on sys.path
77
78 `version` should be a valid setuptools version number that is available
79 as an egg for download under the `download_base` URL (which should end with
80 a '/'). `to_dir` is the directory where setuptools will be downloaded, if
81 it is not already available. If `download_delay` is specified, it should
82 be the number of seconds that will be paused before initiating a download,
83 should one be required. If an older version of setuptools is installed,
84 this routine will print a message to ``sys.stderr`` and raise SystemExit in
85 an attempt to abort the calling script.
86 """
87 was_imported = 'pkg_resources' in sys.modules or 'setuptools' in sys.modules
88 def do_download():
89 egg = download_setuptools(version, download_base, to_dir, download_delay)
90 sys.path.insert(0, egg)
91 import setuptools; setuptools.bootstrap_install_from = egg
92 try:
93 import pkg_resources
94 except ImportError:
95 return do_download()
96 try:
97 pkg_resources.require("setuptools>="+version); return
98 except pkg_resources.VersionConflict, e:
99 if was_imported:
100 print >>sys.stderr, (
101 "The required version of setuptools (>=%s) is not available, and\n"
102 "can't be installed while this script is running. Please install\n"
103 " a more recent version first, using 'easy_install -U setuptools'."
104 "\n\n(Currently using %r)"
105 ) % (version, e.args[0])
106 sys.exit(2)
107 else:
108 del pkg_resources, sys.modules['pkg_resources'] # reload ok
109 return do_download()
110 except pkg_resources.DistributionNotFound:
111 return do_download()
112
113def download_setuptools(
114 version=DEFAULT_VERSION, download_base=DEFAULT_URL, to_dir=os.curdir,
115 delay = 15
116):
117 """Download setuptools from a specified location and return its filename
118
119 `version` should be a valid setuptools version number that is available
120 as an egg for download under the `download_base` URL (which should end
121 with a '/'). `to_dir` is the directory where the egg will be downloaded.
122 `delay` is the number of seconds to pause before an actual download attempt.
123 """
124 import urllib2, shutil
125 egg_name = "setuptools-%s-py%s.egg" % (version,sys.version[:3])
126 url = download_base + egg_name
127 saveto = os.path.join(to_dir, egg_name)
128 src = dst = None
129 if not os.path.exists(saveto): # Avoid repeated downloads
130 try:
131 from distutils import log
132 if delay:
133 log.warn("""
134---------------------------------------------------------------------------
135This script requires setuptools version %s to run (even to display
136help). I will attempt to download it for you (from
137%s), but
138you may need to enable firewall access for this script first.
139I will start the download in %d seconds.
140
141(Note: if this machine does not have network access, please obtain the file
142
143 %s
144
145and place it in this directory before rerunning this script.)
146---------------------------------------------------------------------------""",
147 version, download_base, delay, url
148 ); from time import sleep; sleep(delay)
149 log.warn("Downloading %s", url)
150 src = urllib2.urlopen(url)
151 # Read/write all in one block, so we don't create a corrupt file
152 # if the download is interrupted.
153 data = _validate_md5(egg_name, src.read())
154 dst = open(saveto,"wb"); dst.write(data)
155 finally:
156 if src: src.close()
157 if dst: dst.close()
158 return os.path.realpath(saveto)
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195def main(argv, version=DEFAULT_VERSION):
196 """Install or upgrade setuptools and EasyInstall"""
197 try:
198 import setuptools
199 except ImportError:
200 egg = None
201 try:
202 egg = download_setuptools(version, delay=0)
203 sys.path.insert(0,egg)
204 from setuptools.command.easy_install import main
205 return main(list(argv)+[egg]) # we're done here
206 finally:
207 if egg and os.path.exists(egg):
208 os.unlink(egg)
209 else:
210 if setuptools.__version__ == '0.0.1':
211 print >>sys.stderr, (
212 "You have an obsolete version of setuptools installed. Please\n"
213 "remove it from your system entirely before rerunning this script."
214 )
215 sys.exit(2)
216
217 req = "setuptools>="+version
218 import pkg_resources
219 try:
220 pkg_resources.require(req)
221 except pkg_resources.VersionConflict:
222 try:
223 from setuptools.command.easy_install import main
224 except ImportError:
225 from easy_install import main
226 main(list(argv)+[download_setuptools(delay=0)])
227 sys.exit(0) # try to force an exit
228 else:
229 if argv:
230 from setuptools.command.easy_install import main
231 main(argv)
232 else:
233 print "Setuptools version",version,"or greater has been installed."
234 print '(Run "ez_setup.py -U setuptools" to reinstall or upgrade.)'
235
236def update_md5(filenames):
237 """Update our built-in md5 registry"""
238
239 import re
240
241 for name in filenames:
242 base = os.path.basename(name)
243 f = open(name,'rb')
244 md5_data[base] = md5(f.read()).hexdigest()
245 f.close()
246
247 data = [" %r: %r,\n" % it for it in md5_data.items()]
248 data.sort()
249 repl = "".join(data)
250
251 import inspect
252 srcfile = inspect.getsourcefile(sys.modules[__name__])
253 f = open(srcfile, 'rb'); src = f.read(); f.close()
254
255 match = re.search("\nmd5_data = {\n([^}]+)}", src)
256 if not match:
257 print >>sys.stderr, "Internal error!"
258 sys.exit(2)
259
260 src = src[:match.start(1)] + repl + src[match.end(1):]
261 f = open(srcfile,'w')
262 f.write(src)
263 f.close()
264
265
266if __name__=='__main__':
267 if len(sys.argv)>2 and sys.argv[1]=='--md5update':
268 update_md5(sys.argv[2:])
269 else:
270 main(sys.argv[1:])
271
272
273
274
275
0276
=== removed symlink 'lib/lazr/build'
=== target was '../../build'
=== added file 'setup.py'
--- setup.py 1970-01-01 00:00:00 +0000
+++ setup.py 2009-10-27 09:01:09 +0000
@@ -0,0 +1,47 @@
1# Copyright 2009 Canonical Ltd. All rights reserved.
2
3import ez_setup
4ez_setup.use_setuptools()
5
6import sys
7from setuptools import setup, find_packages
8
9__version__ = '0.9'
10
11
12setup(
13 name='lazr-js',
14 namespace_packages=['lazr'],
15 version=__version__,
16 packages=['lazr', 'lazrjs'],
17 py_modules=['jsmin', 'slimmer'],
18 package_dir={
19 'lazrjs': 'src-js/lazrjs',
20 '': 'src-py'},
21 include_package_data=True,
22 zip_safe=False,
23 maintainer='Canonical JavaScripters',
24 maintainer_email='lazr-dev@lists.launchpad.net',
25 description=('Collection of JS widgets'),
26 license='GPL v3',
27 install_requires=[
28 'bzr',
29 'setuptools',
30 ],
31 url='https://launchpad.net/lazr-js',
32 classifiers=[
33 "Development Status :: 5 - Production/Stable",
34 "Intended Audience :: Developers",
35 "Programming Language :: JavaScript",
36 "Programming Language :: Python",
37 ],
38 extras_require=dict(
39 ),
40 entry_points=dict(
41 console_scripts=[
42 'build=lazr.js.build:main',
43 'jslint=lazr.js.jslint:main',
44 'scaffold=lazr.js.scaffold:main',
45 ]
46 ),
47)
048
=== renamed directory 'src' => 'src-js'
=== added directory 'src-js/lazrjs'
=== added file 'src-js/lazrjs/__init__.py'
=== renamed directory 'src/activator' => 'src-js/lazrjs/activator'
=== renamed directory 'src/anim' => 'src-js/lazrjs/anim'
=== renamed directory 'src/autocomplete' => 'src-js/lazrjs/autocomplete'
=== renamed directory 'src/choiceedit' => 'src-js/lazrjs/choiceedit'
=== renamed directory 'src/effects' => 'src-js/lazrjs/effects'
=== renamed directory 'src/formoverlay' => 'src-js/lazrjs/formoverlay'
=== renamed directory 'src/inlineedit' => 'src-js/lazrjs/inlineedit'
=== renamed directory 'src/lazr' => 'src-js/lazrjs/lazr'
=== renamed directory 'src/overlay' => 'src-js/lazrjs/overlay'
=== renamed directory 'src/picker' => 'src-js/lazrjs/picker'
=== renamed directory 'src/testing' => 'src-js/lazrjs/testing'
=== renamed directory 'lib/yui' => 'src-js/lazrjs/yui'
=== renamed directory 'lib' => 'src-py'
=== added file 'src-py/lazr/__init__.py'
--- src-py/lazr/__init__.py 1970-01-01 00:00:00 +0000
+++ src-py/lazr/__init__.py 2009-10-27 09:01:09 +0000
@@ -0,0 +1,8 @@
1# This is a namespace package.
2try:
3 import pkg_resources
4 pkg_resources.declare_namespace(__name__)
5except ImportError:
6 import pkgutil
7 __path__ = pkgutil.extend_path(__path__, __name__)
8
09
=== added directory 'src-py/lazr/js'
=== added file 'src-py/lazr/js/__init__.py'
=== renamed file 'tools/build.py' => 'src-py/lazr/js/build.py'
--- tools/build.py 2009-01-09 16:02:00 +0000
+++ src-py/lazr/js/build.py 2009-10-27 09:01:09 +0000
@@ -1,5 +1,3 @@
1#!/usr/bin/python
2
3"""build.py - Minifies and creates the JS build directory."""1"""build.py - Minifies and creates the JS build directory."""
42
5__metaclass__ = type3__metaclass__ = type
@@ -13,14 +11,14 @@
1311
14from glob import glob12from glob import glob
1513
14import pkg_resources
15
16HERE = os.path.dirname(__file__)16HERE = os.path.dirname(__file__)
17BUILD_DIR = os.path.normpath(os.path.join(HERE, '..', 'build'))17BUILD_DIR = os.path.normpath(os.path.join(HERE, '..', '..', '..', 'build'))
18SRC_DIR = os.path.normpath(os.path.join(HERE, '..', 'src'))18SRC_DIR = pkg_resources.resource_filename(
19LIB_DIR = os.path.normpath(os.path.join(HERE, '../', 'lib'))19 pkg_resources.Requirement.parse("lazr-js"), "lazrjs")
2020
21# Add the ../lib directory to the python path21import lazrjs
22sys.path.insert(0, LIB_DIR)
23
24from jsmin import JavascriptMinify22from jsmin import JavascriptMinify
25from slimmer import css_slimmer23from slimmer import css_slimmer
2624
@@ -122,6 +120,9 @@
122 self.extra_files = []120 self.extra_files = []
123 else:121 else:
124 self.extra_files = extra_files122 self.extra_files = extra_files
123 # If we build the lazr-js widgets, make sure that YUI source is
124 # included as well, since we depend on it being available.
125 self.include_yui = (src_dir == SRC_DIR)
125126
126 def log(self, msg):127 def log(self, msg):
127 sys.stdout.write(msg + '\n')128 sys.stdout.write(msg + '\n')
@@ -314,15 +315,26 @@
314315
315 def do_build(self):316 def do_build(self):
316 for name, cpath in self.find_components():317 for name, cpath in self.find_components():
318 files_to_link = glob(os.path.join(cpath, '*.js'))
319 if len(files_to_link) == 0:
320 continue
317 self.ensure_build_directory(name)321 self.ensure_build_directory(name)
318322
319 for js_file in glob(os.path.join(cpath, '*.js')):323 for js_file in files_to_link:
320 self.link_and_minify(name, js_file)324 self.link_and_minify(name, js_file)
321325
322 self.build_assets(name)326 self.build_assets(name)
323327
324 self.update_combined_js_file()328 self.update_combined_js_file()
325 self.update_combined_css_skins()329 self.update_combined_css_skins()
330 if self.include_yui:
331 self.link_yui_directory()
332
333 def link_yui_directory(self):
334 """Link to the built yui source directory."""
335 yui_directory = os.path.join(os.path.dirname(lazrjs.__file__), 'yui')
336 link_location = os.path.join(self.build_dir, 'yui')
337 self.ensure_link(yui_directory, link_location)
326338
327339
328def get_options():340def get_options():
@@ -345,7 +357,7 @@
345 return parser.parse_args()357 return parser.parse_args()
346358
347359
348if __name__ == '__main__':360def main():
349 options, extra= get_options()361 options, extra= get_options()
350 Builder(362 Builder(
351 name=options.name,363 name=options.name,
352364
=== renamed file 'lib/fulljslint.js' => 'src-py/lazr/js/fulljslint.js'
=== renamed file 'tools/jslint-wrapper.js' => 'src-py/lazr/js/jslint-wrapper.js'
=== renamed file 'tools/jslint.py' => 'src-py/lazr/js/jslint.py'
--- tools/jslint.py 2009-01-05 23:05:43 +0000
+++ src-py/lazr/js/jslint.py 2009-10-27 09:01:09 +0000
@@ -1,4 +1,3 @@
1#!/usr/bin/python
2"""jslint.py - run the JSLint linter ."""1"""jslint.py - run the JSLint linter ."""
32
4__metaclass__ = type3__metaclass__ = type
@@ -13,7 +12,7 @@
13from bzrlib.plugin import load_plugins12from bzrlib.plugin import load_plugins
1413
15HERE = os.path.join(os.path.dirname(__file__))14HERE = os.path.join(os.path.dirname(__file__))
16FULLJSLINT = os.path.join(HERE, os.path.pardir, 'lib', 'fulljslint.js')15FULLJSLINT = os.path.join(HERE, 'fulljslint.js')
17JSLINT_WRAPPER = os.path.join(HERE, 'jslint-wrapper.js')16JSLINT_WRAPPER = os.path.join(HERE, 'jslint-wrapper.js')
1817
1918
@@ -159,7 +158,7 @@
159 return options, args158 return options, args
160159
161160
162if __name__ == '__main__':161def main():
163 load_plugins()162 load_plugins()
164 options, args = get_options()163 options, args = get_options()
165 linter = JSLinter(options.options)164 linter = JSLinter(options.options)
166165
=== renamed file 'tools/scaffold.py' => 'src-py/lazr/js/scaffold.py'
--- tools/scaffold.py 2009-03-19 14:24:56 +0000
+++ src-py/lazr/js/scaffold.py 2009-10-27 09:01:09 +0000
@@ -1,4 +1,3 @@
1#!/usr/bin/python
2"""1"""
3A script to automatically create the files for a new widget.2A script to automatically create the files for a new widget.
43
@@ -70,7 +69,7 @@
70 test_js_template = find_path(skel_dir, 'template.test-js')69 test_js_template = find_path(skel_dir, 'template.test-js')
71 example_template = find_path(skel_dir, 'template.example')70 example_template = find_path(skel_dir, 'template.example')
72 css_template = find_path(skel_dir, 'template.css')71 css_template = find_path(skel_dir, 'template.css')
73 src_dir = find_path('.', 'src')72 src_dir = find_path('.', 'src-js')
74 example_dir = find_path('.', 'examples')73 example_dir = find_path('.', 'examples')
7574
76 def write_file(template, dest):75 def write_file(template, dest):
@@ -100,7 +99,7 @@
100 write_file(example_template, join(example, 'index.html'))99 write_file(example_template, join(example, 'index.html'))
101100
102101
103if __name__ == '__main__':102def main():
104 if len(sys.argv) != 2:103 if len(sys.argv) != 2:
105 print usage104 print usage
106 sys.exit(1)105 sys.exit(1)
107106
=== renamed directory 'tools/skel' => 'src-py/lazr/js/skel'
=== added symlink 'src-py/lazrjs'
=== target is u'../src-js/lazrjs'

Subscribers

People subscribed via source and target branches