hashdist/python-hpcmp2 — pull request #45 by dagss (2013-04-22 13:24:37+00:00)
Title: Update to latest Hashdist; simplify distutils recipe

@certik, notice that the distutils recipe is now a bit more streamlined, due to the changes made to Hashdist today.

PS: I didn't have time to run through the full build before having to leave, can you do it, or just be mindful of this commit whenever you debug other stuff? I had to make changes to every recipe (because the old "env" dict is replaced by environment-controlling commands "set", "append_path", etc.), so I may have introduced regressions.

**PPS:** It used to be the case that PATH was automatically set. This is no longer the case. However, it seemed like you didn't make use of it anyway? To re-introduce it, simply add this to `build_spec` of artifacts that want to export their bin-directories during builds (doesn't affect profiles):

```
"on_import": {
{"prepend_path": "PATH", "value": "$ARTIFACT/bin"}
}
```

**Explanation**:

First, the Python recipe now has added a small script after the build which adds

```
"on_import": [
{"set": "PYTHON_SITE_PACKAGES_REL", "value": "lib/python2.7/site-packages"}
]
```

to Python's `artifact.json`. The result is that whenever Python is in the import list, this variable will be defined, and so in the distutils recipe we do:

**1) During builds, add oneself to PYTHONPATH**

(This hack is required by distribute/setuptools to allow using `--prefix`).

```
{"prepend_path": "PYTHONPATH", "value": "${ARTIFACT}/${PYTHON_SITE_PACKAGES_REL}"},
{"cmd": ["mkdir", "-p", "${ARTIFACT}/${PYTHON_SITE_PACKAGES_REL}"]},
```

**2) Every Python package gets an "on_import" section**

With the updated Hashdist, we can simply add this in artifact.json of every Python package:

```
"on_import": {
{"prepend_path": "PYTHONPATH", "value": "${ARTIFACT}/${PYTHON_SITE_PACKAGES_REL}"}
}
```

and PYTHONPATH will be dealt with automatically for builds importing this Python package.