File: setup.py

package info (click to toggle)
mgltools-pyglf 1.5.7-3
  • links: PTS, VCS
  • area: non-free
  • in suites: buster, sid
  • size: 1,868 kB
  • sloc: ansic: 1,804; python: 153; sh: 78; makefile: 14
file content (106 lines) | stat: -rw-r--r-- 4,109 bytes parent folder | download | duplicates (2)
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
106
# setup.py - Distutils interface for building glf Python extension.
# creating a distribution.

from distutils.core import setup, Extension
from distutils.command.build import build
from distutils.command.sdist import sdist
from distutils.command.install_data import install_data
import sys, os
from os import path
from platform import machine
machine_arch = machine()
pack_name = "pyglf"
ext_name = "_glf"
platform = sys.platform

source = [path.join(pack_name, "glf.i"),  path.join("src", "glf.c")]
include_dirs = {'posix': ["/usr/include/GL"]}.get ( os.name, [])
import numpy
numpy_include =  numpy.get_include()
include_dirs.extend([path.join(".", "src"), numpy_include])
libs =  {'posix': ["GLU","GL","Xmu", "Xt", "X11", "m"],
         'nt': ["glu32", "opengl32"]}.get( os.name, [])
lib_dirs = []
extra_link_args=[]
macros = []
extra_link_args=[]

if platform == "linux2":
    libs.append( "Xi")
    lib_dirs.append("/usr/X11R6/lib")
    if '64' in machine_arch:
        lib_dirs.insert(0,'/usr/X11R6/lib64')
elif platform == "darwin":
    libs.append( "Xi")
    lib_dirs.append("/opt/X11/lib")
    macros.append(("__APPLE__", None))
    #extra_link_args=["-framework", "OpenGL"]
    (osname, host, release, version, machine) = os.uname()
    if release[0] == '9': # leopard
        extra_link_args=['-Wl,-dylib_file,/System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.dylib:/System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.dylib']
elif platform == 'win32':
    macros.append(('WIN32',None))
    
font_files = []
fonts_dir = os.path.join("pyglf", "fonts")
for f in os.listdir(fonts_dir):
    if os.path.isfile(os.path.join("pyglf","fonts", f)):
        font_files.append(os.path.join("pyglf","fonts", f))
    
data_files = [(fonts_dir, font_files)]
    
# Change the order of commands that are called by "build"
# so that "build_py" command is called after "build_ext". In this case
# "build_py" will install (copy to the build directory) python
# modules generated by "build_ext'.

class modified_build(build):

    sub_commands = [('build_clib',    build.has_c_libraries),
                    ('build_ext',     build.has_ext_modules),
                    ('build_py',      build.has_pure_modules),
                    ('build_scripts', build.has_scripts),
                    ]

# Overwrite the prune_file_list method of sdist to not
# remove automatically the RCS/CVS directory from the distribution.

class modified_sdist(sdist):
    def prune_file_list(self):

        build = self.get_finalized_command('build')
        base_dir = self.distribution.get_fullname()
        self.filelist.exclude_pattern(None, prefix=build.build_base)
        self.filelist.exclude_pattern(None, prefix=base_dir)

class modified_install_data(install_data):

    def run(self):
        install_cmd = self.get_finalized_command('install')
        self.install_dir = getattr(install_cmd, 'install_lib')
        return install_data.run(self)
try:   
    from version import VERSION
except:
    VERSION = "1.0"
# setup()      
dist = setup(name=pack_name,
             version=VERSION,
             description = "GLF library Python extension module. The library is used for displaying text in OpenGL.",
             author = "Molecular Graphics Laboratory",
             author_email = "mgltools@scripps.edu",
             url = "http://www.scripps.edu/~sanner/python/packager.html",
             packages = ["pyglf", "pyglf.Tests"],
             cmdclass = {"build" : modified_build,
                         'sdist' : modified_sdist,
                         'install_data': modified_install_data},
             ext_package = pack_name,
             data_files = data_files,
             ext_modules = [Extension (ext_name, source,
                                  include_dirs = include_dirs,
                                  libraries = libs,
                                  library_dirs = lib_dirs,
                                  extra_link_args=extra_link_args,
                                  define_macros = macros,
                                       ) ] ,)