/[thuban]/branches/WIP-pyshapelib-bramz/setup.py
ViewVC logotype

Diff of /branches/WIP-pyshapelib-bramz/setup.py

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 203 by bh, Mon Jul 8 15:04:57 2002 UTC revision 1291 by jonathan, Mon Jun 23 13:05:32 2003 UTC
# Line 1  Line 1 
1  # Copyright (c) 2001, 2002 by Intevation GmbH  # Copyright (c) 2001, 2002, 2003 by Intevation GmbH
2  # Authors:  # Authors:
3  # Bernhard Herzog <[email protected]>  # Bernhard Herzog <[email protected]>
4  #  #
# Line 17  __version__ = "$Revision$" Line 17  __version__ = "$Revision$"
17    
18  import os  import os
19  from types import TupleType  from types import TupleType
20    import glob
21  from distutils.core import setup, Extension, Command  from distutils.core import setup, Extension, Command
22  from distutils.command.install import install  from distutils.command.install import install, INSTALL_SCHEMES, subst_vars
23  from distutils.command.build_py import build_py  from distutils.command.build_py import build_py
24  from distutils.command.bdist_rpm import bdist_rpm  from distutils.command.bdist_rpm import bdist_rpm
25    from distutils.command.build_ext import build_ext
26  from distutils.file_util import write_file  from distutils.file_util import write_file
27  from distutils.filelist import FileList  from distutils.filelist import FileList
28  from distutils.util import convert_path, change_root  from distutils.util import convert_path, change_root
# Line 31  import distutils Line 33  import distutils
33  from string import split  from string import split
34  import string  import string
35    
36    # config script parameter list indices
37    CS_DEFS, CS_INCDIRS, CS_LIBDIRS, CS_LIBS, CS_NUM_PARAMS = range(5)
38    
39    # support for gdal is on by default, but under posix we try to
40    # detect it anyway. Set this to False to disable GDAL.
41    include_gdal = True
42    
43  if os.name == "posix":  if os.name == "posix":
44      ###################################################################      ###################################################################
45      # Posix configuration. Adapt this if you're running some kind of      # Posix configuration. Adapt this if you're running some kind of
# Line 43  if os.name == "posix": Line 52  if os.name == "posix":
52      proj4_lib = "proj"      proj4_lib = "proj"
53    
54    
55      # You shpuldn't have to modify anything below here      # You shouldn't have to modify anything below here
56      ###################################################################      ###################################################################
57            
58      # The installation prefix (similar to autoconf's --prefix). This is      # The installation prefix (similar to autoconf's --prefix). This is
# Line 51  if os.name == "posix": Line 60  if os.name == "posix":
60      # with the install command's --prefix option.      # with the install command's --prefix option.
61      #      #
62      # Note that there's a separate prefix option for the bdist_rpm      # Note that there's a separate prefix option for the bdist_rpm
63      # command completely independend of this one.      # command completely independent of this one.
64      prefix = "/usr/local/"      prefix = "/usr/local/"
65    
66        # Whether to create the thubaninit module. You can override this
67        # value on the commandline with the --create-init-module to the
68        # install command.
69        create_init_module = 1
70    
71      # On POSIX-systems we run wxgtk-config to determine the C++-compiler      # On POSIX-systems we run wxgtk-config to determine the C++-compiler
72      # flags      # flags
73      wx_config_script = "wx-config"      wx_config_script = "wx-config"
74      # These lists will be filled automatically below      # These lists will be filled automatically below
75      wx_defs = []      wx_cs_params = [[] for i in range(CS_NUM_PARAMS)]
76      wx_incdirs = []  
77      wx_libdirs = []      gdal_config_script = "gdal-config"
78      wx_libs = []      gdal_cs_params = [[] for i in range(CS_NUM_PARAMS)]
79    
80  elif os.name == "nt":  elif os.name == "nt":
81      #################################################################      #################################################################
# Line 69  elif os.name == "nt": Line 83  elif os.name == "nt":
83      #      #
84            
85      # Directories where Proj4 is installed      # Directories where Proj4 is installed
86      proj4_prefix = r"D:\cygwin\home\user\proj-4.4.3\src"      proj4_prefix = r"D:\cygwin\home\user\proj-4.4.7\src"
87      proj4_incdir =  proj4_prefix      proj4_incdir =  proj4_prefix
88      proj4_libdir =  proj4_prefix      proj4_libdir =  proj4_prefix
89      proj4_lib = "proj_i"      proj4_lib = "proj_i"
90    
91      # Define include and lib directories for wxWindows and      # Define include and lib directories for wxWindows and
92      wx_prefix = r"D:\wx230"      #wx_prefix = r"D:\cygwin\home\user\project\greater\wxPython-2.4.0.4"
93      wx_inc =  os.path.join(wx_prefix, "include")      wx_prefix = r"D:\wx-sources\wxPythonSrc-2.4.0.7"
94      wx_lib =  os.path.join(wx_prefix, "lib")      wx_inc = [os.path.join(wx_prefix, 'lib', 'mswdll'),
95                  os.path.join(wx_prefix, "include")]
96        wx_lib = [os.path.join(wx_prefix, "lib")]
97    
98        # Define include and lib directories for GDAL
99        gdal_prefix = r"D:\cygwin\home\user\build\gdal-1.1.8"
100        gdal_inc = [os.path.join(gdal_prefix, 'alg'),
101                    os.path.join(gdal_prefix, 'ogr'),
102                    os.path.join(gdal_prefix, 'port'),
103                    os.path.join(gdal_prefix, 'core')]
104        gdal_lib = [gdal_prefix]
105    
106      #      #
107      # Unless you use a wxPython version other than 2.3.1, you probably      # Unless you use a wxPython version other than 2.4.0, you probably
108      # shouldn't have to modify anything below here      # shouldn't have to modify anything below here
109      ##################################################################      ##################################################################
110            
# Line 89  elif os.name == "nt": Line 113  elif os.name == "nt":
113      # the command line with the install command's --prefix option      # the command line with the install command's --prefix option
114      prefix = r"install"      prefix = r"install"
115    
116        # Whether to create the thubaninit module. You can override this
117        # value on the commandline with the --create-init-module to the
118        # install command. By default we don't create it under NT because we
119        # most often run install only as part of bdist_inno where we can't
120        # really create because it needs information only known at install
121        # time.
122        create_init_module = 0
123    
124      # There doesn't seem to be an easy way to get at the wx compiler      # There doesn't seem to be an easy way to get at the wx compiler
125      # flags, so we define them here. These flags work for us with      # flags, so we define them here. These flags work for us with
126      # wxPython 2.3.1. They may have to be modified for other versions.      # wxPython 2.3.1. They may have to be modified for other versions.
# Line 96  elif os.name == "nt": Line 128  elif os.name == "nt":
128      # there's no config script.      # there's no config script.
129      wx_config_script = ""      wx_config_script = ""
130            
131        wx_cs_params = [[] for i in range(CS_NUM_PARAMS)]
132    
133      # the values of wx_defs and wx_libs. copied from the wxPython      # the values of wx_defs and wx_libs. copied from the wxPython
134      # setup.py      # setup.py
135      wx_defs = [ ('WIN32', None),        # Some of these are no longer      wx_cs_params[CS_DEFS] = \
136                  [ ('WIN32', None),        # Some of these are no longer
137                  ('__WIN32__', None),    # necessary.  Anybody know which?                  ('__WIN32__', None),    # necessary.  Anybody know which?
138                  ('_WINDOWS', None),                  ('_WINDOWS', None),
139                  ('__WINDOWS__', None),                  ('__WINDOWS__', None),
# Line 114  elif os.name == "nt": Line 149  elif os.name == "nt":
149                  ('WXP_USE_THREAD', '1'),                  ('WXP_USE_THREAD', '1'),
150                  ]                  ]
151            
152      wx_incdirs = [wx_inc]      wx_cs_params[CS_INCDIRS] = wx_inc
153      wx_libdirs = [wx_lib]      wx_cs_params[CS_LIBDIRS] = wx_lib
154      wx_libs = ["wx23_1h"]      wx_cs_params[CS_LIBS] = ["wxmsw24"] \
155      wx_libs = wx_libs + ['kernel32', 'user32', 'gdi32', 'comdlg32',                        + ['kernel32', 'user32', 'gdi32', 'comdlg32',
156                           'winspool', 'winmm', 'shell32', 'oldnames',                           'winspool', 'winmm', 'shell32', 'oldnames',
157                           'comctl32', 'ctl3d32', 'odbc32', 'ole32', 'oleaut32',                           'comctl32', 'ctl3d32', 'odbc32', 'ole32', 'oleaut32',
158                           'uuid', 'rpcrt4', 'advapi32', 'wsock32']                           'uuid', 'rpcrt4', 'advapi32', 'wsock32']
159    
160        gdal_config_script = ""
161        gdal_cs_params = [[] for i in range(CS_NUM_PARAMS)]
162    
163        gdal_cs_params[CS_INCDIRS] = gdal_inc
164        gdal_cs_params[CS_LIBDIRS] = gdal_lib
165        gdal_cs_params[CS_LIBS] = ["gdal_i"]
166    
167  else:  else:
168      raise RuntimeError("Unsupported platform " + os.name)      raise RuntimeError("Unsupported platform " + os.name)
169    
# Line 147  def run_script(cmdline): Line 190  def run_script(cmdline):
190      return result      return result
191    
192    
193  def run_wx_script(command):  def run_cs_script(command, store):
194      # first, determine the C++ preprocessor flags Use --cflags here      # first, determine the C++ preprocessor flags Use --cflags here
195      # because it seems that older version don't have --cxxflags and      # because it seems that older version don't have --cxxflags and
196      # newer ones return the same result for both      # newer ones return the same result for both
197      flags = run_script(command + ' --cflags ')      flags = run_script(command + ' --cflags ')
198      if flags is None:      if flags is None:
199          return 0          return False
200      for flag in split(flags):      for flag in split(flags):
201          start = flag[:2]          start = flag[:2]
202          value = flag[2:]          value = flag[2:]
203          if start == "-I":          if start == "-I":
204              wx_incdirs.append(value)              store[CS_INCDIRS].append(value)
205          elif start == "-D":          elif start == "-D":
206              wx_defs.append((value, None))              store[CS_DEFS].append((value, None))
207    
208      # determine the library flags      # determine the library flags
209      flags = run_script(command + ' --libs')      flags = run_script(command + ' --libs')
210      if flags is None:      if flags is None:
211          return 0          return False
212      for flag in split(flags):      for flag in split(flags):
213          start = flag[:2]          start = flag[:2]
214          value = flag[2:]          value = flag[2:]
215          if start == "-L":          if start == "-L":
216              wx_libdirs.append(value)              store[CS_LIBDIRS].append(value)
217          elif start == "-l":          elif start == "-l":
218              wx_libs.append(value)              store[CS_LIBS].append(value)
219    
220        return True
221    
222  if wx_config_script:  if wx_config_script:
223      # if there's a wx config script, run it to determine the configuration      # if there's a wx config script, run it to determine the configuration
224      run_wx_script(wx_config_script)      run_cs_script(wx_config_script, wx_cs_params)
       
225    
226    if gdal_config_script:
227        # if there's a gdal config script, run it to determine the configuration
228        include_gdal = include_gdal \
229                       and run_cs_script(gdal_config_script, gdal_cs_params)
230    
231  #  #
232  # Define some extension and python modules  # Define some extension and python modules
# Line 206  extensions.append(Extension("Lib.wxproj" Line 254  extensions.append(Extension("Lib.wxproj"
254                              [ext_dir + "/thuban/wxproj.cpp"],                              [ext_dir + "/thuban/wxproj.cpp"],
255                              include_dirs = ([shp_dir, proj4_incdir,                              include_dirs = ([shp_dir, proj4_incdir,
256                                               ext_dir + "/pyshapelib/"]                                               ext_dir + "/pyshapelib/"]
257                                              + wx_incdirs),                                              + wx_cs_params[CS_INCDIRS]),
258                              define_macros = wx_defs,                              define_macros = wx_cs_params[CS_DEFS],
259                              library_dirs = [proj4_libdir] + wx_libdirs,                              library_dirs = [proj4_libdir] +
260                              libraries = [proj4_lib] + wx_libs))                                             wx_cs_params[CS_LIBDIRS],
261                                libraries = [proj4_lib] + wx_cs_params[CS_LIBS]))
262    
263    
264  #  #
265  # shapelib wrappers are also distributed with thuban  # shapelib wrappers are also distributed with thuban
# Line 248  py_modules.append(ext_dir + "/pyprojecti Line 298  py_modules.append(ext_dir + "/pyprojecti
298  data_files = []  data_files = []
299    
300  # bitmaps  # bitmaps
301  dir = "Resources/Bitmaps"  # ("Resources/Locale", "Resources/Locale/*/LC_MESSAGES/*.mo")
302  bitmaps = []  for d, pattern in [("Resources/Bitmaps", "Resources/Bitmaps/*.xpm")]:
303  for file in os.listdir(os.path.join("Resources", "Bitmaps")):      data_files.append((d, glob.glob(pattern)))
     if string.lower(file[-4:]) == ".xpm":  
         bitmaps.append(dir + '/' +  file)  
 data_files.append((dir, bitmaps))  
304    
305  #  #
306  #       Command definitions  #       Command definitions
# Line 404  class InstallLocal(Command): Line 451  class InstallLocal(Command):
451    
452      user_options = [      user_options = [
453          ('skip-build', None, "skip the build steps"),          ('skip-build', None, "skip the build steps"),
454            ('create-init-module', None,
455             "Create the thubaninit.py module to ease use of Thuban as a library"),
456            ('dont-create-init-module', None,
457             "Do not create the thubaninit.py module"),
458          ]          ]
459    
460        boolean_options = ["create-init-module"]
461        negative_opt = {'dont-create-init-module' : 'create-init-module'}
462    
463    
464      def initialize_options (self):      def initialize_options (self):
465          self.extensions = None          self.extensions = None
466          self.build_dir = None          self.build_dir = None
467          self.skip_build = None          self.skip_build = None
468            self.create_init_module = None
469    
470      def finalize_options (self):      def finalize_options (self):
471          self.set_undefined_options("install",          self.set_undefined_options("install",
472                                     ("build_lib", "build_dir"),                                     ("build_lib", "build_dir"),
473                                     ('skip_build', 'skip_build'))                                     ('skip_build', 'skip_build'))
474          self.extensions = self.distribution.ext_modules          self.extensions = self.distribution.ext_modules
475            if self.create_init_module is None:
476                # by default we create the init module
477                self.create_init_module = 1
478    
479      def run(self):      def run(self):
480          # Make sure we have built everything we need first          # Make sure we have built everything we need first
# Line 429  class InstallLocal(Command): Line 488  class InstallLocal(Command):
488          else:          else:
489              self.copy_tree(libdir, "Lib")              self.copy_tree(libdir, "Lib")
490    
491            # create the init module if desired
492            if self.create_init_module:
493                # create the init module
494                initfilename = "thubaninit.py"
495                contents = thubaninit_contents("")
496                self.execute(write_file, (initfilename, contents),
497                             "Create %s" % initfilename)
498    
499      def link_dir(self, src, dest):      def link_dir(self, src, dest):
500          """Create a symbolic link dest pointing to src"""          """Create a symbolic link dest pointing to src"""
501          if self.verbose:          if self.verbose:
# Line 455  class thuban_build_py(build_py): Line 522  class thuban_build_py(build_py):
522      distribution.      distribution.
523      """      """
524    
525        # FIXME: When Thuban can rely on Python 2.3 as the oldest supported
526        # Python release we don't need to override the run and
527        # find_all_modules methods anymore. distutils will allow both python
528        # modules and packages starting with 2.3.
529    
530      def run(self):      def run(self):
531          """The same the as the original in build_py revision 1.33 except          """The same the as the original in build_py revision 1.33 except
532          that this allows both packages and modules to be in one          that this allows both packages and modules to be in one
# Line 506  class thuban_build_py(build_py): Line 578  class thuban_build_py(build_py):
578          return modules          return modules
579    
580    
581    thubaninit_contents_start = """
582    # This module was automatically generated by Thuban's install script
583    '''Import this module once per program (best place is probably the file
584    that ends up as your __main__ module) to be able to import Thuban
585    afterwards.
586    
587    Usage:
588    
589    import thubaninit
590    import Thuban
591    '''
592    import sys, os
593    """
594    
595    thubaninit_contents_thubaninitdir = """
596    sys.path.insert(0, %(thubandir)s)
597    """
598    thubaninit_contents_otherdirs = """
599    # Put the Lib dir into the path. The Lib dir contains some extra Python
600    # modules
601    import Thuban
602    thubandir = os.path.join(Thuban.__path__[0], '..')
603    dir = os.path.join(thubandir, "Lib")
604    if os.path.isdir(dir):
605        sys.path.insert(0, dir)
606    """
607    
608    def thubaninit_contents(thubandir):
609        """Return the contents of the the thubaninit file as a list of lines.
610    
611        The parameter thubandir is the parent directory where the Thuban/
612        package or the empty string if the thubaninit file itself will be
613        located in that direcory as well.
614        """
615        contents = thubaninit_contents_start
616        if thubandir:
617            thubandir = repr(thubandir)
618            contents += thubaninit_contents_thubaninitdir % locals()
619        contents += thubaninit_contents_otherdirs
620        return contents.split("\n")
621    
622    
623  class ThubanInstall(install):  class ThubanInstall(install):
624    
# Line 522  class ThubanInstall(install): Line 635  class ThubanInstall(install):
635                          "(default on posix systems and only relevant there)"),                          "(default on posix systems and only relevant there)"),
636    
637                           ("extra-files", None,                           ("extra-files", None,
638                            "List of filenames or (src, dest) pairs describing "                            "List of filenames or (src, dest) pairs describing"
639                            " extra files to install "                            " extra files to install "
640                            "(can only be set from witin setup.py"),                            "(can only be set from within setup.py"),
641    
642                             ("create-init-module=", None,
643                              "If true, create a module in the site-packages"
644                              " directory that tweaks sys.path to let you easily"
645                              " import thuban modules from outside of thuban."),
646                             ("init-module-dir=", None,
647                              "Directory in which to create the init module."
648                              " Defaults to Python's site-packages directory."),
649                           ])                           ])
650    
651      boolean_options = install.boolean_options[:]      boolean_options = install.boolean_options[:]
652      boolean_options.append("do-symlink")      boolean_options.append("do-symlink")
653        boolean_options.append("create-init-module")
654    
655      def initialize_options(self):      def initialize_options(self):
656          self.do_symlink = None          self.do_symlink = None
657          self.extra_files = []          self.extra_files = []
658    
659            # initialize the create_init_module flag from the global
660            # determined at runtime
661            self.create_init_module = create_init_module
662            self.init_module_dir = None
663          install.initialize_options(self)          install.initialize_options(self)
664    
665      def finalize_options(self):      def finalize_options(self):
# Line 542  class ThubanInstall(install): Line 669  class ThubanInstall(install):
669              else:              else:
670                  self.do_symlink = 0                  self.do_symlink = 0
671          install.finalize_options(self)          install.finalize_options(self)
672            self.expand_with_pure_python_dirs(["init_module_dir"])
673    
674        def expand_with_pure_python_dirs(self, attrs):
675            """Expand the attributes with default values of base and platbase"""
676            # it seems that the values for "prefix" and "exec_prefix" in
677            # self.config_vars are the corresponding values used by the
678            # python interpreter, so we just assign these to "base" and
679            # "platbase".
680            config_vars = self.config_vars.copy()
681            config_vars["base"] = self.config_vars["prefix"]
682            config_vars["platbase"] = self.config_vars["exec_prefix"]
683            for attr in attrs:
684                val = getattr(self, attr)
685                if val is not None:
686                    if os.name == 'posix':
687                        val = os.path.expanduser(val)
688                    val = subst_vars(val, config_vars)
689                    setattr(self, attr, val)
690    
691        def select_scheme(self, scheme):
692            """Extend the inherited method to set init_module_dir"""
693            install.select_scheme(self, scheme)
694            # only set init_module_dir if it wasn't set by the user
695            if self.init_module_dir is None:
696                self.init_module_dir = INSTALL_SCHEMES[scheme]['purelib']
697    
698        def convert_paths(self, *args):
699            """Extend the inherited method so that we can remember some filename
700            """
701            # remember the installation directory before its root gets
702            # changed
703            self.install_lib_orig = self.install_lib
704            apply(install.convert_paths, (self,) + args)
705    
706      def run(self):      def run(self):
707          install.run(self)          install.run(self)
# Line 550  class ThubanInstall(install): Line 710  class ThubanInstall(install):
710                  src, dest = item                  src, dest = item
711              else:              else:
712                  src = dest = item                  src = dest = item
713              self.copy_file(convert_path(src),              self.copy_file(convert_path(src),
714                             os.path.join(self.root, convert_path(dest)))                             os.path.join(self.root, convert_path(dest)))
715    
716          if os.name == "posix" and self.do_symlink:          if os.name == "posix" and self.do_symlink:
# Line 565  class ThubanInstall(install): Line 725  class ThubanInstall(install):
725              self.mkpath(bindir)              self.mkpath(bindir)
726              self.link_file(scriptfile, binfile)              self.link_file(scriptfile, binfile)
727    
728            if self.create_init_module:
729                # create the init module
730                initfilename = self.thuban_init_filename()
731                if self.root:
732                    initfilename = change_root(self.root, initfilename)
733                contents = thubaninit_contents(self.install_lib_orig)
734                self.mkpath(os.path.dirname(initfilename))
735                self.execute(write_file, (initfilename, contents),
736                             "Create %s" % initfilename)
737    
738      def link_file(self, src, dest):      def link_file(self, src, dest):
739          """Create a symbolic link dest pointing to src.          """Create a symbolic link dest pointing to src.
740    
# Line 579  class ThubanInstall(install): Line 749  class ThubanInstall(install):
749          if not os.path.exists(dest):          if not os.path.exists(dest):
750              os.symlink(src, dest)              os.symlink(src, dest)
751    
752        def thuban_init_filename(self):
753            """Return the filename for the init-module"""
754            # Since we override the normal install dirs to point to our own
755            # prefix we have to reach into installed
756            return self.init_module_dir + "/thubaninit.py"
757    
758      def get_outputs (self):      def get_outputs (self):
759          outputs = install.get_outputs(self)          outputs = install.get_outputs(self)
# Line 594  class ThubanInstall(install): Line 769  class ThubanInstall(install):
769                  bindir = change_root(self.root, bindir)                  bindir = change_root(self.root, bindir)
770              binfile = os.path.join(bindir, "thuban")              binfile = os.path.join(bindir, "thuban")
771              outputs.append(binfile)              outputs.append(binfile)
772            if self.create_init_module:
773                initfilename = self.thuban_init_filename()
774                if self.root:
775                    initfilename = change_root(self.root, initfilename)
776                outputs.append(initfilename)
777          return outputs          return outputs
778    
779    
# Line 607  cp extensions/pyshapelib/{COPYING,COPYIN Line 787  cp extensions/pyshapelib/{COPYING,COPYIN
787  cp extensions/pyprojection/{LICENSE,LICENSE.pyprojection}  cp extensions/pyprojection/{LICENSE,LICENSE.pyprojection}
788  '''  '''
789    
790    bdist_rpm_build_script = '''
791    env PATH="$PATH:%(prefix)s/lib/wxPython/bin:/usr/lib/wxPython/bin" CFLAGS="$RPM_OPT_FLAGS" %(python)s setup.py build
792    '''
793    
794  bdist_rpm_install_script = '''  bdist_rpm_install_script = '''
795  %(python)s setup.py install --root=$RPM_BUILD_ROOT --record=INSTALLED_FILES \  %(python)s setup.py install --root=$RPM_BUILD_ROOT --record=INSTALLED_FILES \
796     --prefix=%(prefix)s     --prefix=%(prefix)s
797  '''  '''
798    
799        
800  class thuban_bdist_rpm(bdist_rpm):  class thuban_bdist_rpm(bdist_rpm):
801    
802      """Thuban specific RPM distribution command"""      """Thuban specific RPM distribution command"""
# Line 630  class thuban_bdist_rpm(bdist_rpm): Line 814  class thuban_bdist_rpm(bdist_rpm):
814          # scripts such as the python interpreter to use are only known          # scripts such as the python interpreter to use are only known
815          # then.          # then.
816          open("bdist_rpm_prep", "w").close()          open("bdist_rpm_prep", "w").close()
817            open("bdist_rpm_build", "w").close()
818          open("bdist_rpm_install", "w").close()          open("bdist_rpm_install", "w").close()
819          bdist_rpm.initialize_options(self)          bdist_rpm.initialize_options(self)
820    
# Line 637  class thuban_bdist_rpm(bdist_rpm): Line 822  class thuban_bdist_rpm(bdist_rpm):
822          # create the scripts for the spec-file. Now we know the python          # create the scripts for the spec-file. Now we know the python
823          # interpreter to use.          # interpreter to use.
824          open("bdist_rpm_prep", "w").write(bdist_rpm_prep_script)          open("bdist_rpm_prep", "w").write(bdist_rpm_prep_script)
825    
826            build = bdist_rpm_build_script % {"python": self.python,
827                                              "prefix": self.prefix}
828            open("bdist_rpm_build", "w").write(build)
829    
830          install = bdist_rpm_install_script % {"python": self.python,          install = bdist_rpm_install_script % {"python": self.python,
831                                                "prefix": self.prefix}                                                "prefix": self.prefix}
832          open("bdist_rpm_install", "w").write(install)          open("bdist_rpm_install", "w").write(install)
# Line 724  class bdist_inno(Command): Line 914  class bdist_inno(Command):
914          """Execute the command. install_options if given, should be a          """Execute the command. install_options if given, should be a
915          directory of additional options to set in the install step"""          directory of additional options to set in the install step"""
916          # Obviously have to build before we can install          # Obviously have to build before we can install
917    
918          if not self.skip_build:          if not self.skip_build:
919              self.run_command('build')              self.run_command('build')
920    
# Line 746  class bdist_inno(Command): Line 937  class bdist_inno(Command):
937          self.execute(write_file, (iss_file, self.generate_iss()),          self.execute(write_file, (iss_file, self.generate_iss()),
938                       "Create Inno Setup script file %s" % iss_file)                       "Create Inno Setup script file %s" % iss_file)
939    
940          # and invoke          # and invoke
941          if self.run_inno:          if self.run_inno:
942              self.spawn(["iscc", iss_file])              self.spawn(["iscc", iss_file])
943    
# Line 812  class bdist_inno(Command): Line 1003  class bdist_inno(Command):
1003              line = 'Name: "{group}\\%s"; Filename: "%s";' \              line = 'Name: "{group}\\%s"; Filename: "%s";' \
1004                     % (icon.title, icon.install_name)                     % (icon.title, icon.install_name)
1005              iss.append(line)              iss.append(line)
1006                
1007          return iss          return iss
1008    
1009    
# Line 828  class InnoIconItem: Line 1019  class InnoIconItem:
1019          else:          else:
1020              self.install_name = filename              self.install_name = filename
1021    
1022                
1023  class thuban_bdist_inno(bdist_inno):  class thuban_bdist_inno(bdist_inno):
1024    
1025      """Thuban specific Inno Setup stuff"""      """Thuban specific Inno Setup stuff"""
# Line 836  class thuban_bdist_inno(bdist_inno): Line 1027  class thuban_bdist_inno(bdist_inno):
1027      def run(self):      def run(self):
1028          install_options = {          install_options = {
1029              "prefix": ".",              "prefix": ".",
1030                "install_lib": "$base",
1031                "install_data": "$base",
1032              "install_scripts": "$base",              "install_scripts": "$base",
1033              "warn_dir": 0,              "warn_dir": 0,
1034              "extra_files": ["COPYING", "Lib/proj.dll"],              "extra_files": ["COPYING", "Lib/proj.dll"],
# Line 843  class thuban_bdist_inno(bdist_inno): Line 1036  class thuban_bdist_inno(bdist_inno):
1036          # don't make a symlink because we're simulating windows, so          # don't make a symlink because we're simulating windows, so
1037          # that we can generate the iss-file even on Linux          # that we can generate the iss-file even on Linux
1038          install_options["do_symlink"] = 0          install_options["do_symlink"] = 0
1039    
1040          bdist_inno.run(self, install_options)          bdist_inno.run(self, install_options)
1041        
1042                class thuban_build_docs(Command):
1043    
1044        """Command to generate documentation from source code."""
1045    
1046        description = "Generate documentation."
1047    
1048        user_options = []
1049    
1050        def initialize_options(self): pass
1051    
1052        def finalize_options(self): pass
1053    
1054        def run(self, install_options = None):
1055            self.spawn(["happydoc", "-d./Doc", "./Thuban"])
1056    
1057    class thuban_build_ext(build_ext):
1058    
1059        """Extend the build_ext command to optionally include the
1060        GDAL extension.
1061        """
1062    
1063        user_options = build_ext.user_options[:]
1064        user_options.extend([("with-gdal", None, "Include GDAL support."),
1065                             ("without-gdal", None, "Don't include GDAL support.")])
1066    
1067        boolean_options = ["with-gdal"]
1068        negative_opt = {'without-gdal' : 'with-gdal'}
1069    
1070        def initialize_options(self):
1071            self.with_gdal = True
1072            build_ext.initialize_options(self)
1073    
1074        def finalize_options(self):
1075            build_ext.finalize_options(self)
1076            if self.with_gdal and include_gdal:
1077                self.extensions.append(Extension("Lib.gdalwarp",
1078                                    [ext_dir + "/thuban/gdalwarp.cpp",
1079                                    ext_dir + "/thuban/cpl_mfile.cpp",
1080                                    ext_dir + "/thuban/bmpdataset.cpp"],
1081                                    include_dirs = gdal_cs_params[CS_INCDIRS] +
1082                                                   [ext_dir + "/thuban/"],
1083                                    define_macros = gdal_cs_params[CS_DEFS],
1084                                    library_dirs = gdal_cs_params[CS_LIBDIRS],
1085                                    libraries = gdal_cs_params[CS_LIBS]))
1086    
1087        def run(self, install_options = None):
1088            build_ext.run(self)
1089    
1090  #  #
1091  #   Run the script  #   Run the script
1092  #  #
1093    
   
1094  long_description = """\  long_description = """\
1095  Thuban is a viewer for geographic data written in Python  Thuban is a viewer for geographic data written in Python
1096  """  """
1097    
1098  setup(name = "Thuban",  setup(name = "Thuban",
1099        version = "0.1.2",        version = "0.8.0",
1100        description = "Geographic data viewer",        description = "Geographic data viewer",
1101        long_description = long_description,        long_description = long_description,
1102        licence = "GPL",        licence = "GPL",
1103        author = "Intevation GmbH",        author = "Intevation GmbH",
1104        author_email = "[email protected]",        author_email = "[email protected]",
1105        url = "ftp:intevation.de/",        url = "http://thuban.intevation.de/",
1106    
1107        scripts = ["thuban.py"],        scripts = ["thuban.py"],
1108        packages = ["Thuban", "Thuban.Lib", "Thuban.Model", "Thuban.UI"],        packages = ["Thuban", "Thuban.Lib", "Thuban.Model", "Thuban.UI"],
# Line 898  setup(name = "Thuban", Line 1138  setup(name = "Thuban",
1138                    "install": ThubanInstall,                    "install": ThubanInstall,
1139                    "bdist_rpm": thuban_bdist_rpm,                    "bdist_rpm": thuban_bdist_rpm,
1140                    "bdist_inno": thuban_bdist_inno,                    "bdist_inno": thuban_bdist_inno,
1141                    "data_dist": data_dist                    "data_dist": data_dist,
1142                      "build_docs": thuban_build_docs,
1143                      "build_ext": thuban_build_ext
1144                    })                    })
1145    
1146    

Legend:
Removed from v.203  
changed lines
  Added in v.1291

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26