File: setup.py

package info (click to toggle)
pygobject 3.22.0-2
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 5,492 kB
  • ctags: 5,045
  • sloc: ansic: 20,987; python: 15,991; sh: 4,659; makefile: 569; xml: 31
file content (105 lines) | stat: -rwxr-xr-x 3,030 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#!/usr/bin/env python


import os
import re
import subprocess
import sys

from distutils.command.build import build as orig_build
from setuptools.command.build_ext import build_ext as orig_build_ext
from setuptools.command.build_py import build_py as orig_build_py
from setuptools import setup, Extension


with open("configure.ac", "r") as h:
    version = ".".join(re.findall("pygobject_[^\s]+_version,\s*(\d+)\)", h.read()))


def makedirs(dirpath):
    """Safely make directories

    By default, os.makedirs fails if the directory already exists.

    Python 3.2 introduced the `exist_ok` argument, but we can't use it because
    we want to keep supporting Python 2 for some time.
    """
    import errno

    try:
        os.makedirs(dirpath)

    except OSError as e:
        if e.errno == errno.EEXIST:
            return

        raise


class Build(orig_build):
    """Dummy version of distutils build which runs an Autotools build system
    instead.
    """
    def run(self):
        srcdir = os.getcwd()
        builddir = os.path.join(srcdir, self.build_temp)
        makedirs(builddir)
        configure = os.path.join(srcdir, 'configure')

        if not os.path.exists(configure):
            configure = os.path.join(srcdir, 'autogen.sh')

        subprocess.check_call([
                configure,
                'PYTHON=%s' % sys.executable,
                # Put the documentation, etc. out of the way: we only want
                # the Python code and extensions
                '--prefix=' + os.path.join(builddir, 'prefix'),
            ],
            cwd=builddir)
        make_args = [
            'pythondir=%s' % os.path.join(srcdir, self.build_lib),
            'pyexecdir=%s' % os.path.join(srcdir, self.build_lib),
        ]
        subprocess.check_call(['make', '-C', builddir] + make_args)
        subprocess.check_call(['make', '-C', builddir, 'install'] + make_args)


class BuildExt(orig_build_ext):
    def run(self):
        pass


class BuildPy(orig_build_py):
    def run(self):
        pass


setup(
    name='pygobject',
    version=version,
    description='Python bindings for GObject Introspection',
    maintainer='The pygobject maintainers',
    maintainer_email='http://mail.gnome.org/mailman/listinfo/python-hackers-list',
    download_url='http://download.gnome.org/sources/pygobject/',
    url='https://wiki.gnome.org/Projects/PyGObject',
    packages=['gi', 'pygtkcompat'],
    ext_modules=[
        Extension(
            '_gi', sources=['gi/gimodule.c'])
        ],
    license='LGPL',
    classifiers=[
        'Development Status :: 5 - Production/Stable',
        'License :: OSI Approved :: GNU Lesser General Public License v2 or later (LGPLv2+)',
        'Programming Language :: C',
        'Programming Language :: Python :: 2',
        'Programming Language :: Python :: 3',
        'Programming Language :: Python :: Implementation :: CPython',
    ],
    cmdclass={
        'build': Build,
        'build_py': BuildPy,
        'build_ext': BuildExt,
    },
)