7

I want to use Buildout to install my Distribute-based project and its dependencies to an isolated environment. My project should be installed directly from the source tree (a local Git repository), and is not registered with PyPI. How do I accomplish this?

Edit:

Thanks to M. Pieters I was able to suss out what to do. I'm posting my buildout.cfg for reference:

[buildout]
develop = .
parts = fbt

[fbt]
recipe = z3c.recipe.scripts
eggs = BuildTools

Although I didn't need it right now, knowledge of mr.developer could definitely come in handy in the future.

aknuds1
  • 65,625
  • 67
  • 195
  • 317

2 Answers2

12

You have 3 options, depending on where you want your buildout configuration to live and what options you have to check out your git repository.

Note that as far as Python is concerned, the resulting egg is exactly the same. The only difference between a development egg and a "normal" egg is that a development egg overrides any version requirements set elsewhere for that egg; it will be used regardless of what other versions of the egg are found elsewhere.

Inside the development repository

Just use the develop option. This creates a development egg, which is just the same as a normal egg but without a version check, nothing more, nothing less.

Your buildout simply needs to list the current directory (where setup.py lives) as the development egg:

[buildout]
develop = .

In a different location

You'll need to be able to reach the git repository for this to create a new checkout. Use mr.developer to pull in your git repository and automatically mark it as a development egg:

[buildout]
extensions = mr.developer
auto-checkout = package.name

[sources]
package.name = git url/to/package.name.git

With this setup, mr.developer will automatically check out the git repository to the src/ subdirectory and add that to the buildout develop option.

Using a tarball download

Places like github.com also offer an option to download a tarball with the current contents of the repository. You could use that to load that tarball as an egg source with the find-links option:

[buildout]
find-links = http://github.com/yourname/package.name/tarball/version#egg=package.name-versionnumber
eggs = package.name

Buildout will then use that specific find-links entry to find the egg, provided it cannot find the egg elsewhere.

Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
  • I think the first alternative might actually suit my needs well enough, as I could just check out the project right inside the installation directory. I'm going to give it a go. I had some trouble with the develop option earlier though, as Buildout still complained about not finding my distribution at PyPI. – aknuds1 Apr 18 '11 at 20:10
  • @aknuds1: There is a [talk on using buildout for package development](http://rhodesmill.org/brandon/buildout/) that may contain additional hints. – Martijn Pieters Apr 18 '11 at 20:20
  • Your first buildout.cfg is not sufficient. Buildout requires a [parts] section in buildout.cfg: 'Error: Missing option: buildout:parts'. – aknuds1 Apr 19 '11 at 14:07
  • @aknuds1: all the examples are only showing the options pertaining to the specific technique and are not complete buildout.cfg files. See the talk I linked to for further details on the use of buildout. – Martijn Pieters Apr 19 '11 at 14:24
  • Nota Bene: it is `extensions` and not `extension` in the `[buildout]` section !!! (cf https://github.com/fschulze/mr.developer#usage) – zmo Jun 05 '12 at 14:16
  • @Martijn Pieters: I read your page, I miss the information you gave as an answer in stackoverflow about the option to pin it to a specific version (so no need for the newest = false) see http://stackoverflow.com/questions/6402774/how-to-pin-version-of-recipe-egg-for-a-particular-part – michel.iamit Aug 23 '13 at 09:58
  • Develop eggs are used regardless of version pins. – Martijn Pieters Aug 23 '13 at 10:10
3

You easily use Buildout with checkouts from repository by either using the develop directive of zc.buildout or using the mr.developer buildout extension where you can define the packages to be checkout directly from a given repository URL (supports git, svn and others version control systems).

See

http://pypi.python.org/pypi/mr.developer

  • The develop directive would install a development egg of my distribution though, am I right? I want to install a regular, not development, egg. It looks like mr.developer might be what I need; I looked at it before, but I figured it had to be overkill for my simple case. Maybe it isn't after all.. I'll give it a go and see if it does what I need. – aknuds1 Apr 18 '11 at 15:12