diff options
author | John Ehresman <jpe@wingware.com> | 2010-04-16 16:07:02 -0400 |
---|---|---|
committer | John Ehresman <jpe@wingware.com> | 2010-04-16 16:07:02 -0400 |
commit | d570e692a648daab52297f0f9b331a75d231c89f (patch) | |
tree | 41a861e5a57f4cd20d73f8500180e1dc70c07056 | |
parent | 2e2fd145a4f09b67cd014d2eb9f9db5e1715f7ab (diff) | |
parent | 695ac7bc5c60371a32538d690c7a15509f3c9637 (diff) | |
download | pygobject-d570e692a648daab52297f0f9b331a75d231c89f.tar.gz |
Merge branch master into py3k
Conflicts:
dsextras.py
gio/giomodule.c
gobject/constants.py
gobject/gobjectmodule.c
setup.py
-rw-r--r-- | Makefile.am | 1 | ||||
-rw-r--r-- | README.win32 | 24 | ||||
-rw-r--r-- | dsextras.py | 6 | ||||
-rw-r--r-- | gio/giomodule.c | 3 | ||||
-rw-r--r-- | glib/pygiochannel.c | 1 | ||||
-rw-r--r-- | gobject/Makefile.am | 3 | ||||
-rw-r--r-- | gobject/gobjectmodule.c | 63 | ||||
-rw-r--r-- | pygobject_postinstall.py | 43 | ||||
-rwxr-xr-x | setup.py | 24 | ||||
-rw-r--r-- | tests/runtests.py | 3 |
10 files changed, 111 insertions, 60 deletions
diff --git a/Makefile.am b/Makefile.am index 580b489b..f68b338b 100644 --- a/Makefile.am +++ b/Makefile.am @@ -8,6 +8,7 @@ PLATFORM_VERSION = 2.0 CLEANFILES = EXTRA_DIST = \ MANIFEST.in \ + README.win32 \ pygobject-$(PLATFORM_VERSION).pc.in \ PKG-INFO \ PKG-INFO.in \ diff --git a/README.win32 b/README.win32 new file mode 100644 index 00000000..548a3c8c --- /dev/null +++ b/README.win32 @@ -0,0 +1,24 @@ +Windows Setuptools Build Instructions +====================================== + + 1. Install gtk+ bundle from gtk.org (to C:\GTK for example) + 2. Install Python2.6 + 3. Install MinGW and MSYS + 4. Add C:\GTK\bin to path (from windows) + 5. Add the following to your msys environment variables + (open and append to C:\msys\1.0\etc\profile) or set for the session + + $ export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/c/GTK/lib/pkgconfig:/c/Python26/Lib/pkgconfig + $ export PATH=$PATH:/c/Python26:/c/Python26/bin + + 6. In msys shell, build with + + $ python setup.py build --compiler=mingw32 --enable-threading \ + --yes-i-know-its-not-supported bdist_wininst + +Tested with + * gtk+-bundle_2.20.0-20100406_win32.zip + * MinGW-5.16.exe + * MSYS-1.0.11.exe + * python-2.6.5.exe + diff --git a/dsextras.py b/dsextras.py index d3e0d2e0..f5d4a86d 100644 --- a/dsextras.py +++ b/dsextras.py @@ -315,9 +315,15 @@ class PkgConfigExtension(Extension): self.can_build_ok = 1 return 1 else: +<<<<<<< HEAD:dsextras.py print ("Warning: Too old version of %s" % self.pkc_name) print (" Need %s, but %s is installed" % \ (version, orig_version)) +======= + print "Warning: Too old version of %s" % self.pkc_name + print " Need %s, but %s is installed" % \ + (version, orig_version) +>>>>>>> 695ac7bc5c60371a32538d690c7a15509f3c9637:dsextras.py self.can_build_ok = 0 return 0 diff --git a/gio/giomodule.c b/gio/giomodule.c index 292a0d97..868e6857 100644 --- a/gio/giomodule.c +++ b/gio/giomodule.c @@ -49,6 +49,9 @@ PYGLIB_INIT_FUNCTION(_gio, "gio._gio", pygio_functions) d = PyModule_GetDict(module); + g_type_init(); + pyglib_init(); + pygobject_mod = pygobject_init(2, 15, 2); if (pygobject_mod == NULL) return -1; diff --git a/glib/pygiochannel.c b/glib/pygiochannel.c index 0dea769c..1dd2d0a5 100644 --- a/glib/pygiochannel.c +++ b/glib/pygiochannel.c @@ -10,6 +10,7 @@ #include "pyglib.h" #include "pyglib-private.h" +#include "pygsource.h" typedef struct { PyObject_HEAD diff --git a/gobject/Makefile.am b/gobject/Makefile.am index 1f9d0ac2..aff1609d 100644 --- a/gobject/Makefile.am +++ b/gobject/Makefile.am @@ -10,9 +10,9 @@ pkgpyexecdir = $(pyexecdir)/gtk-2.0 pygobjectdir = $(pkgpyexecdir)/gobject pygobject_PYTHON = \ __init__.py \ + constants.py \ propertyhelper.py pygobject_LTLIBRARIES = _gobject.la -nodist_pygobject_PYTHON = constants.py common_ldflags = -module -avoid-version if PLATFORM_WIN32 @@ -50,7 +50,6 @@ _gobject_la_SOURCES = \ pygtype.c \ pygtype.h \ pygi-external.h -_gobject_la_DEPENDENCIES = constants.py if HAVE_LIBFFI _gobject_la_SOURCES += ffi-marshaller.c ffi-marshaller.h diff --git a/gobject/gobjectmodule.c b/gobject/gobjectmodule.c index 63d2ca5b..30ffd7bc 100644 --- a/gobject/gobjectmodule.c +++ b/gobject/gobjectmodule.c @@ -2535,36 +2535,39 @@ static void pygobject_register_constants(PyObject *m) { /* PyFloat_ return a new ref, and add object takes the ref */ - PyModule_AddObject(m, "G_MINFLOAT", PyFloat_FromDouble(G_MINFLOAT)); - PyModule_AddObject(m, "G_MAXFLOAT", PyFloat_FromDouble(G_MAXFLOAT)); - PyModule_AddObject(m, "G_MINDOUBLE", PyFloat_FromDouble(G_MINDOUBLE)); - PyModule_AddObject(m, "G_MAXDOUBLE", PyFloat_FromDouble(G_MAXDOUBLE)); - - PyModule_AddIntConstant(m, "G_MINSHORT", G_MINSHORT); - PyModule_AddIntConstant(m, "G_MAXSHORT", G_MAXSHORT); - PyModule_AddIntConstant(m, "G_MAXUSHORT", G_MAXUSHORT); - PyModule_AddIntConstant(m, "G_MININT", G_MININT); - PyModule_AddIntConstant(m, "G_MAXINT", G_MAXINT); - PyModule_AddIntConstant(m, "G_MAXUINT", G_MAXUINT); - PyModule_AddIntConstant(m, "G_MINLONG", G_MINLONG); - PyModule_AddIntConstant(m, "G_MAXLONG", G_MAXLONG); - PyModule_AddObject(m, "G_MAXULONG", PyLong_FromUnsignedLong(G_MAXULONG)); - PyModule_AddIntConstant(m, "G_MININT8", G_MININT8); - PyModule_AddIntConstant(m, "G_MAXINT8", G_MAXINT8); - PyModule_AddIntConstant(m, "G_MAXUINT8", G_MAXUINT8); - PyModule_AddIntConstant(m, "G_MININT16", G_MININT16); - PyModule_AddIntConstant(m, "G_MAXINT16", G_MAXINT16); - PyModule_AddIntConstant(m, "G_MAXUINT16", G_MAXUINT16); - PyModule_AddIntConstant(m, "G_MININT32", G_MININT32); - PyModule_AddIntConstant(m, "G_MAXINT32", G_MAXINT32); - PyModule_AddObject(m, "G_MAXUINT32", PyLong_FromUnsignedLong(G_MAXUINT32)); - PyModule_AddObject(m, "G_MININT64",PyLong_FromLong( G_MININT64)); - PyModule_AddObject(m, "G_MAXINT64", PyLong_FromLong(G_MAXINT64)); - PyModule_AddObject(m, "G_MAXUINT64", PyLong_FromUnsignedLong(G_MAXUINT64)); - PyModule_AddObject(m, "G_MAXSIZE", PyLong_FromUnsignedLong(G_MAXSIZE)); - PyModule_AddObject(m, "G_MAXSSIZE", PyLong_FromUnsignedLong(G_MAXSSIZE)); - PyModule_AddObject(m, "G_MINOFFSET", PyLong_FromLong(G_MINOFFSET)); - PyModule_AddObject(m, "G_MAXOFFSET", PyLong_FromLong(G_MAXOFFSET)); + PyModule_AddObject(m, "G_MINFLOAT", PyFloat_FromDouble(G_MINFLOAT)); + PyModule_AddObject(m, "G_MAXFLOAT", PyFloat_FromDouble(G_MAXFLOAT)); + PyModule_AddObject(m, "G_MINDOUBLE", PyFloat_FromDouble(G_MINDOUBLE)); + PyModule_AddObject(m, "G_MAXDOUBLE", PyFloat_FromDouble(G_MAXDOUBLE)); + PyModule_AddIntConstant(m, "G_MINSHORT", G_MINSHORT); + PyModule_AddIntConstant(m, "G_MAXSHORT", G_MAXSHORT); + PyModule_AddIntConstant(m, "G_MAXUSHORT", G_MAXUSHORT); + PyModule_AddIntConstant(m, "G_MININT", G_MININT); + PyModule_AddIntConstant(m, "G_MAXINT", G_MAXINT); + PyModule_AddObject(m, "G_MINLONG", PyLong_FromLong(G_MINLONG)); + PyModule_AddObject(m, "G_MAXLONG", PyLong_FromLong(G_MAXLONG)); + PyModule_AddObject(m, "G_MAXULONG", PyLong_FromUnsignedLong(G_MAXULONG)); + PyModule_AddIntConstant(m, "G_MININT8", G_MININT8); + PyModule_AddIntConstant(m, "G_MAXINT8", G_MAXINT8); + PyModule_AddIntConstant(m, "G_MAXUINT8", G_MAXUINT8); + PyModule_AddIntConstant(m, "G_MININT16", G_MININT16); + PyModule_AddIntConstant(m, "G_MAXINT16", G_MAXINT16); + PyModule_AddIntConstant(m, "G_MAXUINT16", G_MAXUINT16); + PyModule_AddIntConstant(m, "G_MININT32", G_MININT32); + PyModule_AddIntConstant(m, "G_MAXINT32", G_MAXINT32); + PyModule_AddObject(m, "G_MININT64", PyLong_FromLongLong(G_MININT64)); + PyModule_AddObject(m, "G_MAXINT64", PyLong_FromLongLong(G_MAXINT64)); + PyModule_AddObject(m, "G_MAXUINT64", PyLong_FromUnsignedLongLong(G_MAXUINT64)); + PyModule_AddObject(m, "G_MAXSIZE", PyLong_FromUnsignedLongLong(G_MAXSIZE)); + PyModule_AddObject(m, "G_MAXSSIZE", PyLong_FromUnsignedLongLong(G_MAXSSIZE)); + PyModule_AddObject(m, "G_MINOFFSET", PyLong_FromLongLong(G_MINOFFSET)); + PyModule_AddObject(m, "G_MAXOFFSET", PyLong_FromLongLong(G_MAXOFFSET)); + + /* in order for test_properties to pass, G_MAXUINT must be initialized using + PyLong_FromUnsignedLong, despite AFAICT it is unecessary for 32bit int types. + In the interests of consistancy I did the same for MAXUINT32 */ + PyModule_AddObject(m, "G_MAXUINT32", PyLong_FromUnsignedLong(G_MAXUINT32)); + PyModule_AddObject(m, "G_MAXUINT", PyLong_FromUnsignedLong(G_MAXUINT)); PyModule_AddIntConstant(m, "SIGNAL_RUN_FIRST", G_SIGNAL_RUN_FIRST); PyModule_AddIntConstant(m, "SIGNAL_RUN_LAST", G_SIGNAL_RUN_LAST); diff --git a/pygobject_postinstall.py b/pygobject_postinstall.py index 8ddaa604..487828e4 100644 --- a/pygobject_postinstall.py +++ b/pygobject_postinstall.py @@ -5,8 +5,12 @@ Local configuration files were successfully updated.""" import os, re, sys -prefix_pattern=re.compile("^prefix=.*") +pkgconfig_file = os.path.normpath( + os.path.join(sys.prefix, + 'lib/pkgconfig/pygobject-2.0.pc')) +prefix_pattern=re.compile("^prefix=.*") +version_pattern=re.compile("Version: ([0-9]+\.[0-9]+\.[0-9]+)") def replace_prefix(s): if prefix_pattern.match(s): @@ -16,6 +20,16 @@ def replace_prefix(s): return s +def get_doc_url(pkgconfig_file, base_url): + try: + f = open(pkgconfig_file).read() + ver = version_pattern.search(f).groups()[0] + majv,minv,micv = ver.split('.') + doc_url = "%s/%s.%s/" % (base_url,majv,minv) + except: + doc_url = base_url + "/stable/" + return doc_url + # TODO : Check that shortcuts are created system-wide when the user # has admin rights (hint: see pywin32 postinstall) def create_shortcuts(): @@ -25,15 +39,16 @@ def create_shortcuts(): pygtk_shortcuts = os.path.join(progs_folder, 'PyGTK') if not os.path.isdir(pygtk_shortcuts): os.mkdir(pygtk_shortcuts) - + + # link to specific documentation version by parsing the + # pkgconfig file + doc_url = get_doc_url(pkgconfig_file, + "http://library.gnome.org/devel/pygobject") pygobject_doc_link=os.path.join(pygtk_shortcuts, 'PyGObject Documentation.lnk') if os.path.isfile(pygobject_doc_link): os.remove(pygobject_doc_link) - - create_shortcut(os.path.join(sys.prefix,'share','gtk-doc','html', - 'pygobject','index.html'), - 'PyGObject Documentation', pygobject_doc_link) + create_shortcut(doc_url,'PyGObject Documentation',pygobject_doc_link) def remove_shortcuts(): pygtk_shortcuts = os.path.join( @@ -47,17 +62,11 @@ def remove_shortcuts(): if len(sys.argv) == 2: if sys.argv[1] == "-install": - filenames=['lib/pkgconfig/pygobject-2.0.pc', - 'share/pygobject/xsl/fixxref.py'] - for filename in filenames: - pkgconfig_file = os.path.normpath( - os.path.join(sys.prefix,filename)) - - lines=open(pkgconfig_file).readlines() - open(pkgconfig_file, 'w').writelines(map(replace_prefix,lines)) + # fixup the pkgconfig file + lines=open(pkgconfig_file).readlines() + open(pkgconfig_file, 'w').writelines(map(replace_prefix,lines)) # TODO: Add an installer option for shortcut creation - # create_shortcuts() + create_shortcuts() print __doc__ elif sys.argv[1] == "-remove": - pass - # remove_shortcuts() + remove_shortcuts() @@ -33,11 +33,9 @@ else: else: input = input('Not supported, ok [y/N]? ') if not input.startswith('y'): - raise SystemExit + raise SystemExit("Aborted") -if sys.version_info[:3] < (2, 3, 5): - raise SystemExit("Python 2.3.5 or higher is required, %d.%d.%d found" - % sys.version_info[:3]) +MIN_PYTHON_VERSION = (2, 3, 5) MAJOR_VERSION = int(get_m4_define('pygobject_major_version')) MINOR_VERSION = int(get_m4_define('pygobject_minor_version')) @@ -60,6 +58,14 @@ if sys.platform == 'win32': else: GLOBAL_MACROS.append(('VERSION', '"%s"' % VERSION)) +if sys.version_info[:3] < MIN_PYTHON_VERSION: + raise SystemExit("Python %s or higher is required, %s found" % ( + ".".join(map(str,MIN_PYTHON_VERSION)), + ".".join(map(str,sys.version_info[:3])))) + +if not have_pkgconfig(): + raise SystemExit("Error, could not find pkg-config") + DEFS_DIR = os.path.join('share', 'pygobject', PYGOBJECT_SUFFIX, 'defs') INCLUDE_DIR = os.path.join('include', 'pygtk-%s' % PYGOBJECT_SUFFIX) XSL_DIR = os.path.join('share', 'pygobject','xsl') @@ -110,8 +116,6 @@ class PyGObjectInstallData(InstallData): self.install_template('pygobject-2.0.pc.in', os.path.join(self.install_dir, 'lib', 'pkgconfig')) - self.install_template('docs/xsl/fixxref.py.in', - os.path.join(self.install_dir, XSL_DIR)) class PyGObjectBuild(build): enable_threading = 1 @@ -176,9 +180,11 @@ ext_modules = [] py_modules = ['dsextras'] packages = ['codegen'] -if not have_pkgconfig(): - print ("Error, could not find pkg-config") - raise SystemExit + +#Install dsextras and codegen so that the pygtk installer +#can find them +py_modules = ['dsextras'] +packages = ['codegen'] if glib.can_build(): #It would have been nice to create another class, such as PkgConfigCLib to diff --git a/tests/runtests.py b/tests/runtests.py index 76b404cf..5c6c64b4 100644 --- a/tests/runtests.py +++ b/tests/runtests.py @@ -21,8 +21,7 @@ else: common.importModules(buildDir=buildDir, srcDir=srcDir) -SKIP_FILES = ['common', 'runtests', - 'test_enum', 'test_conversion'] +SKIP_FILES = ['common', 'runtests'] dir = os.path.split(os.path.abspath(__file__))[0] os.chdir(dir) |