From 6e38a93a9e35739612745b5f66245120bae708f3 Mon Sep 17 00:00:00 2001
From: Leonardo Rochael Almeida <leonardo@nexedi.com>
Date: Sat, 27 Mar 2010 01:03:32 +0000
Subject: [PATCH] streamlined python recipes, dispensing the use of the
 localbin egg

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@34171 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 buildout/local-eggs/localbin/invokepython.py |  4 --
 buildout/local-eggs/localbin/setup.py        | 27 ---------
 buildout/profiles/official.cfg               |  8 ++-
 buildout/profiles/software-definition.cfg    |  1 -
 buildout/software-profiles/erp5.cfg          | 10 +++-
 buildout/software-profiles/python-2.4.cfg    | 59 ++++----------------
 buildout/software-profiles/python-2.6.cfg    | 16 ++++--
 buildout/software-profiles/python-common.cfg | 43 ++++++++++++++
 buildout/testpython.cfg                      | 19 +++++++
 9 files changed, 96 insertions(+), 91 deletions(-)
 delete mode 100644 buildout/local-eggs/localbin/invokepython.py
 delete mode 100644 buildout/local-eggs/localbin/setup.py
 create mode 100644 buildout/software-profiles/python-common.cfg
 create mode 100644 buildout/testpython.cfg

diff --git a/buildout/local-eggs/localbin/invokepython.py b/buildout/local-eggs/localbin/invokepython.py
deleted file mode 100644
index 8e7090b837..0000000000
--- a/buildout/local-eggs/localbin/invokepython.py
+++ /dev/null
@@ -1,4 +0,0 @@
-import sys, os
-def invokepython():
-  os.environ['PYTHONPATH'] = ':'.join(sys.path)
-  os.execl(sys.executable, *sys.argv)
diff --git a/buildout/local-eggs/localbin/setup.py b/buildout/local-eggs/localbin/setup.py
deleted file mode 100644
index 6e9713ff01..0000000000
--- a/buildout/local-eggs/localbin/setup.py
+++ /dev/null
@@ -1,27 +0,0 @@
-from setuptools import setup, find_packages
-
-name = "invokepython"
-version = '0.1'
-
-setup(
-    name = name,
-    version = version,
-    author = "Lukasz Nowak",
-    author_email = "luke@nexedi.com",
-    description = "ZC Buildout recipe to invoke full python interpreter",
-    license = "ZPL 2.1",
-    keywords = "python interpreter",
-    packages = find_packages(),
-    scripts = [name+".py",],
-    include_package_data = True,
-    classifiers=[
-      "License :: OSI Approved :: Zope Public License",
-      "Framework :: Buildout",
-      "Operating System :: POSIX :: Linux",
-      ],
-    zip_safe=False,
-    entry_points = """
-    [console_scripts]
-    invokepython = invokepython:invokepython
-    """,
-    )
diff --git a/buildout/profiles/official.cfg b/buildout/profiles/official.cfg
index ebb720c3fd..7229b306e5 100644
--- a/buildout/profiles/official.cfg
+++ b/buildout/profiles/official.cfg
@@ -1,4 +1,6 @@
 [buildout]
+software_home = ${:directory}
+
 extends =
   ../profiles/versions.cfg
   ../profiles/software-definition.cfg
@@ -13,12 +15,13 @@ extends =
   ../software-profiles/ocropus.cfg
   ../software-profiles/oood.cfg
   ../software-profiles/openoffice-bin.cfg
+  ../software-profiles/python-common.cfg
   ../software-profiles/python-2.4.cfg
   ../software-profiles/varnish.cfg
   ../software-profiles/zope-2.8.cfg
   ../profiles/common.cfg
 
-python = software_definition
+python = python2.4
 versions = versions
 
 parts =
@@ -39,7 +42,6 @@ parts =
   products-other
   openoffice-bin
   oood
-  pythonbin
 
 [show-requirements]
 recipe = plone.recipe.command
@@ -49,4 +51,4 @@ command =
 update-command = ${:command}
 
 [software_definition]
-software_home = ${buildout:directory}
+software_home = ${buildout:software_home}
diff --git a/buildout/profiles/software-definition.cfg b/buildout/profiles/software-definition.cfg
index 65766b6882..089ae359b9 100644
--- a/buildout/profiles/software-definition.cfg
+++ b/buildout/profiles/software-definition.cfg
@@ -9,7 +9,6 @@ mysql_software = ${:software_home}/parts/mysql-tritonn-5.0
 oood_software = ${:software_home}/parts/oood
 openoffice_software = ${:software_home}/parts/openoffice-bin
 zope_software = ${:software_home}/parts/zope-2.8
-executable = ${:software_home}/parts/python2.4/bin/python2.4
 products-zope = ${:zope_software}/lib/python/Products
 products-erp5 = ${:software_home}/parts/products-erp5
 products-erp5-development = ${:software_home}/parts/products-erp5-development
diff --git a/buildout/software-profiles/erp5.cfg b/buildout/software-profiles/erp5.cfg
index 41b0f256d4..7dc2515677 100644
--- a/buildout/software-profiles/erp5.cfg
+++ b/buildout/software-profiles/erp5.cfg
@@ -18,8 +18,8 @@ version-suffix-packages =
 
 [itools]
 # use a custom build for itools, to add lib64 to the include path
-depends = ${python:location}
 recipe = zc.recipe.egg:custom
+python = python2.4
 egg = itools
 include-dirs = /usr/include/glib-2.0:/usr/lib/glib-2.0/include/:/usr/lib64/glib-2.0/include/
 
@@ -78,6 +78,14 @@ eggs =
   threadframe
   timerserver
   uuid
+python = python2.4
+dependent-scripts = true
+interpreter = python${python2.4:version}
+extra-paths =
+  ${zope-2.8:location}/lib/python
+scripts =
+  python=${:interpreter}
+  ipython=ipython${python2.4:version}
 
 [requirements]
 development =
diff --git a/buildout/software-profiles/python-2.4.cfg b/buildout/software-profiles/python-2.4.cfg
index c1b78de7a0..fc7ce07911 100644
--- a/buildout/software-profiles/python-2.4.cfg
+++ b/buildout/software-profiles/python-2.4.cfg
@@ -1,12 +1,8 @@
 [buildout]
-# http://bluedynamics.com/articles/jens/build-python-in-buildout
-# based on https://svn.plone.org/svn/collective/buildout/bda-naked-python/buildout2.4.cfg
-develop += local-eggs/localbin
+# extend your buildout with python-common.cfg before extending with this file
 
-python_version = 2.4
 parts =
-    python
-    pythonbin
+    python2.4
 
 [python2.4-dbm-patch]
 recipe = hexagonit.recipe.download
@@ -14,47 +10,12 @@ url = http://bugs.gentoo.org/attachment.cgi?id=109117
 download-only = true
 filename = attachment.cgi
 
-[python]
-recipe = hexagonit.recipe.cmmi
+[python2.4]
+<= python-common
+python_version_major = 2.4
 python_version_minor = 6
-python_version_full = ${buildout:python_version}.${:python_version_minor}
-url =
-  http://python.org/ftp/python/${:python_version_full}/Python-${:python_version_full}.tgz
-prefix = ${buildout:parts-directory}/python${buildout:python_version}
-configure-options =
-  --enable-unicode=ucs4
-  --with-threads
-  --with-readline
-  --with-dbm
-  --with-zlib
-  --with-ssl
-  --with-bz2
-
-patches = ${python2.4-dbm-patch:location}/${python2.4-dbm-patch:filename}
-
-[pythonbin]
-# XXX/Note: This is hackish way to have fully featured python interpreter
-recipe = zc.recipe.egg:scripts
-eggs = ${eggs:eggs}
-  invokepython
-extra-paths =
-  ${zope-2.8:location}/lib/python
-dependent-scripts = true
-scripts =
-  invokepython=python${buildout:python_version}
-  ipython=ipython${buildout:python_version}
-
-[requirements]
-binary =
-  g++
-  gcc
-  make
-
-development =
-  /usr/include/bzlib.h
-  /usr/include/curses.h
-  /usr/include/gdbm.h
-  /usr/include/jpeglib.h
-  /usr/include/openssl/ssl.h
-  /usr/include/termcap.h
-  /usr/include/zlib.h
+# this next setting should always match the name of this part
+name = python2.4
+# XXX maybe add the tarfile patch as well?
+patches =
+	${python2.4-dbm-patch:location}/${python2.4-dbm-patch:filename}
diff --git a/buildout/software-profiles/python-2.6.cfg b/buildout/software-profiles/python-2.6.cfg
index 44cf68aa19..a0de06885c 100644
--- a/buildout/software-profiles/python-2.6.cfg
+++ b/buildout/software-profiles/python-2.6.cfg
@@ -1,8 +1,12 @@
 [buildout]
-# http://bluedynamics.com/articles/jens/build-python-in-buildout
-extends = https://svn.plone.org/svn/collective/buildout/bda-naked-python/buildout2.6.cfg
-python_version = 2.6
+# extend your buildout with python-common.cfg before extending with this file
 
-[pythonbin]
-recipe = plone.recipe.command
-command = ln -s ${python:executable} ${buildout:bin-directory}/python${buildout:python_version}
+parts =
+    python2.6
+
+[python2.6]
+<= python-common
+python_version_major = 2.6
+python_version_minor = 5
+# this next setting should always match the name of this part
+name = python2.6
diff --git a/buildout/software-profiles/python-common.cfg b/buildout/software-profiles/python-common.cfg
new file mode 100644
index 0000000000..648827a14d
--- /dev/null
+++ b/buildout/software-profiles/python-common.cfg
@@ -0,0 +1,43 @@
+# part template for building python distributions
+# http://bluedynamics.com/articles/jens/build-python-in-buildout
+# based on https://svn.plone.org/svn/collective/buildout/bda-naked-python/buildout2.4.cfg
+
+[python-common]
+# override these three variables in parts that extend this one:
+#python_version_major = 2.4
+#python_version_minor = 6
+#name = python2.4 # unfortunately there is no way to get the part name here
+
+# This is actually the default setting for prefix, but we can't use it in
+# other settings in this part if we don't set it explicitly here.
+prefix = ${buildout:parts-directory}/${:name}
+version = ${:python_version_major}
+executable = ${:prefix}/bin/python${:version}
+
+recipe = hexagonit.recipe.cmmi
+python_version_full = ${:python_version_major}.${:python_version_minor}
+url =
+  http://python.org/ftp/python/${:python_version_full}/Python-${:python_version_full}.tgz
+configure-options =
+  --enable-unicode=ucs4
+  --with-threads
+  --with-readline
+  --with-dbm
+  --with-zlib
+  --with-ssl
+  --with-bz2
+
+[requirements]
+binary =
+  g++
+  gcc
+  make
+
+development =
+  /usr/include/bzlib.h
+  /usr/include/curses.h
+  /usr/include/gdbm.h
+  /usr/include/jpeglib.h
+  /usr/include/openssl/ssl.h
+  /usr/include/termcap.h
+  /usr/include/zlib.h
diff --git a/buildout/testpython.cfg b/buildout/testpython.cfg
new file mode 100644
index 0000000000..64ffabd072
--- /dev/null
+++ b/buildout/testpython.cfg
@@ -0,0 +1,19 @@
+[buildout]
+software_home = ${:directory}
+versions = versions
+extends =
+  profiles/versions.cfg
+  profiles/software-definition.cfg
+  software-profiles/zope-2.8.cfg
+  software-profiles/python-common.cfg
+  software-profiles/python-2.4.cfg
+  software-profiles/python-2.6.cfg
+  software-profiles/mysql-tritonn-5.0.cfg
+  software-profiles/erp5.cfg
+  profiles/common.cfg
+
+python = python2.4
+parts = eggs
+
+[software_definition]
+software_home = ${buildout:software_home}
\ No newline at end of file
-- 
2.30.9