|
1 Running setup scripts |
|
2 ===================== |
|
3 |
|
4 Buildouts are often used to work on packages that will be distributed |
|
5 as eggs. During development, we use develop eggs. When you've |
|
6 completed a development cycle, you'll need to run your setup script to |
|
7 generate a distribution and, perhaps, uploaded it to the Python |
|
8 package index. If your script uses setuptools, you'll need setuptools |
|
9 in your Python path, which may be an issue if you haven't installed |
|
10 setuptools into your Python installation. |
|
11 |
|
12 The buildout setup command is helpful in a situation like this. It |
|
13 can be used to run a setup script and it does so with the setuptools |
|
14 egg in the Python path and with setuptools already imported. The fact |
|
15 that setuptools is imported means that you can use setuptools-based |
|
16 commands, like bdist_egg even with packages that don't use setuptools. |
|
17 To illustrate this, we'll create a package in a sample buildout: |
|
18 |
|
19 >>> mkdir('hello') |
|
20 >>> write('hello', 'hello.py', 'print "Hello World!"') |
|
21 >>> write('hello', 'README', 'This is hello') |
|
22 >>> write('hello', 'setup.py', |
|
23 ... """ |
|
24 ... from distutils.core import setup |
|
25 ... setup(name="hello", |
|
26 ... version="1.0", |
|
27 ... py_modules=["hello"], |
|
28 ... author="Bob", |
|
29 ... author_email="bob@foo.com", |
|
30 ... ) |
|
31 ... """) |
|
32 |
|
33 We can use the buildout command to generate the hello egg: |
|
34 |
|
35 >>> print system(buildout +' setup hello -q bdist_egg'), |
|
36 Running setup script 'hello/setup.py'. |
|
37 zip_safe flag not set; analyzing archive contents... |
|
38 |
|
39 The hello directory now has a hello egg in it's dist directory: |
|
40 |
|
41 >>> ls('hello', 'dist') |
|
42 - hello-1.0-py2.4.egg |