GValue: add overflow checking for py -> gint; forward marshaling exceptions
[pygobject.git] / setup.py
blob0da9ed95abb0d4b6cb844d2977ba9f360ba6f41b
1 #!/usr/bin/env python
4 import os
5 import re
6 import subprocess
7 import sys
9 from distutils.command.build import build as orig_build
10 from setuptools.command.build_ext import build_ext as orig_build_ext
11 from setuptools.command.build_py import build_py as orig_build_py
12 from setuptools import setup, Extension
15 with open("configure.ac", "r") as h:
16 version = ".".join(re.findall("pygobject_[^\s]+_version,\s*(\d+)\)", h.read()))
19 def makedirs(dirpath):
20 """Safely make directories
22 By default, os.makedirs fails if the directory already exists.
24 Python 3.2 introduced the `exist_ok` argument, but we can't use it because
25 we want to keep supporting Python 2 for some time.
26 """
27 import errno
29 try:
30 os.makedirs(dirpath)
32 except OSError as e:
33 if e.errno == errno.EEXIST:
34 return
36 raise
39 class Build(orig_build):
40 """Dummy version of distutils build which runs an Autotools build system
41 instead.
42 """
43 def run(self):
44 srcdir = os.getcwd()
45 builddir = os.path.join(srcdir, self.build_temp)
46 makedirs(builddir)
47 configure = os.path.join(srcdir, 'configure')
49 if not os.path.exists(configure):
50 configure = os.path.join(srcdir, 'autogen.sh')
52 subprocess.check_call([
53 configure,
54 'PYTHON=%s' % sys.executable,
55 # Put the documentation, etc. out of the way: we only want
56 # the Python code and extensions
57 '--prefix=' + os.path.join(builddir, 'prefix'),
59 cwd=builddir)
60 make_args = [
61 'pythondir=%s' % os.path.join(srcdir, self.build_lib),
62 'pyexecdir=%s' % os.path.join(srcdir, self.build_lib),
64 subprocess.check_call(['make', '-C', builddir] + make_args)
65 subprocess.check_call(['make', '-C', builddir, 'install'] + make_args)
68 class BuildExt(orig_build_ext):
69 def run(self):
70 pass
73 class BuildPy(orig_build_py):
74 def run(self):
75 pass
78 setup(
79 name='pygobject',
80 version=version,
81 description='Python bindings for GObject Introspection',
82 maintainer='The pygobject maintainers',
83 maintainer_email='http://mail.gnome.org/mailman/listinfo/python-hackers-list',
84 download_url='http://download.gnome.org/sources/pygobject/',
85 url='https://wiki.gnome.org/Projects/PyGObject',
86 packages=['gi', 'pygtkcompat'],
87 ext_modules=[
88 Extension(
89 '_gi', sources=['gi/gimodule.c'])
91 license='LGPL',
92 classifiers=[
93 'Development Status :: 5 - Production/Stable',
94 'License :: OSI Approved :: GNU Lesser General Public License v2 or later (LGPLv2+)',
95 'Programming Language :: C',
96 'Programming Language :: Python :: 2',
97 'Programming Language :: Python :: 3',
98 'Programming Language :: Python :: Implementation :: CPython',
100 cmdclass={
101 'build': Build,
102 'build_py': BuildPy,
103 'build_ext': BuildExt,