From d11ef47072acae5801ce25c68d1289e425eb9fc2 Mon Sep 17 00:00:00 2001 From: John Stowers Date: Thu, 15 Apr 2010 22:48:28 +1200 Subject: Include pygsource.h --- glib/pygiochannel.c | 1 + 1 file changed, 1 insertion(+) diff --git a/glib/pygiochannel.c b/glib/pygiochannel.c index 5b570114..4c935e8e 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 -- cgit v1.2.1 From 6d7a3ab9ce352692d0faccbf106974d264fa953d Mon Sep 17 00:00:00 2001 From: John Stowers Date: Thu, 15 Apr 2010 22:49:17 +1200 Subject: Bug 589671 - Fix setup.py for windows build * Building pyglib as a static private library * Update to include new defs * Modernise setup.py and add more util functions to dsextras --- dsextras.py | 32 ++++++++++++++++--- setup.py | 102 +++++++++++++++++++++++++++++++++++++++++++++++++++--------- 2 files changed, 116 insertions(+), 18 deletions(-) diff --git a/dsextras.py b/dsextras.py index 9fc79c1b..10973e2c 100644 --- a/dsextras.py +++ b/dsextras.py @@ -95,6 +95,21 @@ def pkgc_version_check(name, req_version): return 0 +def pkgc_get_libraries(name): + """returns a list of libraries as returned by pkg-config --libs-only-l""" + output = getoutput('pkg-config --libs-only-l %s' % name) + return output.replace('-l', '').split() + +def pkgc_get_library_dirs(name): + """returns a list of library dirs as returned by pkg-config --libs-only-L""" + output = getoutput('pkg-config --libs-only-L %s' % name) + return output.replace('-L', '').split() + +def pkgc_get_include_dirs(name): + """returns a list of include dirs as returned by pkg-config --cflags-only-I""" + output = getoutput('pkg-config --cflags-only-I %s' % name) + return output.replace('-I', '').split() + class BuildExt(build_ext): def init_extra_compile_args(self): self.extra_compile_args = [] @@ -220,10 +235,19 @@ class PkgConfigExtension(Extension): can_build_ok = None def __init__(self, **kwargs): name = kwargs['pkc_name'] - kwargs['include_dirs'] = self.get_include_dirs(name) + GLOBAL_INC + if 'include_dirs' in kwargs: + kwargs['include_dirs'] += self.get_include_dirs(name) + GLOBAL_INC + else: + kwargs['include_dirs'] = self.get_include_dirs(name) + GLOBAL_INC kwargs['define_macros'] = GLOBAL_MACROS - kwargs['libraries'] = self.get_libraries(name) - kwargs['library_dirs'] = self.get_library_dirs(name) + if 'libraries' in kwargs: + kwargs['libraries'] += self.get_libraries(name) + else: + kwargs['libraries'] = self.get_libraries(name) + if 'library_dirs' in kwargs: + kwargs['library_dirs'] += self.get_library_dirs(name) + else: + kwargs['library_dirs'] = self.get_library_dirs(name) if 'pygobject_pkc' in kwargs: self.pygobject_pkc = kwargs.pop('pygobject_pkc') if self.pygobject_pkc: @@ -290,7 +314,7 @@ class PkgConfigExtension(Extension): else: print "Warning: Too old version of %s" % self.pkc_name print " Need %s, but %s is installed" % \ - (package, orig_version) + (version, orig_version) self.can_build_ok = 0 return 0 diff --git a/setup.py b/setup.py index b367c6af..fcd7e639 100755 --- a/setup.py +++ b/setup.py @@ -5,6 +5,8 @@ """Python Bindings for GObject.""" from distutils.command.build import build +from distutils.command.build_clib import build_clib +from distutils.sysconfig import get_python_inc from distutils.core import setup import glob import os @@ -12,7 +14,8 @@ import sys from dsextras import get_m4_define, getoutput, have_pkgconfig, \ GLOBAL_INC, GLOBAL_MACROS, InstallLib, InstallData, BuildExt, \ - PkgConfigExtension + PkgConfigExtension, TemplateExtension, \ + pkgc_get_libraries, pkgc_get_library_dirs, pkgc_get_include_dirs if '--yes-i-know-its-not-supported' in sys.argv: sys.argv.remove('--yes-i-know-its-not-supported') @@ -39,7 +42,7 @@ MICRO_VERSION = int(get_m4_define('pygobject_micro_version')) VERSION = "%d.%d.%d" % (MAJOR_VERSION, MINOR_VERSION, MICRO_VERSION) -GOBJECT_REQUIRED = get_m4_define('glib_required_version') +GLIB_REQUIRED = get_m4_define('glib_required_version') PYGOBJECT_SUFFIX = '2.0' PYGOBJECT_SUFFIX_LONG = 'gtk-' + PYGOBJECT_SUFFIX @@ -49,11 +52,12 @@ GLOBAL_MACROS += [('PYGOBJECT_MAJOR_VERSION', MAJOR_VERSION), ('PYGOBJECT_MINOR_VERSION', MINOR_VERSION), ('PYGOBJECT_MICRO_VERSION', MICRO_VERSION)] -if sys.platform == 'win33': +if sys.platform == 'win32': GLOBAL_MACROS.append(('VERSION', '"""%s"""' % VERSION)) else: GLOBAL_MACROS.append(('VERSION', '"%s"' % VERSION)) +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') HTML_DIR = os.path.join('share', 'gtk-doc', 'html', 'pygobject') @@ -91,6 +95,7 @@ class PyGObjectInstallData(InstallData): def run(self): self.add_template_option('VERSION', VERSION) self.add_template_option('FFI_LIBS', '') + self.add_template_option('LIBFFI_PC', '') self.prepare() # Install templates @@ -110,47 +115,113 @@ class PyGObjectBuild(build): PyGObjectBuild.user_options.append(('enable-threading', None, 'enable threading support')) +# glib +glib = PkgConfigExtension(name='glib._glib', + pkc_name='glib-2.0', + pkc_version=GLIB_REQUIRED, + pygobject_pkc=None, + include_dirs=['glib'], + libraries=['pyglib'], + sources=['glib/glibmodule.c', + 'glib/pygiochannel.c', + 'glib/pygmaincontext.c', + 'glib/pygmainloop.c', + 'glib/pygoptioncontext.c', + 'glib/pygoptiongroup.c', + 'glib/pygsource.c', + 'glib/pygspawn.c', + ]) + # GObject -gobject = PkgConfigExtension(name='gobject._gobject', pkc_name='gobject-2.0', - pkc_version=GOBJECT_REQUIRED, +gobject = PkgConfigExtension(name='gobject._gobject', + pkc_name='gobject-2.0', + pkc_version=GLIB_REQUIRED, pygobject_pkc=None, + include_dirs=['glib'], + libraries=['pyglib'], sources=['gobject/gobjectmodule.c', 'gobject/pygboxed.c', 'gobject/pygenum.c', 'gobject/pygflags.c', + 'gobject/pyginterface.c', 'gobject/pygobject.c', - 'gobject/pygmaincontext.c', - 'gobject/pygmainloop.c', - 'gobject/pygoptioncontext.c', - 'gobject/pygoptiongroup.c', 'gobject/pygparamspec.c', 'gobject/pygpointer.c', 'gobject/pygtype.c', - 'gobject/pygsource.c', - 'gobject/pygiochannel.c', ]) +# gio +gio = TemplateExtension(name='gio', + pkc_name='gio-2.0', + pkc_version=GLIB_REQUIRED, + output='gio._gio', + defs=('gio/gio.defs', ['gio/gio-types.defs']), + include_dirs=['glib'], + libraries=['pyglib'], + sources=['gio/giomodule.c', + 'gio/gio.c', + 'gio/pygio-utils.c'], + register=[('gio/gio.defs', ['gio/gio-types.defs'])], + override='gio/gio.override') + +clibs = [] data_files = [] ext_modules = [] -py_modules = [] -py_modules.append('dsextras') + +#Install dsextras and codegen so that the pygtk installer +#can find them +py_modules = ['dsextras'] +packages = ['codegen'] if not have_pkgconfig(): print "Error, could not find pkg-config" raise SystemExit +if glib.can_build(): + #It would have been nice to create another class, such as PkgConfigCLib to + #encapsulate this dictionary, but it is impossible. build_clib.py does + #a dumb check to see if its only arguments are a 2-tuple containing a + #string and a Dictionary type - which makes it impossible to hide behind a + #subclass + # + #So we are stuck with this ugly thing + clibs.append(( + 'pyglib',{ + 'sources':['glib/pyglib.c'], + 'macros':GLOBAL_MACROS, + 'include_dirs': + ['glib', get_python_inc()]+pkgc_get_include_dirs('glib-2.0')})) + #this library is not installed, so probbably should not include its header + #data_files.append((INCLUDE_DIR, ('glib/pyglib.h',))) + + ext_modules.append(glib) + py_modules += ['glib.__init__', 'glib.option'] +else: + print + print 'ERROR: Nothing to do, glib could not be found and is essential.' + raise SystemExit + if gobject.can_build(): ext_modules.append(gobject) - py_modules.append('gobject.option') data_files.append((INCLUDE_DIR, ('gobject/pygobject.h',))) data_files.append((HTML_DIR, glob.glob('docs/html/*.html'))) data_files.append((HTML_DIR, ['docs/style.css'])) data_files.append((XSL_DIR, glob.glob('docs/xsl/*.xsl'))) + py_modules += ['gobject.__init__', 'gobject.propertyhelper'] else: print print 'ERROR: Nothing to do, gobject could not be found and is essential.' raise SystemExit +if gio.can_build(): + ext_modules.append(gio) + py_modules += ['gio.__init__'] + data_files.append((DEFS_DIR,('gio/gio-types.defs',))) +else: + print + print 'ERROR: Nothing to do, gio could not be found and is essential.' + raise SystemExit + # Threading support if '--disable-threading' in sys.argv: sys.argv.remove('--disable-threading') @@ -199,11 +270,14 @@ setup(name="pygobject", description = doclines[0], long_description = "\n".join(doclines[2:]), py_modules=py_modules, + packages=packages, ext_modules=ext_modules, + libraries=clibs, data_files=data_files, scripts = ["pygobject_postinstall.py"], options=options, cmdclass={'install_lib': PyGObjectInstallLib, 'install_data': PyGObjectInstallData, + 'build_clib' : build_clib, 'build_ext': BuildExt, 'build': PyGObjectBuild}) -- cgit v1.2.1 From 5d159a13d89587cba189a0ca3203ac003e2f1f2b Mon Sep 17 00:00:00 2001 From: John Stowers Date: Thu, 15 Apr 2010 22:52:48 +1200 Subject: Bug 589671 - Dont use generate-constants This breaks the build using distutils, and it is largely unneeded. Just add the G_XXX constants to the module directly --- gobject/Makefile.am | 16 +-------- gobject/constants.py | 83 ++++++++++++++++++++++++++++++++++++++++++++ gobject/constants.py.in | 50 -------------------------- gobject/generate-constants.c | 44 ----------------------- gobject/gobjectmodule.c | 35 +++++++++++++++++++ setup.py | 2 +- tests/runtests.py | 3 +- 7 files changed, 121 insertions(+), 112 deletions(-) create mode 100644 gobject/constants.py delete mode 100644 gobject/constants.py.in delete mode 100644 gobject/generate-constants.c diff --git a/gobject/Makefile.am b/gobject/Makefile.am index e5d7f7bc..aff1609d 100644 --- a/gobject/Makefile.am +++ b/gobject/Makefile.am @@ -10,28 +10,15 @@ 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 common_ldflags += -no-undefined endif -constants.py: generate-constants$(EXEEXT) constants.py.in - rm -f constants.py - cp $(srcdir)/constants.py.in constants.py - chmod 644 constants.py - $(top_builddir)/gobject/generate-constants$(EXEEXT) >> constants.py - chmod 444 constants.py - -generate_constants_CFLAGS = $(GLIB_CFLAGS) $(PYTHON_INCLUDES) - -noinst_PROGRAMS = generate-constants -CLEANFILES = constants.py -EXTRA_DIST = constants.py.in - _gobject_la_CFLAGS = \ -I$(top_srcdir)/glib \ $(PYTHON_INCLUDES) \ @@ -63,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/constants.py b/gobject/constants.py new file mode 100644 index 00000000..a6d3ce92 --- /dev/null +++ b/gobject/constants.py @@ -0,0 +1,83 @@ +# -*- Mode: Python; py-indent-offset: 4 -*- +# pygobject - Python bindings for the GObject library +# Copyright (C) 2006-2007 Johan Dahlin +# +# gobject/constants.py: GObject type constants +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 +# USA + +import sys + +import gobject._gobject +_gobject = sys.modules['gobject._gobject'] + +# TYPE_INVALID defined in gobjectmodule.c +TYPE_NONE = _gobject.type_from_name('void') +TYPE_INTERFACE = _gobject.type_from_name('GInterface') +TYPE_CHAR = _gobject.type_from_name('gchar') +TYPE_UCHAR = _gobject.type_from_name('guchar') +TYPE_BOOLEAN = _gobject.type_from_name('gboolean') +TYPE_INT = _gobject.type_from_name('gint') +TYPE_UINT = _gobject.type_from_name('guint') +TYPE_LONG = _gobject.type_from_name('glong') +TYPE_ULONG = _gobject.type_from_name('gulong') +TYPE_INT64 = _gobject.type_from_name('gint64') +TYPE_UINT64 = _gobject.type_from_name('guint64') +TYPE_ENUM = _gobject.type_from_name('GEnum') +TYPE_FLAGS = _gobject.type_from_name('GFlags') +TYPE_FLOAT = _gobject.type_from_name('gfloat') +TYPE_DOUBLE = _gobject.type_from_name('gdouble') +TYPE_STRING = _gobject.type_from_name('gchararray') +TYPE_POINTER = _gobject.type_from_name('gpointer') +TYPE_BOXED = _gobject.type_from_name('GBoxed') +TYPE_PARAM = _gobject.type_from_name('GParam') +TYPE_OBJECT = _gobject.type_from_name('GObject') +TYPE_PYOBJECT = _gobject.type_from_name('PyObject') +TYPE_UNICHAR = TYPE_UINT + +# do a little dance to maintain API compatibility +# as these were origianally defined here, and are +# now defined in gobjectmodule.c +G_MINFLOAT = _gobject.G_MINFLOAT +G_MAXFLOAT = _gobject.G_MAXFLOAT +G_MINDOUBLE = _gobject.G_MINDOUBLE +G_MAXDOUBLE = _gobject.G_MAXDOUBLE +G_MINSHORT = _gobject.G_MINSHORT +G_MAXSHORT = _gobject.G_MAXSHORT +G_MAXUSHORT = _gobject.G_MAXUSHORT +G_MININT = _gobject.G_MININT +G_MAXINT = _gobject.G_MAXINT +G_MAXUINT = _gobject.G_MAXUINT +G_MINLONG = _gobject.G_MINLONG +G_MAXLONG = _gobject.G_MAXLONG +G_MAXULONG = _gobject.G_MAXULONG +G_MININT8 = _gobject.G_MININT8 +G_MAXINT8 = _gobject.G_MAXINT8 +G_MAXUINT8 = _gobject.G_MAXUINT8 +G_MININT16 = _gobject.G_MININT16 +G_MAXINT16 = _gobject.G_MAXINT16 +G_MAXUINT16 = _gobject.G_MAXUINT16 +G_MININT32 = _gobject.G_MININT32 +G_MAXINT32 = _gobject.G_MAXINT32 +G_MAXUINT32 = _gobject.G_MAXUINT32 +G_MININT64 = _gobject.G_MININT64 +G_MAXINT64 = _gobject.G_MAXINT64 +G_MAXUINT64 = _gobject.G_MAXUINT64 +G_MAXSIZE = _gobject.G_MAXSIZE +G_MAXSSIZE = _gobject.G_MAXSSIZE +G_MINOFFSET = _gobject.G_MINOFFSET +G_MAXOFFSET = _gobject.G_MAXOFFSET + diff --git a/gobject/constants.py.in b/gobject/constants.py.in deleted file mode 100644 index 0a1eb866..00000000 --- a/gobject/constants.py.in +++ /dev/null @@ -1,50 +0,0 @@ -# -*- Mode: Python; py-indent-offset: 4 -*- -# pygobject - Python bindings for the GObject library -# Copyright (C) 2006-2007 Johan Dahlin -# -# gobject/constants.py: GObject type constants -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License, or (at your option) any later version. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 -# USA - -import sys - -import gobject._gobject -_gobject = sys.modules['gobject._gobject'] - -# TYPE_INVALID defined in gobjectmodule.c -TYPE_NONE = _gobject.type_from_name('void') -TYPE_INTERFACE = _gobject.type_from_name('GInterface') -TYPE_CHAR = _gobject.type_from_name('gchar') -TYPE_UCHAR = _gobject.type_from_name('guchar') -TYPE_BOOLEAN = _gobject.type_from_name('gboolean') -TYPE_INT = _gobject.type_from_name('gint') -TYPE_UINT = _gobject.type_from_name('guint') -TYPE_LONG = _gobject.type_from_name('glong') -TYPE_ULONG = _gobject.type_from_name('gulong') -TYPE_INT64 = _gobject.type_from_name('gint64') -TYPE_UINT64 = _gobject.type_from_name('guint64') -TYPE_ENUM = _gobject.type_from_name('GEnum') -TYPE_FLAGS = _gobject.type_from_name('GFlags') -TYPE_FLOAT = _gobject.type_from_name('gfloat') -TYPE_DOUBLE = _gobject.type_from_name('gdouble') -TYPE_STRING = _gobject.type_from_name('gchararray') -TYPE_POINTER = _gobject.type_from_name('gpointer') -TYPE_BOXED = _gobject.type_from_name('GBoxed') -TYPE_PARAM = _gobject.type_from_name('GParam') -TYPE_OBJECT = _gobject.type_from_name('GObject') -TYPE_PYOBJECT = _gobject.type_from_name('PyObject') -TYPE_UNICHAR = TYPE_UINT - diff --git a/gobject/generate-constants.c b/gobject/generate-constants.c deleted file mode 100644 index 7789b968..00000000 --- a/gobject/generate-constants.c +++ /dev/null @@ -1,44 +0,0 @@ -#include -#include -#include - -#if PY_VERSION_HEX < 0x03000000 -# define LONGSUFFIX "L" -#else -# define LONGSUFFIX "" -#endif - -int main(void) -{ - printf("# This part is generated by generate-constants.c\n"); - printf("G_MINFLOAT = %f\n", G_MINFLOAT); - printf("G_MAXFLOAT = %f\n", G_MAXFLOAT); - printf("G_MINDOUBLE = %f\n", G_MINDOUBLE); - printf("G_MAXDOUBLE = %f\n", G_MAXDOUBLE); - printf("G_MINSHORT = %d\n", G_MINSHORT); - printf("G_MAXSHORT = %d\n", G_MAXSHORT); - printf("G_MAXUSHORT = %u\n", G_MAXUSHORT); - printf("G_MININT = %d\n", G_MININT); - printf("G_MAXINT = %d\n", G_MAXINT); - printf("G_MAXUINT = %u\n", G_MAXUINT); - printf("G_MINLONG = %ld%s\n", G_MINLONG, LONGSUFFIX); - printf("G_MAXLONG = %ld%s\n", G_MAXLONG, LONGSUFFIX); - printf("G_MAXULONG = %lu%s\n", G_MAXULONG, LONGSUFFIX); - printf("G_MININT8 = %hhd\n", G_MININT8); - printf("G_MAXINT8 = %hhd\n", G_MAXINT8); - printf("G_MAXUINT8 = %hhu\n", G_MAXUINT8); - printf("G_MININT16 = %" G_GINT16_FORMAT "\n", G_MININT16); - printf("G_MAXINT16 = %" G_GINT16_FORMAT "\n", G_MAXINT16); - printf("G_MAXUINT16 = %" G_GUINT16_FORMAT "\n", G_MAXUINT16); - printf("G_MININT32 = %" G_GINT32_FORMAT "\n", G_MININT32); - printf("G_MAXINT32 = %" G_GINT32_FORMAT "\n", G_MAXINT32); - printf("G_MAXUINT32 = %" G_GUINT32_FORMAT "\n", G_MAXUINT32); - printf("G_MININT64 = %" G_GINT64_FORMAT "%s\n", G_MININT64, LONGSUFFIX); - printf("G_MAXINT64 = %" G_GINT64_FORMAT "%s\n", G_MAXINT64, LONGSUFFIX); - printf("G_MAXUINT64 = %" G_GUINT64_FORMAT "%s\n", G_MAXUINT64, LONGSUFFIX); - printf("G_MAXSIZE = %" G_GSIZE_FORMAT "%s\n", G_MAXSIZE, LONGSUFFIX); - printf("G_MAXSSIZE = %" G_GSSIZE_FORMAT "%s\n", G_MAXSSIZE, LONGSUFFIX); - printf("G_MINOFFSET = %" G_GOFFSET_FORMAT "%s\n", G_MINOFFSET, LONGSUFFIX); - printf("G_MAXOFFSET = %" G_GOFFSET_FORMAT "%s\n", G_MAXOFFSET, LONGSUFFIX); - return 0; -} diff --git a/gobject/gobjectmodule.c b/gobject/gobjectmodule.c index 73bfc3c0..6fc7b51d 100644 --- a/gobject/gobjectmodule.c +++ b/gobject/gobjectmodule.c @@ -2522,6 +2522,41 @@ pygobject_register_api(PyObject *d) 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_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_FromSize_t(G_MAXSIZE)); + PyModule_AddObject(m, "G_MAXSSIZE", PyLong_FromSsize_t(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); PyModule_AddIntConstant(m, "SIGNAL_RUN_CLEANUP", G_SIGNAL_RUN_CLEANUP); diff --git a/setup.py b/setup.py index fcd7e639..50f7abef 100755 --- a/setup.py +++ b/setup.py @@ -207,7 +207,7 @@ if gobject.can_build(): data_files.append((HTML_DIR, glob.glob('docs/html/*.html'))) data_files.append((HTML_DIR, ['docs/style.css'])) data_files.append((XSL_DIR, glob.glob('docs/xsl/*.xsl'))) - py_modules += ['gobject.__init__', 'gobject.propertyhelper'] + py_modules += ['gobject.__init__', 'gobject.propertyhelper', 'gobject.constants'] else: print print 'ERROR: Nothing to do, gobject could not be found and is essential.' diff --git a/tests/runtests.py b/tests/runtests.py index fc0558d2..da5ade03 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) -- cgit v1.2.1 From 69ecd506c83ddf180c6cc9a2a8dc753a02543959 Mon Sep 17 00:00:00 2001 From: John Stowers Date: Sat, 25 Jul 2009 14:12:30 +1200 Subject: Fix crash when importing gio Only seems to be necessary on windows, but no harm on linux as multiple calls to init are OK --- gio/giomodule.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/gio/giomodule.c b/gio/giomodule.c index 171a06f9..409aeefa 100644 --- a/gio/giomodule.c +++ b/gio/giomodule.c @@ -50,6 +50,9 @@ init_gio(void) m = Py_InitModule("gio._gio", pygio_functions); d = PyModule_GetDict(m); + g_type_init(); + pyglib_init(); + init_pygobject_check(2, 15, 2); pygio_register_classes(d); -- cgit v1.2.1 From e580da87f0b2fd36cb5d8008fb2fb0c3b01f456a Mon Sep 17 00:00:00 2001 From: John Stowers Date: Thu, 15 Apr 2010 13:40:39 +1200 Subject: Setup.py cosmetic tidy * Remove local doc install, point to website instead * link to versioned docs --- pygobject_postinstall.py | 43 ++++++++++++++++++++++++++----------------- setup.py | 39 ++++++++++++++------------------------- 2 files changed, 40 insertions(+), 42 deletions(-) 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() diff --git a/setup.py b/setup.py index 50f7abef..0999c002 100755 --- a/setup.py +++ b/setup.py @@ -30,11 +30,9 @@ else: print '*'*70 input = raw_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')) @@ -55,12 +53,18 @@ GLOBAL_MACROS += [('PYGOBJECT_MAJOR_VERSION', MAJOR_VERSION), if sys.platform == 'win32': GLOBAL_MACROS.append(('VERSION', '"""%s"""' % VERSION)) else: - GLOBAL_MACROS.append(('VERSION', '"%s"' % VERSION)) + raise SystemExit("Error: distutils build only supported on windows") + +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') -HTML_DIR = os.path.join('share', 'gtk-doc', 'html', 'pygobject') class PyGObjectInstallLib(InstallLib): def run(self): @@ -107,8 +111,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 @@ -173,10 +175,6 @@ ext_modules = [] py_modules = ['dsextras'] packages = ['codegen'] -if not have_pkgconfig(): - print "Error, could not find pkg-config" - raise SystemExit - if glib.can_build(): #It would have been nice to create another class, such as PkgConfigCLib to #encapsulate this dictionary, but it is impossible. build_clib.py does @@ -197,30 +195,21 @@ if glib.can_build(): ext_modules.append(glib) py_modules += ['glib.__init__', 'glib.option'] else: - print - print 'ERROR: Nothing to do, glib could not be found and is essential.' - raise SystemExit + raise SystemExit("ERROR: Nothing to do, glib could not be found and is essential.") if gobject.can_build(): ext_modules.append(gobject) data_files.append((INCLUDE_DIR, ('gobject/pygobject.h',))) - data_files.append((HTML_DIR, glob.glob('docs/html/*.html'))) - data_files.append((HTML_DIR, ['docs/style.css'])) - data_files.append((XSL_DIR, glob.glob('docs/xsl/*.xsl'))) py_modules += ['gobject.__init__', 'gobject.propertyhelper', 'gobject.constants'] else: - print - print 'ERROR: Nothing to do, gobject could not be found and is essential.' - raise SystemExit + raise SystemExit("ERROR: Nothing to do, gobject could not be found and is essential.") if gio.can_build(): ext_modules.append(gio) py_modules += ['gio.__init__'] data_files.append((DEFS_DIR,('gio/gio-types.defs',))) else: - print - print 'ERROR: Nothing to do, gio could not be found and is essential.' - raise SystemExit + raise SystemExit("ERROR: Nothing to do, gio could not be found and is essential.") # Threading support if '--disable-threading' in sys.argv: -- cgit v1.2.1 From 695ac7bc5c60371a32538d690c7a15509f3c9637 Mon Sep 17 00:00:00 2001 From: John Stowers Date: Fri, 16 Apr 2010 14:36:11 +1200 Subject: Add build docs for windows --- Makefile.am | 1 + README.win32 | 24 ++++++++++++++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 README.win32 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 + -- cgit v1.2.1