README.rst 18.8 KB
Newer Older
1 2 3
Installation of distributions as eggs
=====================================

4
The zc.recipe.egg:eggs recipe can be used to install various types if
5 6
distutils distributions as eggs.  It takes a number of options:

7
eggs
8
    A list of eggs to install given as one or more setuptools
9 10
    requirement strings.  Each string must be given on a separate
    line.
11

12 13 14 15 16 17 18 19 20 21 22 23 24
patch-binary
   The path to the patch executable.

EGGNAME-patches
   A new-line separated list of patchs to apply when building.

EGGNAME-patch-options
   Options to give to the patch program when applying patches.

EGGNAME-patch-revision
   An integer to specify the revision (default is the number of
   patches).

25
find-links
26 27
   A list of URLs, files, or directories to search for distributions.

28 29 30 31 32 33 34 35
index
   The URL of an index server, or almost any other valid URL. :)

   If not specified, the Python Package Index,
   http://cheeseshop.python.org/pypi, is used.  You can specify an
   alternate index with this option.  If you use the links option and
   if the links point to the needed distributions, then the index can
   be anything and will be largely ignored.  In the examples, here,
36
   we'll just point to an empty directory on our link server.  This
37 38
   will make our examples run a little bit faster.

39
We have a link server that has a number of distributions:
40

Jim Fulton's avatar
Jim Fulton committed
41
    >>> print_(get(link_server), end='')
42
    <html><body>
43
    <a href="bigdemo-0.1-py2.3.egg">bigdemo-0.1-py2.3.egg</a><br>
44 45 46
    <a href="demo-0.1-py2.3.egg">demo-0.1-py2.3.egg</a><br>
    <a href="demo-0.2-py2.3.egg">demo-0.2-py2.3.egg</a><br>
    <a href="demo-0.3-py2.3.egg">demo-0.3-py2.3.egg</a><br>
47
    <a href="demo-0.4rc1-py2.3.egg">demo-0.4rc1-py2.3.egg</a><br>
48 49
    <a href="demoneeded-1.0.zip">demoneeded-1.0.zip</a><br>
    <a href="demoneeded-1.1.zip">demoneeded-1.1.zip</a><br>
50
    <a href="demoneeded-1.2rc1.zip">demoneeded-1.2rc1.zip</a><br>
51
    <a href="du_zipped-1.0-pyN.N.egg">du_zipped-1.0-pyN.N.egg</a><br>
52
    <a href="extdemo-1.4.zip">extdemo-1.4.zip</a><br>
53 54 55 56
    <a href="index/">index/</a><br>
    <a href="other-1.0-py2.3.egg">other-1.0-py2.3.egg</a><br>
    </body></html>

57
We have a sample buildout.  Let's update it's configuration file to
58
install the demo package.
59 60 61 62 63 64 65

    >>> write(sample_buildout, 'buildout.cfg',
    ... """
    ... [buildout]
    ... parts = demo
    ...
    ... [demo]
66
    ... recipe = zc.recipe.egg:eggs
67
    ... eggs = demo<0.3
68 69 70
    ... find-links = %(server)s
    ... index = %(server)s/index
    ... """ % dict(server=link_server))
71

72
In this example, we limited ourselves to revisions before 0.3. We also
73
specified where to find distributions using the find-links option.
74 75 76 77

Let's run the buildout:

    >>> import os
Jim Fulton's avatar
Jim Fulton committed
78
    >>> print_(system(buildout), end='')
79 80 81 82
    Installing demo.
    Getting distribution for 'demo<0.3'.
    Got demo 0.2.
    Getting distribution for 'demoneeded'.
Jim Fulton's avatar
Jim Fulton committed
83
    Got demoneeded 1.1.
84

85 86 87
Now, if we look at the buildout eggs directory:

    >>> ls(sample_buildout, 'eggs')
Jim Fulton's avatar
Jim Fulton committed
88
    d  demo-0.2-py2.3.egg
Jim Fulton's avatar
Jim Fulton committed
89
    d  demoneeded-1.1-py2.3.egg
90
    -  setuptools-0.7-py2.3.egg
Jim Fulton's avatar
Jim Fulton committed
91
    d  zc.buildout-1.0-py2.3.egg
92 93

We see that we got an egg for demo that met the requirement, as well
94
as the egg for demoneeded, which demo requires.  (We also see an egg
95 96 97
link for the recipe in the develop-eggs directory.  This egg link was
actually created as part of the sample buildout setup. Normally, when
using the recipe, you'll get a regular egg installation.)
98

99 100 101
Script generation
-----------------

102 103 104 105 106
The demo egg defined a script, but we didn't get one installed:

    >>> ls(sample_buildout, 'bin')
    -  buildout

107
If we want scripts provided by eggs to be installed, we should use the
108 109 110 111 112 113 114 115 116 117 118 119 120 121
scripts recipe:

    >>> write(sample_buildout, 'buildout.cfg',
    ... """
    ... [buildout]
    ... parts = demo
    ...
    ... [demo]
    ... recipe = zc.recipe.egg:scripts
    ... eggs = demo<0.3
    ... find-links = %(server)s
    ... index = %(server)s/index
    ... """ % dict(server=link_server))

Jim Fulton's avatar
Jim Fulton committed
122
    >>> print_(system(buildout), end='')
123 124 125
    Uninstalling demo.
    Installing demo.
    Generated script '/sample-buildout/bin/demo'.
126

Chris Withers's avatar
Chris Withers committed
127
Now we also see the script defined by the demo script:
128 129 130 131 132

    >>> ls(sample_buildout, 'bin')
    -  buildout
    -  demo

133 134 135
The scripts recipe defines some additional options:

entry-points
Chris Withers's avatar
Chris Withers committed
136 137 138 139 140
   A list of entry-point identifiers of the form:

   name=module:attrs

   where name is a script name, module is a dotted name resolving to a
141
   module name, and attrs is a dotted name resolving to a callable
Chris Withers's avatar
Chris Withers committed
142 143 144 145
   object within a module.

   This option is useful when working with distributions that don't
   declare entry points, such as distributions not written to work
146
   with setuptools.
Chris Withers's avatar
Chris Withers committed
147 148

   Examples can be seen in the section "Specifying entry points" below.
149 150 151 152 153 154 155 156 157

scripts
   Control which scripts are generated.  The value should be a list of
   zero or more tokens.  Each token is either a name, or a name
   followed by an '=' and a new name.  Only the named scripts are
   generated.  If no tokens are given, then script generation is
   disabled.  If the option isn't given at all, then all scripts
   defined by the named eggs will be generated.

158 159 160 161
dependent-scripts
   If set to the string "true", scripts will be generated for all
   required eggs in addition to the eggs specifically named.

162 163 164 165 166
interpreter
   The name of a script to generate that allows access to a Python
   interpreter that has the path set based on the eggs installed.

extra-paths
Chris Withers's avatar
Chris Withers committed
167
   Extra paths to include in a generated script.
168

169 170 171 172 173 174 175 176
initialization
   Specify some Python initialization code.  This is very limited.  In
   particular, be aware that leading whitespace is stripped from the
   code given.

arguments
   Specify some arguments to be passed to entry points as Python source.

177 178 179 180 181 182
relative-paths
   If set to true, then egg paths will be generated relative to the
   script path.  This allows a buildout to be moved without breaking
   egg paths.  This option can be set in either the script section or
   in the buildout section.

183 184 185 186 187 188 189 190 191 192 193 194 195 196 197
Let's add an interpreter option:

    >>> write(sample_buildout, 'buildout.cfg',
    ... """
    ... [buildout]
    ... parts = demo
    ...
    ... [demo]
    ... recipe = zc.recipe.egg
    ... eggs = demo<0.3
    ... find-links = %(server)s
    ... index = %(server)s/index
    ... interpreter = py-demo
    ... """ % dict(server=link_server))

pombredanne's avatar
pombredanne committed
198
Note that we omitted the entry point name from the recipe
Chris Withers's avatar
Chris Withers committed
199
specification. We were able to do this because the scripts recipe is
200 201
the default entry point for the zc.recipe.egg egg.

Jim Fulton's avatar
Jim Fulton committed
202
   >>> print_(system(buildout), end='')
203 204 205 206
   Uninstalling demo.
   Installing demo.
   Generated script '/sample-buildout/bin/demo'.
   Generated interpreter '/sample-buildout/bin/py-demo'.
207 208

Now we also get a py-demo script for giving us a Python prompt with
209
the path for demo and any eggs it depends on included in sys.path.
Jim Fulton's avatar
Jim Fulton committed
210
This is useful for debugging and testing.
211

212 213 214 215 216
    >>> ls(sample_buildout, 'bin')
    -  buildout
    -  demo
    -  py-demo

217 218
If we run the demo script, it prints out some minimal data:

Jim Fulton's avatar
Jim Fulton committed
219
    >>> print_(system(join(sample_buildout, 'bin', 'demo')), end='')
Jim Fulton's avatar
Jim Fulton committed
220
    2 1
221 222 223 224

The value it prints out happens to be some values defined in the
modules installed.

Jim Fulton's avatar
Jim Fulton committed
225
We can also run the py-demo script.  Here we'll just print_(out)
226 227
the bits if the path added to reflect the eggs:

Jim Fulton's avatar
Jim Fulton committed
228
    >>> print_(system(join(sample_buildout, 'bin', 'py-demo'),
Jim Fulton's avatar
Jim Fulton committed
229 230 231
    ... """import os, sys
    ... for p in sys.path:
    ...     if 'demo' in p:
Jim Fulton's avatar
Jim Fulton committed
232
    ...         _ = sys.stdout.write(os.path.basename(p)+'\\n')
Jim Fulton's avatar
Jim Fulton committed
233
    ...
Jim Fulton's avatar
Jim Fulton committed
234
    ... """).replace('>>> ', '').replace('... ', ''), end='')
Jim Fulton's avatar
Jim Fulton committed
235 236
    ... # doctest: +ELLIPSIS +NORMALIZE_WHITESPACE
    demo-0.2-py2.4.egg
Jim Fulton's avatar
Jim Fulton committed
237
    demoneeded-1.1-py2.4.egg
238

239 240 241 242 243 244 245
Egg updating
------------

The recipe normally gets the most recent distribution that satisfies the
specification.  It won't do this is the buildout is either in
non-newest mode or in offline mode.  To see how this works, we'll
remove the restriction on demo:
Jim Fulton's avatar
Jim Fulton committed
246 247 248 249 250 251 252 253

    >>> write(sample_buildout, 'buildout.cfg',
    ... """
    ... [buildout]
    ... parts = demo
    ...
    ... [demo]
    ... recipe = zc.recipe.egg
254 255 256
    ... find-links = %(server)s
    ... index = %(server)s/index
    ... """ % dict(server=link_server))
Jim Fulton's avatar
Jim Fulton committed
257

258 259
and run the buildout in non-newest mode:

Jim Fulton's avatar
Jim Fulton committed
260
    >>> print_(system(buildout+' -N'), end='')
261 262 263
    Uninstalling demo.
    Installing demo.
    Generated script '/sample-buildout/bin/demo'.
264 265 266 267 268 269 270

Note that we removed the eggs option, and the eggs defaulted to the
part name. Because we removed the eggs option, the demo was
reinstalled.

We'll also run the buildout in off-line mode:

Jim Fulton's avatar
Jim Fulton committed
271
    >>> print_(system(buildout+' -o'), end='')
272
    Updating demo.
273 274 275 276

We didn't get an update for demo:

    >>> ls(sample_buildout, 'eggs')
Jim Fulton's avatar
Jim Fulton committed
277
    d  demo-0.2-py2.3.egg
Jim Fulton's avatar
Jim Fulton committed
278
    d  demoneeded-1.1-py2.3.egg
279
    -  setuptools-0.7-py2.3.egg
Jim Fulton's avatar
Jim Fulton committed
280
    d  zc.buildout-1.0-py2.3.egg
281

282
If we run the buildout on the default online and newest modes,
283 284
we'll get an update for demo:

Jim Fulton's avatar
Jim Fulton committed
285
    >>> print_(system(buildout), end='')
286 287
    Updating demo.
    Getting distribution for 'demo'.
Jim Fulton's avatar
Jim Fulton committed
288
    Got demo 0.3.
289
    Generated script '/sample-buildout/bin/demo'.
Jim Fulton's avatar
Jim Fulton committed
290 291 292 293

Then we'll get a new demo egg:

    >>> ls(sample_buildout, 'eggs')
Jim Fulton's avatar
Jim Fulton committed
294
    d  demo-0.2-py2.3.egg
Jim Fulton's avatar
Jim Fulton committed
295 296
    d  demo-0.3-py2.3.egg
    d  demoneeded-1.1-py2.3.egg
297
    -  setuptools-0.7-py2.4.egg
Jim Fulton's avatar
Jim Fulton committed
298
    d  zc.buildout-1.0-py2.4.egg
Jim Fulton's avatar
Jim Fulton committed
299 300 301

The script is updated too:

Jim Fulton's avatar
Jim Fulton committed
302
    >>> print_(system(join(sample_buildout, 'bin', 'demo')), end='')
Jim Fulton's avatar
Jim Fulton committed
303
    3 1
Jim Fulton's avatar
Jim Fulton committed
304

305 306 307
Controlling script generation
-----------------------------

Jim Fulton's avatar
Jim Fulton committed
308 309 310 311 312 313 314 315 316 317 318
You can control which scripts get generated using the scripts option.
For example, to suppress scripts, use the scripts option without any
arguments:

    >>> write(sample_buildout, 'buildout.cfg',
    ... """
    ... [buildout]
    ... parts = demo
    ...
    ... [demo]
    ... recipe = zc.recipe.egg
319 320
    ... find-links = %(server)s
    ... index = %(server)s/index
Jim Fulton's avatar
Jim Fulton committed
321
    ... scripts =
322
    ... """ % dict(server=link_server))
Jim Fulton's avatar
Jim Fulton committed
323 324


Jim Fulton's avatar
Jim Fulton committed
325
    >>> print_(system(buildout), end='')
326 327
    Uninstalling demo.
    Installing demo.
Jim Fulton's avatar
Jim Fulton committed
328 329 330 331 332 333 334 335 336 337 338 339 340

    >>> ls(sample_buildout, 'bin')
    -  buildout

You can also control the name used for scripts:

    >>> write(sample_buildout, 'buildout.cfg',
    ... """
    ... [buildout]
    ... parts = demo
    ...
    ... [demo]
    ... recipe = zc.recipe.egg
341 342
    ... find-links = %(server)s
    ... index = %(server)s/index
Jim Fulton's avatar
Jim Fulton committed
343
    ... scripts = demo=foo
344
    ... """ % dict(server=link_server))
Jim Fulton's avatar
Jim Fulton committed
345

Jim Fulton's avatar
Jim Fulton committed
346
    >>> print_(system(buildout), end='')
347 348 349
    Uninstalling demo.
    Installing demo.
    Generated script '/sample-buildout/bin/foo'.
Jim Fulton's avatar
Jim Fulton committed
350 351 352 353

    >>> ls(sample_buildout, 'bin')
    -  buildout
    -  foo
354 355 356

Specifying extra script paths
-----------------------------
357

358 359 360 361 362 363 364 365 366 367 368 369 370
If we need to include extra paths in a script, we can use the
extra-paths option:

    >>> write(sample_buildout, 'buildout.cfg',
    ... """
    ... [buildout]
    ... parts = demo
    ...
    ... [demo]
    ... recipe = zc.recipe.egg
    ... find-links = %(server)s
    ... index = %(server)s/index
    ... scripts = demo=foo
371
    ... extra-paths =
372
    ...    /foo/bar
373
    ...    ${buildout:directory}/spam
374 375
    ... """ % dict(server=link_server))

Jim Fulton's avatar
Jim Fulton committed
376
    >>> print_(system(buildout), end='')
377 378 379
    Uninstalling demo.
    Installing demo.
    Generated script '/sample-buildout/bin/foo'.
380 381 382 383

Let's look at the script that was generated:

    >>> cat(sample_buildout, 'bin', 'foo') # doctest: +NORMALIZE_WHITESPACE
Jim Fulton's avatar
Jim Fulton committed
384
    #!/usr/local/bin/python2.7
385 386 387
    <BLANKLINE>
    import sys
    sys.path[0:0] = [
Jim Fulton's avatar
Jim Fulton committed
388 389
      '/sample-buildout/eggs/demo-0.3-py2.4.egg',
      '/sample-buildout/eggs/demoneeded-1.1-py2.4.egg',
390
      '/foo/bar',
391 392 393 394 395 396
      '/sample-buildout/spam',
      ]
    <BLANKLINE>
    import eggrecipedemo
    <BLANKLINE>
    if __name__ == '__main__':
397
        sys.exit(eggrecipedemo.main())
398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422

Relative egg paths
------------------

If the relative-paths option is specified with a true value, then
paths will be generated relative to the script. This is useful when
you want to be able to move a buildout directory around without
breaking scripts.

    >>> write(sample_buildout, 'buildout.cfg',
    ... """
    ... [buildout]
    ... parts = demo
    ...
    ... [demo]
    ... recipe = zc.recipe.egg
    ... find-links = %(server)s
    ... index = %(server)s/index
    ... scripts = demo=foo
    ... relative-paths = true
    ... extra-paths =
    ...    /foo/bar
    ...    ${buildout:directory}/spam
    ... """ % dict(server=link_server))

Jim Fulton's avatar
Jim Fulton committed
423
    >>> print_(system(buildout), end='')
424 425 426 427 428 429 430
    Uninstalling demo.
    Installing demo.
    Generated script '/sample-buildout/bin/foo'.

Let's look at the script that was generated:

    >>> cat(sample_buildout, 'bin', 'foo') # doctest: +NORMALIZE_WHITESPACE
Jim Fulton's avatar
Jim Fulton committed
431
    #!/usr/local/bin/python2.7
432 433 434 435
    <BLANKLINE>
    import os
    <BLANKLINE>
    join = os.path.join
Jim Fulton's avatar
Jim Fulton committed
436
    base = os.path.dirname(os.path.abspath(os.path.realpath(__file__)))
437
    base = os.path.dirname(base)
438 439 440
    <BLANKLINE>
    import sys
    sys.path[0:0] = [
Jim Fulton's avatar
Jim Fulton committed
441 442
      join(base, 'eggs/demo-0.3-pyN.N.egg'),
      join(base, 'eggs/demoneeded-1.1-pyN.N.egg'),
443
      '/foo/bar',
444
      join(base, 'spam'),
445 446 447 448 449
      ]
    <BLANKLINE>
    import eggrecipedemo
    <BLANKLINE>
    if __name__ == '__main__':
450
        sys.exit(eggrecipedemo.main())
451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471

You can specify relative paths in the buildout section, rather than in
each individual script section:


    >>> write(sample_buildout, 'buildout.cfg',
    ... """
    ... [buildout]
    ... parts = demo
    ... relative-paths = true
    ...
    ... [demo]
    ... recipe = zc.recipe.egg
    ... find-links = %(server)s
    ... index = %(server)s/index
    ... scripts = demo=foo
    ... extra-paths =
    ...    /foo/bar
    ...    ${buildout:directory}/spam
    ... """ % dict(server=link_server))

Jim Fulton's avatar
Jim Fulton committed
472
    >>> print_(system(buildout), end='')
473 474 475 476 477
    Uninstalling demo.
    Installing demo.
    Generated script '/sample-buildout/bin/foo'.

    >>> cat(sample_buildout, 'bin', 'foo') # doctest: +NORMALIZE_WHITESPACE
Jim Fulton's avatar
Jim Fulton committed
478
    #!/usr/local/bin/python2.7
479 480 481 482
    <BLANKLINE>
    import os
    <BLANKLINE>
    join = os.path.join
Jim Fulton's avatar
Jim Fulton committed
483
    base = os.path.dirname(os.path.abspath(os.path.realpath(__file__)))
484
    base = os.path.dirname(base)
485 486 487
    <BLANKLINE>
    import sys
    sys.path[0:0] = [
Jim Fulton's avatar
Jim Fulton committed
488 489
      join(base, 'eggs/demo-0.3-pyN.N.egg'),
      join(base, 'eggs/demoneeded-1.1-pyN.N.egg'),
490
      '/foo/bar',
491
      join(base, 'spam'),
492 493 494 495 496
      ]
    <BLANKLINE>
    import eggrecipedemo
    <BLANKLINE>
    if __name__ == '__main__':
497
        sys.exit(eggrecipedemo.main())
498

pombredanne's avatar
pombredanne committed
499
Specifying initialization code and arguments
500 501
-----------------------------------------------

Chris Withers's avatar
Chris Withers committed
502
Sometimes, we need to do more than just calling entry points.  We can
pombredanne's avatar
pombredanne committed
503
use the initialization and arguments options to specify extra code
504 505 506 507 508 509 510 511 512 513 514 515 516 517 518
to be included in generated scripts:


    >>> write(sample_buildout, 'buildout.cfg',
    ... """
    ... [buildout]
    ... parts = demo
    ...
    ... [demo]
    ... recipe = zc.recipe.egg
    ... find-links = %(server)s
    ... index = %(server)s/index
    ... scripts = demo=foo
    ... extra-paths =
    ...    /foo/bar
519
    ...    ${buildout:directory}/spam
520 521
    ... initialization = a = (1, 2
    ...                       3, 4)
522
    ... interpreter = py
523 524 525
    ... arguments = a, 2
    ... """ % dict(server=link_server))

Jim Fulton's avatar
Jim Fulton committed
526
    >>> print_(system(buildout), end='')
527 528 529
    Uninstalling demo.
    Installing demo.
    Generated script '/sample-buildout/bin/foo'.
530
    Generated interpreter '/sample-buildout/bin/py'.
531 532

    >>> cat(sample_buildout, 'bin', 'foo') # doctest: +NORMALIZE_WHITESPACE
Jim Fulton's avatar
Jim Fulton committed
533
    #!/usr/local/bin/python2.7
534 535 536
    <BLANKLINE>
    import sys
    sys.path[0:0] = [
Jim Fulton's avatar
Jim Fulton committed
537 538
      '/sample-buildout/eggs/demo-0.3-py2.4.egg',
      '/sample-buildout/eggs/demoneeded-1.1-py2.4.egg',
539
      '/foo/bar',
540
      '/sample-buildout/spam',
541 542 543 544 545 546 547 548
      ]
    <BLANKLINE>
    a = (1, 2
    3, 4)
    <BLANKLINE>
    import eggrecipedemo
    <BLANKLINE>
    if __name__ == '__main__':
549
        sys.exit(eggrecipedemo.main(a, 2))
550 551

Here we see that the initialization code we specified was added after
Chris Withers's avatar
Chris Withers committed
552
setting the path.  Note, as mentioned above, that leading whitespace
553 554 555
has been stripped.  Similarly, the argument code we specified was
added in the entry point call (to main).

556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577
Our interpreter also has the initialization code:

    >>> cat(sample_buildout, 'bin', 'py')
    ... # doctest: +NORMALIZE_WHITESPACE +ELLIPSIS
    #!/usr/local/bin/python2.7
    <BLANKLINE>
    import sys
    <BLANKLINE>
    sys.path[0:0] = [
      '/sample-buildout/eggs/demo-0.3-py3.3.egg',
      '/sample-buildout/eggs/demoneeded-1.1-py3.3.egg',
      '/foo/bar',
      '/sample-buildout/spam',
      ]
    <BLANKLINE>
    a = (1, 2
    3, 4)
    <BLANKLINE>
    <BLANKLINE>
    _interactive = True
    ...

578 579 580
Specifying entry points
-----------------------

581 582
Scripts can be generated for entry points declared explicitly.  We can
declare entry points using the entry-points option:
583

584 585 586 587 588 589 590 591 592
    >>> write(sample_buildout, 'buildout.cfg',
    ... """
    ... [buildout]
    ... parts = demo
    ...
    ... [demo]
    ... recipe = zc.recipe.egg
    ... find-links = %(server)s
    ... index = %(server)s/index
593
    ... extra-paths =
594
    ...    /foo/bar
595
    ...    ${buildout:directory}/spam
596 597 598
    ... entry-points = alt=eggrecipedemo:alt other=foo.bar:a.b.c
    ... """ % dict(server=link_server))

Jim Fulton's avatar
Jim Fulton committed
599
    >>> print_(system(buildout), end='')
600 601 602 603 604
    Uninstalling demo.
    Installing demo.
    Generated script '/sample-buildout/bin/demo'.
    Generated script '/sample-buildout/bin/alt'.
    Generated script '/sample-buildout/bin/other'.
605 606 607 608 609 610 611 612

    >>> ls(sample_buildout, 'bin')
    -  alt
    -  buildout
    -  demo
    -  other

    >>> cat(sample_buildout, 'bin', 'other')
Jim Fulton's avatar
Jim Fulton committed
613
    #!/usr/local/bin/python2.7
614 615 616
    <BLANKLINE>
    import sys
    sys.path[0:0] = [
Jim Fulton's avatar
Jim Fulton committed
617 618
      '/sample-buildout/eggs/demo-0.3-py2.4.egg',
      '/sample-buildout/eggs/demoneeded-1.1-py2.4.egg',
619
      '/foo/bar',
620
      '/sample-buildout/spam',
621 622 623 624 625
      ]
    <BLANKLINE>
    import foo.bar
    <BLANKLINE>
    if __name__ == '__main__':
626
        sys.exit(foo.bar.a.b.c())
627

628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645
Generating all scripts
----------------------

The `bigdemo` package doesn't have any scripts, but it requires the `demo`
package, which does have a script.  Specify `dependent-scripts = true` to
generate all scripts in required packages:

    >>> write(sample_buildout, 'buildout.cfg',
    ... """
    ... [buildout]
    ... parts = bigdemo
    ...
    ... [bigdemo]
    ... recipe = zc.recipe.egg
    ... find-links = %(server)s
    ... index = %(server)s/index
    ... dependent-scripts = true
    ... """ % dict(server=link_server))
Jim Fulton's avatar
Jim Fulton committed
646
    >>> print_(system(buildout+' -N'), end='')
647 648 649 650 651 652
    Uninstalling demo.
    Installing bigdemo.
    Getting distribution for 'bigdemo'.
    Got bigdemo 0.1.
    Generated script '/sample-buildout/bin/demo'.

653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670
Offline mode
------------

If the buildout offline option is set to "true", then no attempt will
be made to contact an index server:

    >>> write(sample_buildout, 'buildout.cfg',
    ... """
    ... [buildout]
    ... parts = demo
    ... offline = true
    ...
    ... [demo]
    ... recipe = zc.recipe.egg
    ... index = eek!
    ... scripts = demo=foo
    ... """ % dict(server=link_server))

Jim Fulton's avatar
Jim Fulton committed
671
    >>> print_(system(buildout), end='')
672
    Uninstalling bigdemo.
673 674
    Installing demo.
    Generated script '/sample-buildout/bin/foo'.