Commit 4b4ad2ac authored by Christian Zagrodnick's avatar Christian Zagrodnick

- Added `environment` option to custom extension building options.

parent 00cd74f6
...@@ -2475,8 +2475,12 @@ initextdemo(void) ...@@ -2475,8 +2475,12 @@ initextdemo(void)
""" """
extdemo_setup_py = """ extdemo_setup_py = """
import os
from distutils.core import setup, Extension from distutils.core import setup, Extension
if os.environ.get('test-variable'):
print "Have environment test-variable:", os.environ['test-variable']
setup(name = "extdemo", version = "%s", url="http://www.zope.org", setup(name = "extdemo", version = "%s", url="http://www.zope.org",
author="Demo", author_email="demo@demo.com", author="Demo", author_email="demo@demo.com",
ext_modules = [Extension('extdemo', ['extdemo.c'])], ext_modules = [Extension('extdemo', ['extdemo.c'])],
......
...@@ -8,6 +8,11 @@ To do ...@@ -8,6 +8,11 @@ To do
Change History Change History
************** **************
1.1.0 (unreleased)
==================
- Added `environment` option to custom extension building options.
1.0.0 (2007-11-03) 1.0.0 (2007-11-03)
================== ==================
......
...@@ -57,6 +57,11 @@ class Custom(Base): ...@@ -57,6 +57,11 @@ class Custom(Base):
options['index'] = index options['index'] = index
self.index = index self.index = index
environment_section = options.get('envirionment')
if environment_section:
for key, value in buildout[environment_section].items():
os.environ[key] = value
options['_e'] = buildout['buildout']['eggs-directory'] options['_e'] = buildout['buildout']['eggs-directory']
assert options.get('unzip') in ('true', 'false', None) assert options.get('unzip') in ('true', 'false', None)
......
...@@ -83,7 +83,7 @@ python ...@@ -83,7 +83,7 @@ python
section. section.
environment environment
The name of a section wich additional environment variables. The The name of a section with additional environment variables. The
envirionment variables are set before the egg is built. envirionment variables are set before the egg is built.
To illustrate this, we'll define a buildout that builds an egg for a To illustrate this, we'll define a buildout that builds an egg for a
...@@ -129,20 +129,29 @@ the egg: ...@@ -129,20 +129,29 @@ the egg:
... [buildout] ... [buildout]
... parts = extdemo ... parts = extdemo
... ...
... [extdemo-env]
... test-variable = foo
...
... [extdemo] ... [extdemo]
... recipe = zc.recipe.egg:custom ... recipe = zc.recipe.egg:custom
... find-links = %(server)s ... find-links = %(server)s
... index = %(server)s/index ... index = %(server)s/index
... include-dirs = include ... include-dirs = include
... envirionment = extdemo-env
...
... """ % dict(server=link_server)) ... """ % dict(server=link_server))
>>> print system(buildout), >>> print system(buildout),
Installing extdemo. Installing extdemo.
Have environment test-variable: foo
zip_safe flag not set; analyzing archive contents... zip_safe flag not set; analyzing archive contents...
We got the zip_safe warning because the source distribution we used We got the zip_safe warning because the source distribution we used
wasn't setuptools based and thus didn't set the option. wasn't setuptools based and thus didn't set the option.
The setup.py also printed out that we have set the environment `test-variable`
to foo.
The egg is created in the develop-eggs directory *not* the eggs The egg is created in the develop-eggs directory *not* the eggs
directory because it depends on buildout-specific parameters and the directory because it depends on buildout-specific parameters and the
eggs directory can be shared across multiple buildouts. eggs directory can be shared across multiple buildouts.
...@@ -179,11 +188,15 @@ Let's define a script that uses out ext demo: ...@@ -179,11 +188,15 @@ Let's define a script that uses out ext demo:
... develop = demo ... develop = demo
... parts = extdemo demo ... parts = extdemo demo
... ...
... [extdemo-env]
... test-variable = foo
...
... [extdemo] ... [extdemo]
... recipe = zc.recipe.egg:custom ... recipe = zc.recipe.egg:custom
... find-links = %(server)s ... find-links = %(server)s
... index = %(server)s/index ... index = %(server)s/index
... include-dirs = include ... include-dirs = include
... envirionment = extdemo-env
... ...
... [demo] ... [demo]
... recipe = zc.recipe.egg ... recipe = zc.recipe.egg
...@@ -233,11 +246,13 @@ We won't get an update. ...@@ -233,11 +246,13 @@ We won't get an update.
- zc.recipe.egg.egg-link - zc.recipe.egg.egg-link
But if we run the buildout in the default on-line and newest modes, we But if we run the buildout in the default on-line and newest modes, we
will: will. This time we also get the test-variable message again, because the new
version is imported:
>>> print system(buildout), >>> print system(buildout),
Develop: '/sample-buildout/demo' Develop: '/sample-buildout/demo'
Updating extdemo. Updating extdemo.
Have environment test-variable: foo
zip_safe flag not set; analyzing archive contents... zip_safe flag not set; analyzing archive contents...
Updating demo. Updating demo.
Generated script '/sample-buildout/bin/demo'. Generated script '/sample-buildout/bin/demo'.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment