| 1 | """ |
|---|
| 2 | The PIDA Installer |
|---|
| 3 | """ |
|---|
| 4 | |
|---|
| 5 | import os |
|---|
| 6 | from distutils.core import setup, Extension |
|---|
| 7 | from distutils.command.build_ext import build_ext |
|---|
| 8 | |
|---|
| 9 | from pida import PIDA_VERSION, PIDA_AUTHOR, PIDA_WEBSITE, \ |
|---|
| 10 | PIDA_SHORT_DESCRIPTION, PIDA_NAME |
|---|
| 11 | |
|---|
| 12 | # Check availability of pygtk 2.0 |
|---|
| 13 | import subprocess, sys |
|---|
| 14 | NO_PYGTK_ERROR_MESSAGE = """pkg-config reports your system misses pygtk 2.0. |
|---|
| 15 | PIDA needs pygtk headers at compile time. These can generally be found in the |
|---|
| 16 | python-dev or python-gtk2-dev package of your distribution. |
|---|
| 17 | """ |
|---|
| 18 | if subprocess.call(['pkg-config', '--exists', 'pygtk-2.0']) != 0: |
|---|
| 19 | print NO_PYGTK_ERROR_MESSAGE |
|---|
| 20 | sys.exit(1) |
|---|
| 21 | |
|---|
| 22 | |
|---|
| 23 | # Moo Extension |
|---|
| 24 | from dsutils import pkc_get_include_dirs, pkc_get_libraries, pkc_get_library_dirs |
|---|
| 25 | moo = Extension( |
|---|
| 26 | 'moo_stub', |
|---|
| 27 | [ 'contrib/moo/%s'%c for c in [ |
|---|
| 28 | 'moopane.c', |
|---|
| 29 | 'moopaned.c', |
|---|
| 30 | 'moobigpaned.c', |
|---|
| 31 | 'marshals.c', |
|---|
| 32 | 'moo-pygtk.c', |
|---|
| 33 | 'moo-stub.c', |
|---|
| 34 | 'moopython-utils.c', |
|---|
| 35 | ]], |
|---|
| 36 | include_dirs=pkc_get_include_dirs('gtk+-2.0', 'pygtk-2.0'), |
|---|
| 37 | libraries=pkc_get_libraries('gtk+-2.0', 'pygtk-2.0'), |
|---|
| 38 | library_dirs=pkc_get_library_dirs('gtk+-2.0', 'pygtk-2.0'), |
|---|
| 39 | ) |
|---|
| 40 | |
|---|
| 41 | |
|---|
| 42 | class BuildExt(build_ext): |
|---|
| 43 | def build_extension(self, ext): |
|---|
| 44 | if ext.name == 'moo_stub': |
|---|
| 45 | if os.system('cd contrib/moo && make prepare'): |
|---|
| 46 | raise RuntimeError() |
|---|
| 47 | build_ext.build_extension(self, ext) |
|---|
| 48 | |
|---|
| 49 | |
|---|
| 50 | # Modified from kiwi |
|---|
| 51 | def listpackages(root): |
|---|
| 52 | packages = [] |
|---|
| 53 | if os.path.exists(os.path.join(root, '__init__.py')): |
|---|
| 54 | packages.append(root.replace('/', '.')) |
|---|
| 55 | for filename in os.listdir(root): |
|---|
| 56 | full = os.path.join(root, filename) |
|---|
| 57 | if os.path.isdir(full): |
|---|
| 58 | packages.extend(listpackages(full)) |
|---|
| 59 | return packages |
|---|
| 60 | |
|---|
| 61 | |
|---|
| 62 | def list_pida_packages(): |
|---|
| 63 | packages = [] |
|---|
| 64 | for package in ['pida', 'pida/core', 'pida/ui', 'pida/utils']: |
|---|
| 65 | packages.extend(listpackages(package)) |
|---|
| 66 | return packages |
|---|
| 67 | |
|---|
| 68 | |
|---|
| 69 | |
|---|
| 70 | def list_pida_services(package_data): |
|---|
| 71 | packages = listpackages('pida/services') + listpackages('pida/editors') |
|---|
| 72 | for package in packages: |
|---|
| 73 | package_data[package] = [ |
|---|
| 74 | 'service.pida', |
|---|
| 75 | 'glade/*', |
|---|
| 76 | 'pixmaps/*', |
|---|
| 77 | 'uidef/*', |
|---|
| 78 | 'data/*', |
|---|
| 79 | 'locale/fr_FR/LC_MESSAGES/*', |
|---|
| 80 | ] |
|---|
| 81 | return packages |
|---|
| 82 | |
|---|
| 83 | |
|---|
| 84 | def get_main_data(): |
|---|
| 85 | return { |
|---|
| 86 | 'pida': |
|---|
| 87 | [ |
|---|
| 88 | 'resources/glade/*', |
|---|
| 89 | 'resources/pixmaps/*', |
|---|
| 90 | 'resources/uidef/*', |
|---|
| 91 | 'resources/data/*', |
|---|
| 92 | 'resources/locale/fr_FR/LC_MESSAGES/*', |
|---|
| 93 | 'utils/puilder/glade/*', |
|---|
| 94 | ] |
|---|
| 95 | } |
|---|
| 96 | |
|---|
| 97 | all_package_data = get_main_data() |
|---|
| 98 | |
|---|
| 99 | all_packages = list_pida_packages() + list_pida_services(all_package_data) |
|---|
| 100 | |
|---|
| 101 | setup( |
|---|
| 102 | name = PIDA_NAME, |
|---|
| 103 | version = PIDA_VERSION, |
|---|
| 104 | packages = all_packages, |
|---|
| 105 | package_data = all_package_data, |
|---|
| 106 | ext_modules = [moo], |
|---|
| 107 | cmdclass={'build_ext': BuildExt}, |
|---|
| 108 | scripts=['bin/pida', 'bin/pida-remote', 'bin/pida-build', 'bin/pida-pyshell'], |
|---|
| 109 | author = PIDA_AUTHOR, |
|---|
| 110 | author_email = PIDA_AUTHOR, |
|---|
| 111 | url = PIDA_WEBSITE, |
|---|
| 112 | download_url = PIDA_WEBSITE + 'download/', |
|---|
| 113 | description = PIDA_SHORT_DESCRIPTION, |
|---|
| 114 | ) |
|---|
| 115 | |
|---|