[Zope-dev] Zope2 trunk: getting 'mkzopeinstance' / 'mkzeoinstance' working

Tres Seaver tseaver at palladion.com
Tue Feb 24 19:59:58 EST 2009


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hanno Schlichting wrote:
> Tres Seaver wrote:
>> Hanno Schlichting wrote:
>>> I looked at this, but guessing or reliably getting to the zopepy script
>>> wasn't possible. So I added an explicit option to the script instead and
>>> documented it. You can now use:
>>> bin/mkzopeinstance --python=bin/zopepy
>>> on the SVN trunk. You can omit this option and it will use
>>> sys.executable as before.
>> Maybe we can detect buildout vs. tarball (e.g., the presence of
>> 'buildout.cfg' vs. 'makefile'?)
> 
> What you have available inside the mkzopeinstance script is:
> 
> sys.executable which is just your regular Python interpreter and then
> sys.argv which is ./bin/mkzopeinstance.
> 
> As the 'zopepy' script can be called anything, I don't see how you can
> be smarter here.

I'm not worried about generalities:  I think that 'mkzopeinstance'
should work from inside a SVN checkout of the Zope2 trunk, where the
script is going to have a known hame.  Something like this::

- --- src/Zope2/utilities/mkzopeinstance.py	(revision 97232)
+++ src/Zope2/utilities/mkzopeinstance.py	(working copy)
@@ -50,6 +50,9 @@
     skelsrc = None
     python = None

+    if check_buildout():
+        python = os.path.abspath('bin/zopepy')
+
     for opt, arg in opts:
         if opt in ("-d", "--dir"):
             skeltarget = os.path.abspath(os.path.expanduser(arg))
@@ -186,5 +189,14 @@
     fp.close()
     os.chmod(fn, 0644)

+def check_buildout():
+    """ Are we running from within a buildout which supplies 'zopepy'?
+    """
+    if os.path.exists('buildout.cfg'):
+        from ConfigParser import RawConfigParser
+        parser = RawConfigParser()
+        parser.read('buildout.cfg')
+        return 'zopepy' in parser.sections()
+
 if __name__ == "__main__":
     main()




Tres.
- --
===================================================================
Tres Seaver          +1 540-429-0999          tseaver at palladion.com
Palladion Software   "Excellence by Design"    http://palladion.com
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD4DBQFJpJgO+gerLs4ltQ4RAqR1AJ9OBXJ7NNDkG5wc0aKAapvDoZbeIQCYsJfH
6jyjW7e7X5XXBE2G6xJX8w==
=ha/A
-----END PGP SIGNATURE-----



More information about the Zope-Dev mailing list