/[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 204 by bh, Tue Jul 9 14:02:27 2002 UTC revision 2651 by bh, Tue Jul 5 20:24:50 2005 UTC
# Line 1  Line 1 
1  # Copyright (c) 2001, 2002 by Intevation GmbH  # Copyright (c) 2001, 2002, 2003, 2004, 2005 by Intevation GmbH
2  # Authors:  # Authors:
3  # Bernhard Herzog <[email protected]>  # Bernhard Herzog <[email protected]>
4  #  #
# Line 15  __version__ = "$Revision$" Line 15  __version__ = "$Revision$"
15  # hand below.  # hand below.
16  #  #
17    
18    import sys
19  import os  import os
20  from types import TupleType  from types import TupleType
21    import glob
22  from distutils.core import setup, Extension, Command  from distutils.core import setup, Extension, Command
23  from distutils.command.install import install, INSTALL_SCHEMES, subst_vars  from distutils.command.install import install, INSTALL_SCHEMES, subst_vars
24  from distutils.command.build_py import build_py  from distutils.command.build_py import build_py
25  from distutils.command.bdist_rpm import bdist_rpm  from distutils.command.bdist_rpm import bdist_rpm
26    from distutils.command.build_ext import build_ext
27  from distutils.file_util import write_file  from distutils.file_util import write_file
28  from distutils.filelist import FileList  from distutils.filelist import FileList
29  from distutils.util import convert_path, change_root  from distutils.util import convert_path, change_root
# Line 31  import distutils Line 34  import distutils
34  from string import split  from string import split
35  import string  import string
36    
37    # config script parameter list indices
38    CS_DEFS, CS_INCDIRS, CS_LIBDIRS, CS_LIBS, CS_NUM_PARAMS = range(5)
39    
40    # support for gdal is on by default, but under posix we try to
41    # detect it anyway. Set this to False to disable GDAL.
42    include_gdal = True
43    
44  if os.name == "posix":  if os.name == "posix":
45      ###################################################################      ###################################################################
46      # 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 53  if os.name == "posix":
53      proj4_lib = "proj"      proj4_lib = "proj"
54    
55    
56      # You shpuldn't have to modify anything below here      # You shouldn't have to modify anything below here
57      ###################################################################      ###################################################################
58            
59      # 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 61  if os.name == "posix":
61      # with the install command's --prefix option.      # with the install command's --prefix option.
62      #      #
63      # Note that there's a separate prefix option for the bdist_rpm      # Note that there's a separate prefix option for the bdist_rpm
64      # command completely independend of this one.      # command completely independent of this one.
65      prefix = "/usr/local/"      prefix = "/usr/local/"
66    
67        # Whether to create the thubaninit module. You can override this
68        # value on the commandline with the --create-init-module to the
69        # install command.
70        create_init_module = 1
71    
72      # On POSIX-systems we run wxgtk-config to determine the C++-compiler      # On POSIX-systems we run wxgtk-config to determine the C++-compiler
73      # flags      # flags
74      wx_config_script = "wx-config"      wx_config_script = "wx-config"
75      # These lists will be filled automatically below      # These lists will be filled automatically below
76      wx_defs = []      wx_cs_params = [[] for i in range(CS_NUM_PARAMS)]
77      wx_incdirs = []  
78      wx_libdirs = []      gdal_config_script = "gdal-config"
79      wx_libs = []      gdal_cs_params = [[] for i in range(CS_NUM_PARAMS)]
80    
81  elif os.name == "nt":  elif os.name == "nt":
82      #################################################################      #################################################################
83      # Windows configuration.      # Windows configuration.
84      #      #
85        
86        basedir = os.path.dirname(sys.argv[0])
87    
88      # Directories where Proj4 is installed      # Directories where Proj4 is installed
89      proj4_prefix = r"D:\cygwin\home\user\proj-4.4.3\src"      proj4_prefix = os.path.join(basedir, "..", "proj-4.4.7", "src")
90      proj4_incdir =  proj4_prefix      proj4_incdir =  proj4_prefix
91      proj4_libdir =  proj4_prefix      proj4_libdir =  proj4_prefix
92      proj4_lib = "proj_i"      proj4_lib = "proj_i"
93    
94      # Define include and lib directories for wxWindows and      # Define include and lib directories for wxWindows and
95      wx_prefix = r"D:\wx230"      wx_prefix = os.path.join(basedir, "..", "wxPython-2.4.2.4")
96      wx_inc =  os.path.join(wx_prefix, "include")      wx_inc = [os.path.join(wx_prefix, 'lib', 'mswdllh'),
97      wx_lib =  os.path.join(wx_prefix, "lib")                os.path.join(wx_prefix, "include")]
98        wx_lib = [os.path.join(wx_prefix, "lib")]
99    
100        # Define include and lib directories for GDAL
101        gdal_prefix = os.path.join(basedir, "..", "gdal-1.1.8")
102        gdal_inc = [os.path.join(gdal_prefix, 'alg'),
103                    os.path.join(gdal_prefix, 'ogr'),
104                    os.path.join(gdal_prefix, 'port'),
105                    os.path.join(gdal_prefix, 'core')]
106        gdal_lib = [gdal_prefix]
107    
108      #      #
109      # 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
110      # shouldn't have to modify anything below here      # shouldn't have to modify anything below here
111      ##################################################################      ##################################################################
112            
# Line 89  elif os.name == "nt": Line 115  elif os.name == "nt":
115      # the command line with the install command's --prefix option      # the command line with the install command's --prefix option
116      prefix = r"install"      prefix = r"install"
117    
118        # Whether to create the thubaninit module. You can override this
119        # value on the commandline with the --create-init-module to the
120        # install command. By default we don't create it under NT because we
121        # most often run install only as part of bdist_inno where we can't
122        # really create because it needs information only known at install
123        # time.
124        create_init_module = 0
125    
126      # 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
127      # flags, so we define them here. These flags work for us with      # flags, so we define them here. These flags work for us with
128      # 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 130  elif os.name == "nt":
130      # there's no config script.      # there's no config script.
131      wx_config_script = ""      wx_config_script = ""
132            
133        wx_cs_params = [[] for i in range(CS_NUM_PARAMS)]
134    
135      # the values of wx_defs and wx_libs. copied from the wxPython      # the values of wx_defs and wx_libs. copied from the wxPython
136      # setup.py      # setup.py
137      wx_defs = [ ('WIN32', None),        # Some of these are no longer      wx_cs_params[CS_DEFS] = \
138                  [ ('WIN32', None),        # Some of these are no longer
139                  ('__WIN32__', None),    # necessary.  Anybody know which?                  ('__WIN32__', None),    # necessary.  Anybody know which?
140                  ('_WINDOWS', None),                  ('_WINDOWS', None),
141                  ('__WINDOWS__', None),                  ('__WINDOWS__', None),
# Line 114  elif os.name == "nt": Line 151  elif os.name == "nt":
151                  ('WXP_USE_THREAD', '1'),                  ('WXP_USE_THREAD', '1'),
152                  ]                  ]
153            
154      wx_incdirs = [wx_inc]      wx_cs_params[CS_INCDIRS] = wx_inc
155      wx_libdirs = [wx_lib]      wx_cs_params[CS_LIBDIRS] = wx_lib
156      wx_libs = ["wx23_1h"]      wx_cs_params[CS_LIBS] = ["wxmsw24h"] \
157      wx_libs = wx_libs + ['kernel32', 'user32', 'gdi32', 'comdlg32',                        + ['kernel32', 'user32', 'gdi32', 'comdlg32',
158                           'winspool', 'winmm', 'shell32', 'oldnames',                           'winspool', 'winmm', 'shell32', 'oldnames',
159                           'comctl32', 'ctl3d32', 'odbc32', 'ole32', 'oleaut32',                           'comctl32', 'ctl3d32', 'odbc32', 'ole32', 'oleaut32',
160                           'uuid', 'rpcrt4', 'advapi32', 'wsock32']                           'uuid', 'rpcrt4', 'advapi32', 'wsock32']
161    
162        gdal_config_script = ""
163        gdal_cs_params = [[] for i in range(CS_NUM_PARAMS)]
164    
165        gdal_cs_params[CS_INCDIRS] = gdal_inc
166        gdal_cs_params[CS_LIBDIRS] = gdal_lib
167        gdal_cs_params[CS_LIBS] = ["gdal_i"]
168    
169  else:  else:
170      raise RuntimeError("Unsupported platform " + os.name)      raise RuntimeError("Unsupported platform " + os.name)
171    
# Line 147  def run_script(cmdline): Line 192  def run_script(cmdline):
192      return result      return result
193    
194    
195  def run_wx_script(command):  def run_cs_script(command, store):
196      # first, determine the C++ preprocessor flags Use --cflags here      # first, determine the C++ preprocessor flags Use --cflags here
197      # because it seems that older version don't have --cxxflags and      # because it seems that older version don't have --cxxflags and
198      # newer ones return the same result for both      # newer ones return the same result for both
199      flags = run_script(command + ' --cflags ')      flags = run_script(command + ' --cflags ')
200      if flags is None:      if flags is None:
201          return 0          return False
202      for flag in split(flags):      for flag in split(flags):
203          start = flag[:2]          start = flag[:2]
204          value = flag[2:]          value = flag[2:]
205          if start == "-I":          if start == "-I":
206              wx_incdirs.append(value)              store[CS_INCDIRS].append(value)
207          elif start == "-D":          elif start == "-D":
208              wx_defs.append((value, None))              store[CS_DEFS].append((value, None))
209    
210      # determine the library flags      # determine the library flags
211      flags = run_script(command + ' --libs')      flags = run_script(command + ' --libs')
212      if flags is None:      if flags is None:
213          return 0          return False
214      for flag in split(flags):      for flag in split(flags):
215          start = flag[:2]          start = flag[:2]
216          value = flag[2:]          value = flag[2:]
217          if start == "-L":          if start == "-L":
218              wx_libdirs.append(value)              store[CS_LIBDIRS].append(value)
219          elif start == "-l":          elif start == "-l":
220              wx_libs.append(value)              store[CS_LIBS].append(value)
221    
222        return True
223    
224  if wx_config_script:  if wx_config_script:
225      # 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
226      run_wx_script(wx_config_script)      run_cs_script(wx_config_script, wx_cs_params)
       
227    
228    if gdal_config_script:
229        # if there's a gdal config script, run it to determine the configuration
230        include_gdal = include_gdal \
231                       and run_cs_script(gdal_config_script, gdal_cs_params)
232    
233  #  #
234  # Define some extension and python modules  # Define some extension and python modules
235  #  #
236  # The C-extension names are prefixed woth "Lib." so they get put into  # The C-extension names are prefixed with "Lib." so they get put into
237  # the Lib/ subdirectory. Lib/ is not really a package but distutils  # the Lib/ subdirectory. Lib/ is not really a package but distutils
238  # doesn't care  # doesn't care
239    
240  # subdirectory containing the extensions  # subdirectory containing the distutil extensions
241  ext_dir = "extensions"  ext_dir = "libraries"
242    
243  # subdirectory with some shapelib files  # subdirectory with some shapelib files
244  shp_dir = ext_dir + "/shapelib"  shp_dir = ext_dir + "/shapelib"
# Line 202  py_modules = [] Line 252  py_modules = []
252  # Thuban specific modules  # Thuban specific modules
253  #  #
254    
255  extensions.append(Extension("Lib.wxproj",  wxproj_extension = Extension("Lib.wxproj",
256                              [ext_dir + "/thuban/wxproj.cpp"],                               [ext_dir + "/thuban/wxproj.cpp"],
257                              include_dirs = ([shp_dir, proj4_incdir,                               include_dirs = ([shp_dir, proj4_incdir,
258                                               ext_dir + "/pyshapelib/"]                                                ext_dir + "/pyshapelib/"]
259                                              + wx_incdirs),                                               + wx_cs_params[CS_INCDIRS]),
260                              define_macros = wx_defs,                               define_macros = wx_cs_params[CS_DEFS],
261                              library_dirs = [proj4_libdir] + wx_libdirs,                               library_dirs = [proj4_libdir] +
262                              libraries = [proj4_lib] + wx_libs))                               wx_cs_params[CS_LIBDIRS],
263                                 libraries = [proj4_lib] + wx_cs_params[CS_LIBS])
264    extensions.append(wxproj_extension)
265    
266    
267  #  #
268  # shapelib wrappers are also distributed with thuban  # shapelib wrappers are also distributed with thuban
# Line 226  extensions.append(Extension("Lib.shptree Line 279  extensions.append(Extension("Lib.shptree
279  extensions.append(Extension("Lib.dbflibc",  extensions.append(Extension("Lib.dbflibc",
280                              [ext_dir + "/pyshapelib/dbflib_wrap.c",                              [ext_dir + "/pyshapelib/dbflib_wrap.c",
281                               shp_dir + "/dbfopen.c"],                               shp_dir + "/dbfopen.c"],
282                              include_dirs = [shp_dir]))                              include_dirs = [shp_dir],
283                                define_macros = [("HAVE_UPDATE_HEADER", "1")]))
284  for name in ("shapelib", "dbflib"):  for name in ("shapelib", "dbflib"):
285      py_modules.append(ext_dir + "/pyshapelib/" + name)      py_modules.append(ext_dir + "/pyshapelib/" + name)
286    
# Line 247  py_modules.append(ext_dir + "/pyprojecti Line 301  py_modules.append(ext_dir + "/pyprojecti
301    
302  data_files = []  data_files = []
303    
304  # bitmaps  # Resources
305  dir = "Resources/Bitmaps"  for d, patterns in [("Resources/Bitmaps",
306  bitmaps = []                      ("Resources/Bitmaps/*.xpm",)),
307  for file in os.listdir(os.path.join("Resources", "Bitmaps")):                     ("Resources/Projections",
308      if string.lower(file[-4:]) == ".xpm":                      ("Resources/Projections/*.proj",)),
309          bitmaps.append(dir + '/' +  file)                     ("Resources/XML",
310  data_files.append((dir, bitmaps))                      ("Resources/XML/*.dtd",)),
311                       ("Extensions/importAPR/samples",
312                        ("Extensions/importAPR/samples/README",
313                         "Extensions/importAPR/samples/*.apr")),
314                       ]:
315        for pattern in patterns:
316            data_files.append((d, glob.glob(pattern)))
317    if os.path.isdir("Resources/Locale"):
318        for d in os.listdir("Resources/Locale"):
319            data_files.append(("Resources/Locale/" + d +"/LC_MESSAGES",
320                               ["Resources/Locale/"+ d +"/LC_MESSAGES/thuban.mo"]))
321    
322  #  #
323  #       Command definitions  #       Command definitions
# Line 404  class InstallLocal(Command): Line 468  class InstallLocal(Command):
468    
469      user_options = [      user_options = [
470          ('skip-build', None, "skip the build steps"),          ('skip-build', None, "skip the build steps"),
471            ('create-init-module', None,
472             "Create the thubaninit.py module to ease use of Thuban as a library"),
473            ('dont-create-init-module', None,
474             "Do not create the thubaninit.py module"),
475          ]          ]
476    
477        boolean_options = ["create-init-module"]
478        negative_opt = {'dont-create-init-module' : 'create-init-module'}
479    
480    
481      def initialize_options (self):      def initialize_options (self):
482          self.extensions = None          self.extensions = None
483          self.build_dir = None          self.build_dir = None
484          self.skip_build = None          self.skip_build = None
485            self.create_init_module = None
486    
487      def finalize_options (self):      def finalize_options (self):
488          self.set_undefined_options("install",          self.set_undefined_options("install",
489                                     ("build_lib", "build_dir"),                                     ("build_lib", "build_dir"),
490                                     ('skip_build', 'skip_build'))                                     ('skip_build', 'skip_build'))
491          self.extensions = self.distribution.ext_modules          self.extensions = self.distribution.ext_modules
492            if self.create_init_module is None:
493                # by default we create the init module
494                self.create_init_module = 1
495    
496      def run(self):      def run(self):
497          # Make sure we have built everything we need first          # Make sure we have built everything we need first
# Line 429  class InstallLocal(Command): Line 505  class InstallLocal(Command):
505          else:          else:
506              self.copy_tree(libdir, "Lib")              self.copy_tree(libdir, "Lib")
507    
508            # create the init module if desired
509            if self.create_init_module:
510                # create the init module
511                initfilename = "thubaninit.py"
512                contents = thubaninit_contents("")
513                self.execute(write_file, (initfilename, contents),
514                             "Create %s" % initfilename)
515    
516      def link_dir(self, src, dest):      def link_dir(self, src, dest):
517          """Create a symbolic link dest pointing to src"""          """Create a symbolic link dest pointing to src"""
518          if self.verbose:          if self.verbose:
# Line 455  class thuban_build_py(build_py): Line 539  class thuban_build_py(build_py):
539      distribution.      distribution.
540      """      """
541    
542        # FIXME: When Thuban can rely on Python 2.3 as the oldest supported
543        # Python release we don't need to override the run and
544        # find_all_modules methods anymore. distutils will allow both python
545        # modules and packages starting with 2.3.
546    
547      def run(self):      def run(self):
548          """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
549          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 595  class thuban_build_py(build_py):
595          return modules          return modules
596    
597    
598  thubaninit_contents = """  thubaninit_contents_start = """
599  # This module was automatically generated by Thuban's install script  # This module was automatically generated by Thuban's install script
600  '''Import this module once per program (best place is probably the file  '''Import this module once per program (best place is probably the file
601  that ends up as your __main__ module) to be able to import Thuban  that ends up as your __main__ module) to be able to import Thuban
# Line 518  import thubaninit Line 607  import thubaninit
607  import Thuban  import Thuban
608  '''  '''
609  import sys, os  import sys, os
610  sys.path.insert(0, %(thubandir)s)  """
611    
612    thubaninit_contents_thubaninitdir = """
613    sys.path.insert(0, %(thubandir)s)
614    """
615    thubaninit_contents_otherdirs = """
616  # Put the Lib dir into the path. The Lib dir contains some extra Python  # Put the Lib dir into the path. The Lib dir contains some extra Python
617  # modules  # modules
618  import Thuban  import Thuban
# Line 529  if os.path.isdir(dir): Line 622  if os.path.isdir(dir):
622      sys.path.insert(0, dir)      sys.path.insert(0, dir)
623  """  """
624    
625    def thubaninit_contents(thubandir):
626        """Return the contents of the the thubaninit file as a list of lines.
627    
628        The parameter thubandir is the parent directory where the Thuban/
629        package or the empty string if the thubaninit file itself will be
630        located in that direcory as well.
631        """
632        contents = thubaninit_contents_start
633        if thubandir:
634            thubandir = repr(thubandir)
635            contents += thubaninit_contents_thubaninitdir % locals()
636        contents += thubaninit_contents_otherdirs
637        return contents.split("\n")
638    
639    
640  class ThubanInstall(install):  class ThubanInstall(install):
641    
# Line 547  class ThubanInstall(install): Line 654  class ThubanInstall(install):
654                           ("extra-files", None,                           ("extra-files", None,
655                            "List of filenames or (src, dest) pairs describing"                            "List of filenames or (src, dest) pairs describing"
656                            " extra files to install "                            " extra files to install "
657                            "(can only be set from witin setup.py"),                            "(can only be set from within setup.py"),
658    
659                           ("create-init-module", None,                           ("create-init-module=", None,
660                            "Create a module in the site-packages directory that"                            "If true, create a module in the site-packages"
661                            " tweaks sys.path to let you easily import thuban"                            " directory that tweaks sys.path to let you easily"
662                            " modules from outside of thuban."),                            " import thuban modules from outside of thuban."),
663                           ("init-module-dir", None,                           ("init-module-dir=", None,
664                            "Directory in which to create the init module."                            "Directory in which to create the init module."
665                            " Defaults to Python's site-packages directory."),                            " Defaults to Python's site-packages directory."),
                           
666                           ])                           ])
667    
668      boolean_options = install.boolean_options[:]      boolean_options = install.boolean_options[:]
# Line 566  class ThubanInstall(install): Line 672  class ThubanInstall(install):
672      def initialize_options(self):      def initialize_options(self):
673          self.do_symlink = None          self.do_symlink = None
674          self.extra_files = []          self.extra_files = []
675          self.create_init_module = 1  
676            # initialize the create_init_module flag from the global
677            # determined at runtime
678            self.create_init_module = create_init_module
679          self.init_module_dir = None          self.init_module_dir = None
680          install.initialize_options(self)          install.initialize_options(self)
681    
# Line 618  class ThubanInstall(install): Line 727  class ThubanInstall(install):
727                  src, dest = item                  src, dest = item
728              else:              else:
729                  src = dest = item                  src = dest = item
730              self.copy_file(convert_path(src),              self.copy_file(convert_path(src),
731                             os.path.join(self.root, convert_path(dest)))                             os.path.join(self.root, convert_path(dest)))
732    
733          if os.name == "posix" and self.do_symlink:          if os.name == "posix" and self.do_symlink:
# Line 638  class ThubanInstall(install): Line 747  class ThubanInstall(install):
747              initfilename = self.thuban_init_filename()              initfilename = self.thuban_init_filename()
748              if self.root:              if self.root:
749                  initfilename = change_root(self.root, initfilename)                  initfilename = change_root(self.root, initfilename)
750              contents = thubaninit_contents % {              contents = thubaninit_contents(self.install_lib_orig)
                 "thubandir": repr(self.install_lib_orig)  
                 }  
751              self.mkpath(os.path.dirname(initfilename))              self.mkpath(os.path.dirname(initfilename))
752              self.execute(write_file, (initfilename, split(contents, "\n")),              self.execute(write_file, (initfilename, contents),
753                           "Create %s" % initfilename)                           "Create %s" % initfilename)
754    
755      def link_file(self, src, dest):      def link_file(self, src, dest):
# Line 692  class ThubanInstall(install): Line 799  class ThubanInstall(install):
799    
800  bdist_rpm_prep_script = '''  bdist_rpm_prep_script = '''
801  %setup  %setup
802  cp extensions/pyshapelib/{README,README.pyshapelib}  cp libraries/pyshapelib/{README,README.pyshapelib}
803  cp extensions/pyshapelib/{COPYING,COPYING.pyshapelib}  cp libraries/pyshapelib/{COPYING,COPYING.pyshapelib}
804  cp extensions/pyprojection/{LICENSE,LICENSE.pyprojection}  cp libraries/pyprojection/{LICENSE,LICENSE.pyprojection}
805    '''
806    
807    bdist_rpm_build_script = '''
808    env PATH="$PATH:%(prefix)s/lib/wxPython/bin:/usr/lib/wxPython/bin" CFLAGS="$RPM_OPT_FLAGS" %(python)s setup.py build
809  '''  '''
810    
811  bdist_rpm_install_script = '''  bdist_rpm_install_script = '''
# Line 702  bdist_rpm_install_script = ''' Line 813  bdist_rpm_install_script = '''
813     --prefix=%(prefix)s     --prefix=%(prefix)s
814  '''  '''
815    
816        
817  class thuban_bdist_rpm(bdist_rpm):  class thuban_bdist_rpm(bdist_rpm):
818    
819      """Thuban specific RPM distribution command"""      """Thuban specific RPM distribution command"""
# Line 720  class thuban_bdist_rpm(bdist_rpm): Line 831  class thuban_bdist_rpm(bdist_rpm):
831          # scripts such as the python interpreter to use are only known          # scripts such as the python interpreter to use are only known
832          # then.          # then.
833          open("bdist_rpm_prep", "w").close()          open("bdist_rpm_prep", "w").close()
834            open("bdist_rpm_build", "w").close()
835          open("bdist_rpm_install", "w").close()          open("bdist_rpm_install", "w").close()
836          bdist_rpm.initialize_options(self)          bdist_rpm.initialize_options(self)
837    
# Line 727  class thuban_bdist_rpm(bdist_rpm): Line 839  class thuban_bdist_rpm(bdist_rpm):
839          # create the scripts for the spec-file. Now we know the python          # create the scripts for the spec-file. Now we know the python
840          # interpreter to use.          # interpreter to use.
841          open("bdist_rpm_prep", "w").write(bdist_rpm_prep_script)          open("bdist_rpm_prep", "w").write(bdist_rpm_prep_script)
842    
843            build = bdist_rpm_build_script % {"python": self.python,
844                                              "prefix": self.prefix}
845            open("bdist_rpm_build", "w").write(build)
846    
847          install = bdist_rpm_install_script % {"python": self.python,          install = bdist_rpm_install_script % {"python": self.python,
848                                                "prefix": self.prefix}                                                "prefix": self.prefix}
849          open("bdist_rpm_install", "w").write(install)          open("bdist_rpm_install", "w").write(install)
# Line 814  class bdist_inno(Command): Line 931  class bdist_inno(Command):
931          """Execute the command. install_options if given, should be a          """Execute the command. install_options if given, should be a
932          directory of additional options to set in the install step"""          directory of additional options to set in the install step"""
933          # Obviously have to build before we can install          # Obviously have to build before we can install
934    
935          if not self.skip_build:          if not self.skip_build:
936              self.run_command('build')              self.run_command('build')
937    
# Line 836  class bdist_inno(Command): Line 954  class bdist_inno(Command):
954          self.execute(write_file, (iss_file, self.generate_iss()),          self.execute(write_file, (iss_file, self.generate_iss()),
955                       "Create Inno Setup script file %s" % iss_file)                       "Create Inno Setup script file %s" % iss_file)
956    
957          # and invoke          # and invoke
958          if self.run_inno:          if self.run_inno:
959              self.spawn(["iscc", iss_file])              self.spawn(["iscc", iss_file])
960    
# Line 902  class bdist_inno(Command): Line 1020  class bdist_inno(Command):
1020              line = 'Name: "{group}\\%s"; Filename: "%s";' \              line = 'Name: "{group}\\%s"; Filename: "%s";' \
1021                     % (icon.title, icon.install_name)                     % (icon.title, icon.install_name)
1022              iss.append(line)              iss.append(line)
1023                
1024          return iss          return iss
1025    
1026    
# Line 918  class InnoIconItem: Line 1036  class InnoIconItem:
1036          else:          else:
1037              self.install_name = filename              self.install_name = filename
1038    
1039                
1040  class thuban_bdist_inno(bdist_inno):  class thuban_bdist_inno(bdist_inno):
1041    
1042      """Thuban specific Inno Setup stuff"""      """Thuban specific Inno Setup stuff"""
# Line 926  class thuban_bdist_inno(bdist_inno): Line 1044  class thuban_bdist_inno(bdist_inno):
1044      def run(self):      def run(self):
1045          install_options = {          install_options = {
1046              "prefix": ".",              "prefix": ".",
1047                "install_lib": "$base",
1048                "install_data": "$base",
1049              "install_scripts": "$base",              "install_scripts": "$base",
1050              "warn_dir": 0,              "warn_dir": 0,
1051              "extra_files": ["COPYING", "Lib/proj.dll"],              "extra_files": ["COPYING", "Lib/proj.dll"],
# Line 933  class thuban_bdist_inno(bdist_inno): Line 1053  class thuban_bdist_inno(bdist_inno):
1053          # don't make a symlink because we're simulating windows, so          # don't make a symlink because we're simulating windows, so
1054          # that we can generate the iss-file even on Linux          # that we can generate the iss-file even on Linux
1055          install_options["do_symlink"] = 0          install_options["do_symlink"] = 0
1056    
1057          bdist_inno.run(self, install_options)          bdist_inno.run(self, install_options)
1058        
1059                class thuban_build_docs(Command):
1060    
1061        """Command to generate documentation from source code."""
1062    
1063        description = "Generate documentation."
1064    
1065        user_options = []
1066    
1067        def initialize_options(self): pass
1068    
1069        def finalize_options(self): pass
1070    
1071        def run(self, install_options = None):
1072            self.spawn(["happydoc", "-d./Doc", "./Thuban"])
1073    
1074    class thuban_build_ext(build_ext):
1075    
1076        """Extend the build_ext command with some Thuban specific options
1077    
1078        --with-gdal, --without-gdal
1079    
1080            Switch the optional GDAL support on/off.  Default is On.
1081    
1082        --use-wx-python-swig-hack
1083    
1084            For performance reasons, Thuban access wxPython objects at the
1085            C++ level so that it can directly call wxWidgets code from C++.
1086            The normal and preferred way to do that is to use the API
1087            defined in wxPython.h.  Unfortunately, this header file is not
1088            distributed with binary packages of wxPython on some platforms.
1089            By using the --use-wx-python-swig-hack option you can activate a
1090            way to access the C++ objects without wxPython.h.  This relies
1091            on internals of SWIG, so it might change with future wxPython
1092            versions.  Therefore, only use this option if the normal way
1093            doesn't work for you.
1094        """
1095    
1096        user_options = build_ext.user_options[:]
1097        user_options.extend([("with-gdal", None, "Include GDAL support."),
1098                             ("without-gdal", None, "Don't include GDAL support."),
1099                             ("use-wx-python-swig-hack", None,
1100                     "Use a hack to access wxPython objects at the C++ level"
1101                     "(use only when you absolutely can't use wxPython.h)")])
1102    
1103        boolean_options = ["with-gdal", "use-wx-python-swig-hack"]
1104        negative_opt = {'without-gdal' : 'with-gdal'}
1105    
1106        def initialize_options(self):
1107            self.with_gdal = True
1108            self.use_wx_python_swig_hack = False
1109            build_ext.initialize_options(self)
1110    
1111        def finalize_options(self):
1112            build_ext.finalize_options(self)
1113            if self.with_gdal and include_gdal:
1114                self.extensions.append(Extension("Lib.gdalwarp",
1115                                    [ext_dir + "/thuban/gdalwarp.cpp"],
1116                                    include_dirs = gdal_cs_params[CS_INCDIRS] +
1117                                                   [ext_dir + "/thuban/"],
1118                                    define_macros = gdal_cs_params[CS_DEFS],
1119                                    library_dirs = gdal_cs_params[CS_LIBDIRS],
1120                                    libraries = gdal_cs_params[CS_LIBS]))
1121            if self.use_wx_python_swig_hack:
1122                wxproj_extension.define_macros.append(("USE_WX_PYTHON_SWIG_HACK",
1123                                                       None))
1124    
1125        def run(self, install_options = None):
1126            build_ext.run(self)
1127    
1128  #  #
1129  #   Run the script  #   Run the script
1130  #  #
1131    
   
1132  long_description = """\  long_description = """\
1133  Thuban is a viewer for geographic data written in Python  Thuban is a viewer for geographic data written in Python
1134  """  """
1135    
1136  setup(name = "Thuban",  setup(name = "Thuban",
1137        version = "0.1.2",        version = "1.1.0",
1138        description = "Geographic data viewer",        description = "Geographic data viewer",
1139        long_description = long_description,        long_description = long_description,
1140        licence = "GPL",        license = "GPL",
1141        author = "Intevation GmbH",        author = "Intevation GmbH",
1142        author_email = "[email protected]",        author_email = "[email protected]",
1143        url = "ftp:intevation.de/",        url = "http://thuban.intevation.de/",
1144    
1145        scripts = ["thuban.py"],        scripts = ["thuban.py"],
1146        packages = ["Thuban", "Thuban.Lib", "Thuban.Model", "Thuban.UI"],        packages = ["Thuban", "Thuban.Lib", "Thuban.Model", "Thuban.UI",
1147                      "Extensions", "Extensions.gns2shp", "Extensions.wms",
1148                      "Extensions.importAPR", "Extensions.profiling"],
1149        ext_modules = extensions,        ext_modules = extensions,
1150        py_modules = py_modules,        py_modules = py_modules,
1151        data_files = data_files,        data_files = data_files,
# Line 988  setup(name = "Thuban", Line 1178  setup(name = "Thuban",
1178                    "install": ThubanInstall,                    "install": ThubanInstall,
1179                    "bdist_rpm": thuban_bdist_rpm,                    "bdist_rpm": thuban_bdist_rpm,
1180                    "bdist_inno": thuban_bdist_inno,                    "bdist_inno": thuban_bdist_inno,
1181                    "data_dist": data_dist                    "data_dist": data_dist,
1182                      "build_docs": thuban_build_docs,
1183                      "build_ext": thuban_build_ext
1184                    })                    })
1185    
1186    

Legend:
Removed from v.204  
changed lines
  Added in v.2651

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26