Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Python: Checkins

r67238 - in sandbox/trunk/tkinter-polo: Makefile setup.py

 

 

Python checkins RSS feed   Index | Next | Previous | View Threaded


python-checkins at python

Nov 16, 2008, 12:48 PM

Post #1 of 1 (112 views)
Permalink
r67238 - in sandbox/trunk/tkinter-polo: Makefile setup.py

Author: guilherme.polo
Date: Sun Nov 16 21:48:41 2008
New Revision: 67238

Log:
Added something to compile _tkinter which will probably work only here (!)

Added:
sandbox/trunk/tkinter-polo/Makefile (contents, props changed)
sandbox/trunk/tkinter-polo/setup.py (contents, props changed)

Added: sandbox/trunk/tkinter-polo/Makefile
==============================================================================
--- (empty file)
+++ sandbox/trunk/tkinter-polo/Makefile Sun Nov 16 21:48:41 2008
@@ -0,0 +1,18 @@
+PYTHON=python
+INSTALL_DIR=tkinter
+TCLTK_VER=8.5
+TCL_BASE_DIR=/usr/share/tcltk
+TK_BASE_DIR=$(TCL_BASE_DIR)
+TCL_CONFIG_DIR=$(TCL_BASE_DIR)/tcl$(TCLTK_VER)
+TK_CONFIG_DIR=$(TK_BASE_DIR)/tk$(TCLTK_VER)
+
+TCL_CONFIG=$(TCL_CONFIG_DIR)/tclConfig.sh
+TK_CONFIG=$(TK_CONFIG_DIR)/tkConfig.sh
+
+build:
+ TCL_CONFIG=$(TCL_CONFIG) TK_CONFIG=$(TK_CONFIG) \
+$(PYTHON) setup.py install_lib --install-dir $(INSTALL_DIR)
+
+clean:
+ rm -rf build
+ rm -rf $(INSTALL_DIR)

Added: sandbox/trunk/tkinter-polo/setup.py
==============================================================================
--- (empty file)
+++ sandbox/trunk/tkinter-polo/setup.py Sun Nov 16 21:48:41 2008
@@ -0,0 +1,57 @@
+"""
+This builds _tkinter (in a hacky way to not require autotools).
+"""
+from distutils.core import setup, Extension
+import os
+import sys
+import subprocess
+
+class MissingTclTkConfig(EnvironmentError):
+ pass
+
+def get_paths(path, prefix):
+ bash = subprocess.Popen(['bash'], stdin=subprocess.PIPE,
+ stdout=subprocess.PIPE)
+
+ bash.stdin.write('source %s\n' % path)
+ for name in ("%s_LIB_SPEC", "%s_INCLUDE_SPEC"):
+ bash.stdin.write('echo `eval echo $%s`\n' % (name % prefix))
+ result = bash.communicate()[0].strip().split('\n')
+
+ if not result[0]:
+ raise MissingTclTkConfig("'%s' did not contain a (correct) '%s'" %
+ (os.path.dirname(path), "%sConfig.sh" % prefix.lower()))
+
+ libs = result[0].split()
+ yield libs[1][2:]
+ yield libs[0][2:]
+ yield result[1][2:]
+
+def get_tcltk_paths():
+ tclconfig = os.environ.get('TCL_CONFIG')
+ tkconfig = os.environ.get('TK_CONFIG')
+
+ if not all((tclconfig, tkconfig)):
+ raise MissingTclTkConfig("TCL_CONFIG and TK_CONFIG env vars must "
+ "exist and should point to tclConfig.sh and tkConfig.sh ")
+
+ paths = zip(get_paths(tclconfig, 'TCL'), get_paths(tkconfig, 'TK'))
+ return dict(zip(('libraries', 'library_dirs', 'include_dirs'), paths))
+
+
+def main(args):
+ if not len(args) or args[0].startswith('-'):
+ tcltk_paths = {}
+ else:
+ tcltk_paths = get_tcltk_paths()
+
+ setup(name="_tkinter",
+ package_dir={'': 'src'}, packages=[''],
+ ext_modules=[
+ Extension("_tkinter", ["src/_tkinter.c"],
+ **tcltk_paths)
+ ]
+ )
+
+if __name__ == "__main__":
+ main(sys.argv[1:])
_______________________________________________
Python-checkins mailing list
Python-checkins[at]python.org
http://mail.python.org/mailman/listinfo/python-checkins

Python checkins RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact lists@gossamer-threads.com
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.