win32 build
Tim Newsham <[email protected]>
| Newsgroups | gmane.comp.scigraphica.gtkextra |
|---|---|
| Message-ID | <[email protected]> |
Ok.. after much tinkering and a few headaches, I have gtkextra2
and python-gtkextra2 building on win32. Many thanks to those
who answered my questions.
The steps I used are more or less as follows. I'm sure I missed
a few hacks here and there that I might have thrown in:
- install msys and mingw from www.mingw.org
- install python23
- install gtk+ and c++-devel packages. Add the c++-devel stuff to path:
export PATH="$PATH:$PF/Python23"
export PATH="$PATH:$PF/Common Files/GTK/2.0/bin:$PF/Common Files/GTK/2.0/lib"
export PATH="$PATH:$PF/Dev-C++/bin:$PF/Dev-C++/lib"
export PKG_CONFIG_PATH="$PF/Python23/Lib/pkgconfig:$PF/Dev-C++/lib/pkgconfig:$PF/GtkGLExt/1.0/lib/pkgconfig"
- get pexports from http://starship.python.net/crew/kernr/mingw32/Notes.html
run:
$ cd c:/program\ files/python23/libs
$ pexports c:/windows/system32/python23.dll > python23.def
$ dlltool --dllname python23.dll --def python23.def
--output-lib libpython23.a
- build and install pygtk-2.0.0
- build gtkextra-2 from cvs:
- on a linux box check out cvs sources, run autogen.sh and configure
and then make dist.
- extract the dist in windows and build with msys
./configure --disable-gtktest --disable-glibtest --disable-shared \
--enable-static --prefix=c:/gtkextra2 --with-threads=win32 \
--enable-debug=no
replace -fnative-struct with -mms-bitfields -DG_IMPLEMENT_INLINES
in the makefiles
make
make install
- I copy the files to c:\progra~1\Dev-C++ (libtool is incapable
of dealing with spaces or tildes in filenames, so I install it
in c:/gtkextra2 first then move it)
- copy gtkextra-2.0.pc to c:\program files\dev-c++\lib\pkgconfig
- get python-gtkextra2 from cvs and build
- I made a setup.py that I use. Its attached below. It requires
that you manually set the path to your python dist (I'm no
distutils wiz).
python setup.py build --compiler=mingw32
python setup.py install
Thats it. If anyone has questions or recommendations on how to
better deal with the setup.py please let me know.
Tim N.
setup.py
(text/plain, 3.6 KB)
#!/usr/bin/env python
#
# setup.py - distutils configuration for python-gtkextra2
#
"""Python Bindings for the GTK Extra 2"""
from distutils.command.build import build
from distutils.core import setup
import glob
import os
import sys
from dsextras import getoutput, have_pkgconfig, list_files, \
GLOBAL_INC, GLOBAL_MACROS, InstallLib, BuildExt, \
PkgConfigExtension, Template, TemplateExtension
# XXX how can we get this in a better way?
PYTHON_DIR = 'c:\Program Files\Python23'
MAJOR_VERSION = 1
MINOR_VERSION = 1
MICRO_VERSION = 0
VERSION = "%d.%d.%d" % (MAJOR_VERSION,
MINOR_VERSION,
MICRO_VERSION)
PYGTK_SUFFIX = '2.0'
PYGTK_SUFFIX_LONG = 'gtk-' + PYGTK_SUFFIX
if sys.platform == 'win32':
GLOBAL_MACROS.append(('VERSION', '\\\"%s\\\"' % VERSION))
else:
GLOBAL_MACROS.append(('VERSION', '"%s"' % VERSION))
INCLUDE_DIR = os.path.join('include', 'pygtk-%s' % PYGTK_SUFFIX)
DEFS_DIR = os.path.join('share', 'pygtk', PYGTK_SUFFIX, 'defs')
CODEGEN_DIR = os.path.join('share', 'pygtk', PYGTK_SUFFIX, 'codegen')
GLOBAL_INC += ['gtkextra', os.path.join(PYTHON_DIR, INCLUDE_DIR)]
#GLOBAL_MACROS += []
EXTDEFS = ["pango-types.defs", "gdk-types.defs", "gtk-types.defs"]
D = os.path.join(PYTHON_DIR, DEFS_DIR)
REGISTER = [os.path.join(D, name) for name in EXTDEFS]
sys.path.insert(0, os.path.join(PYTHON_DIR, CODEGEN_DIR))
str_version = sys.version[:3]
version = map(int, str_version.split('.'))
if version < [2, 2]:
raise SystemExit, \
"Python 2.2 or higher is required, %s found" % str_version
class PyGtkExtraInstallLib(InstallLib):
def run(self):
self.add_template_option('VERSION', VERSION)
self.prepare()
# Install templates
self.install_templates()
# Modify the base installation dir to install under pygtk's dir
install_dir = os.path.join(self.install_dir, PYGTK_SUFFIX_LONG)
self.set_install_dir(install_dir)
InstallLib.run(self)
def install_templates(self):
self.install_template('python-gtkextra.pc.in',
os.path.join(self.libdir, 'pkgconfig'))
gtkextra = TemplateExtension(name='gtkextra2', pkc_name='gtkextra-2.0',
pkc_version='1.1.0',
output='gtkextra._gtkextra',
sources=['gtkextra/gtkextra.c',
'gtkextra/gtkextramodule.c'],
register=REGISTER + ['gtkextra/gtkextra-types.defs'],
override='gtkextra/gtkextra.override',
defs='gtkextra/gtkextra.defs')
data_files = []
ext_modules = []
py_modules = []
if not have_pkgconfig():
print "Error, could not find pkg-config"
raise SystemExit
if gtkextra.can_build():
ext_modules.append(gtkextra)
data_files.append((DEFS_DIR, ('gtkextra/gtkextra.defs',
'gtkextra/gtkextra-types.defs',
'gtkextra/gtkextra-addons.defs')))
py_modules += ['gtkextra.__init__']
#py_modules += ['gtkextra.config']
doclines = __doc__.split("\n")
setup(name="python-gtkextra2",
url='http://python-gtkextra.sourceforge.net/',
version=VERSION,
license='LGPL',
platforms=['yes'],
description = doclines[0],
long_description = "\n".join(doclines[2:]),
py_modules=py_modules,
ext_modules=ext_modules,
data_files=data_files,
cmdclass={'install_lib': PyGtkExtraInstallLib,
'build_ext': BuildExt,
'build': build})