/[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 671 by bh, Tue Apr 15 18:09:47 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, INSTALL_SCHEMES, subst_vars  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
# Line 43  if os.name == "posix": Line 44  if os.name == "posix":
44      proj4_lib = "proj"      proj4_lib = "proj"
45    
46    
47      # You shpuldn't have to modify anything below here      # You shouldn't have to modify anything below here
48      ###################################################################      ###################################################################
49            
50      # The installation prefix (similar to autoconf's --prefix). This is      # The installation prefix (similar to autoconf's --prefix). This is
# Line 54  if os.name == "posix": Line 55  if os.name == "posix":
55      # command completely independend of this one.      # command completely independend of this one.
56      prefix = "/usr/local/"      prefix = "/usr/local/"
57    
58        # Whether to create the thubaninit module. You can override this
59        # value on the commandline with the --create-init-module to the
60        # install command.
61        create_init_module = 1
62    
63      # On POSIX-systems we run wxgtk-config to determine the C++-compiler      # On POSIX-systems we run wxgtk-config to determine the C++-compiler
64      # flags      # flags
65      wx_config_script = "wx-config"      wx_config_script = "wx-config"
# Line 75  elif os.name == "nt": Line 81  elif os.name == "nt":
81      proj4_lib = "proj_i"      proj4_lib = "proj_i"
82    
83      # Define include and lib directories for wxWindows and      # Define include and lib directories for wxWindows and
84      wx_prefix = r"D:\wx230"      wx_prefix = r"D:\wx240"
85      wx_inc =  os.path.join(wx_prefix, "include")      wx_inc = [os.path.join(wx_prefix, 'lib', 'mswdllh'),
86      wx_lib =  os.path.join(wx_prefix, "lib")                os.path.join(wx_prefix, "include")]
87        wx_lib = [os.path.join(wx_prefix, "lib")]
88    
89    
90      #      #
91      # 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
92      # shouldn't have to modify anything below here      # shouldn't have to modify anything below here
93      ##################################################################      ##################################################################
94            
# Line 89  elif os.name == "nt": Line 97  elif os.name == "nt":
97      # the command line with the install command's --prefix option      # the command line with the install command's --prefix option
98      prefix = r"install"      prefix = r"install"
99    
100        # Whether to create the thubaninit module. You can override this
101        # value on the commandline with the --create-init-module to the
102        # install command. By default we don't create it under NT because we
103        # most often run install only as part of bdist_inno where we can't
104        # really create because it needs information only known at install
105        # time.
106        create_init_module = 0
107    
108      # 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
109      # flags, so we define them here. These flags work for us with      # flags, so we define them here. These flags work for us with
110      # 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 114  elif os.name == "nt": Line 130  elif os.name == "nt":
130                  ('WXP_USE_THREAD', '1'),                  ('WXP_USE_THREAD', '1'),
131                  ]                  ]
132            
133      wx_incdirs = [wx_inc]      wx_incdirs = wx_inc
134      wx_libdirs = [wx_lib]      wx_libdirs = wx_lib
135      wx_libs = ["wx23_1h"]      wx_libs = ["wxmsw24h"]
136    
137      wx_libs = wx_libs + ['kernel32', 'user32', 'gdi32', 'comdlg32',      wx_libs = wx_libs + ['kernel32', 'user32', 'gdi32', 'comdlg32',
138                           'winspool', 'winmm', 'shell32', 'oldnames',                           'winspool', 'winmm', 'shell32', 'oldnames',
139                           'comctl32', 'ctl3d32', 'odbc32', 'ole32', 'oleaut32',                           'comctl32', 'ctl3d32', 'odbc32', 'ole32', 'oleaut32',
# Line 248  py_modules.append(ext_dir + "/pyprojecti Line 265  py_modules.append(ext_dir + "/pyprojecti
265  data_files = []  data_files = []
266    
267  # bitmaps  # bitmaps
268  dir = "Resources/Bitmaps"  for d, pattern in [("Resources/Bitmaps", "Resources/Bitmaps/*.xpm"),
269  bitmaps = []                     ("Resources/Locale", "Resources/Locale/*/LC_MESSAGES/*.mo")
270  for file in os.listdir(os.path.join("Resources", "Bitmaps")):                     ]:
271      if string.lower(file[-4:]) == ".xpm":      data_files.append((d, glob.glob(pattern)))
         bitmaps.append(dir + '/' +  file)  
 data_files.append((dir, bitmaps))  
272    
273  #  #
274  #       Command definitions  #       Command definitions
# Line 404  class InstallLocal(Command): Line 419  class InstallLocal(Command):
419    
420      user_options = [      user_options = [
421          ('skip-build', None, "skip the build steps"),          ('skip-build', None, "skip the build steps"),
422            ('create-init-module', None,
423             "Create the thubaninit.py module to ease use of Thuban as a library"),
424            ('dont-create-init-module', None,
425             "Do not create the thubaninit.py module"),
426          ]          ]
427    
428        boolean_options = ["create-init-module"]
429        negative_opt = {'dont-create-init-module' : 'create-init-module'}
430    
431    
432      def initialize_options (self):      def initialize_options (self):
433          self.extensions = None          self.extensions = None
434          self.build_dir = None          self.build_dir = None
435          self.skip_build = None          self.skip_build = None
436            self.create_init_module = None
437    
438      def finalize_options (self):      def finalize_options (self):
439          self.set_undefined_options("install",          self.set_undefined_options("install",
440                                     ("build_lib", "build_dir"),                                     ("build_lib", "build_dir"),
441                                     ('skip_build', 'skip_build'))                                     ('skip_build', 'skip_build'))
442          self.extensions = self.distribution.ext_modules          self.extensions = self.distribution.ext_modules
443            if self.create_init_module is None:
444                # by default we create the init module
445                self.create_init_module = 1
446    
447      def run(self):      def run(self):
448          # Make sure we have built everything we need first          # Make sure we have built everything we need first
# Line 429  class InstallLocal(Command): Line 456  class InstallLocal(Command):
456          else:          else:
457              self.copy_tree(libdir, "Lib")              self.copy_tree(libdir, "Lib")
458    
459            # create the init module if desired
460            if self.create_init_module:
461                # create the init module
462                initfilename = "thubaninit.py"
463                contents = thubaninit_contents("")
464                self.execute(write_file, (initfilename, contents),
465                             "Create %s" % initfilename)
466    
467      def link_dir(self, src, dest):      def link_dir(self, src, dest):
468          """Create a symbolic link dest pointing to src"""          """Create a symbolic link dest pointing to src"""
469          if self.verbose:          if self.verbose:
# Line 455  class thuban_build_py(build_py): Line 490  class thuban_build_py(build_py):
490      distribution.      distribution.
491      """      """
492    
493        # FIXME: When Thuban can rely on Python 2.3 as the oldest supported
494        # Python release we don't need to override the run and
495        # find_all_modules methods anymore. distutils will allow both python
496        # modules and packages starting with 2.3.
497    
498      def run(self):      def run(self):
499          """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
500          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 546  class thuban_build_py(build_py):
546          return modules          return modules
547    
548    
549  thubaninit_contents = """  thubaninit_contents_start = """
550  # This module was automatically generated by Thuban's install script  # This module was automatically generated by Thuban's install script
551  '''Import this module once per program (best place is probably the file  '''Import this module once per program (best place is probably the file
552  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 558  import thubaninit
558  import Thuban  import Thuban
559  '''  '''
560  import sys, os  import sys, os
561  sys.path.insert(0, %(thubandir)s)  """
562    
563    thubaninit_contents_thubaninitdir = """
564    sys.path.insert(0, %(thubandir)s)
565    """
566    thubaninit_contents_otherdirs = """
567  # 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
568  # modules  # modules
569  import Thuban  import Thuban
# Line 529  if os.path.isdir(dir): Line 573  if os.path.isdir(dir):
573      sys.path.insert(0, dir)      sys.path.insert(0, dir)
574  """  """
575    
576    def thubaninit_contents(thubandir):
577        """Return the contents of the the thubaninit file as a list of lines.
578    
579        The parameter thubandir is the parent directory where the Thuban/
580        package or the empty string if the thubaninit file itself will be
581        located in that direcory as well.
582        """
583        contents = thubaninit_contents_start
584        if thubandir:
585            thubandir = repr(thubandir)
586            contents += thubaninit_contents_thubaninitdir % locals()
587        contents += thubaninit_contents_otherdirs
588        return contents.split("\n")
589    
590    
591  class ThubanInstall(install):  class ThubanInstall(install):
592    
# Line 549  class ThubanInstall(install): Line 607  class ThubanInstall(install):
607                            " extra files to install "                            " extra files to install "
608                            "(can only be set from witin setup.py"),                            "(can only be set from witin setup.py"),
609    
610                           ("create-init-module", None,                           ("create-init-module=", None,
611                            "Create a module in the site-packages directory that"                            "If true, create a module in the site-packages"
612                            " tweaks sys.path to let you easily import thuban"                            " directory that tweaks sys.path to let you easily"
613                            " modules from outside of thuban."),                            " import thuban modules from outside of thuban."),
614                           ("init-module-dir", None,                           ("init-module-dir=", None,
615                            "Directory in which to create the init module."                            "Directory in which to create the init module."
616                            " Defaults to Python's site-packages directory."),                            " Defaults to Python's site-packages directory."),
                           
617                           ])                           ])
618    
619      boolean_options = install.boolean_options[:]      boolean_options = install.boolean_options[:]
# Line 566  class ThubanInstall(install): Line 623  class ThubanInstall(install):
623      def initialize_options(self):      def initialize_options(self):
624          self.do_symlink = None          self.do_symlink = None
625          self.extra_files = []          self.extra_files = []
626          self.create_init_module = 1  
627            # initialize the create_init_module flag from the global
628            # determined at runtime
629            self.create_init_module = create_init_module
630          self.init_module_dir = None          self.init_module_dir = None
631          install.initialize_options(self)          install.initialize_options(self)
632    
# Line 618  class ThubanInstall(install): Line 678  class ThubanInstall(install):
678                  src, dest = item                  src, dest = item
679              else:              else:
680                  src = dest = item                  src = dest = item
681              self.copy_file(convert_path(src),              self.copy_file(convert_path(src),
682                             os.path.join(self.root, convert_path(dest)))                             os.path.join(self.root, convert_path(dest)))
683    
684          if os.name == "posix" and self.do_symlink:          if os.name == "posix" and self.do_symlink:
# Line 638  class ThubanInstall(install): Line 698  class ThubanInstall(install):
698              initfilename = self.thuban_init_filename()              initfilename = self.thuban_init_filename()
699              if self.root:              if self.root:
700                  initfilename = change_root(self.root, initfilename)                  initfilename = change_root(self.root, initfilename)
701              contents = thubaninit_contents % {              contents = thubaninit_contents(self.install_lib_orig)
                 "thubandir": repr(self.install_lib_orig)  
                 }  
702              self.mkpath(os.path.dirname(initfilename))              self.mkpath(os.path.dirname(initfilename))
703              self.execute(write_file, (initfilename, split(contents, "\n")),              self.execute(write_file, (initfilename, contents),
704                           "Create %s" % initfilename)                           "Create %s" % initfilename)
705    
706      def link_file(self, src, dest):      def link_file(self, src, dest):
# Line 697  cp extensions/pyshapelib/{COPYING,COPYIN Line 755  cp extensions/pyshapelib/{COPYING,COPYIN
755  cp extensions/pyprojection/{LICENSE,LICENSE.pyprojection}  cp extensions/pyprojection/{LICENSE,LICENSE.pyprojection}
756  '''  '''
757    
758    bdist_rpm_build_script = '''
759    env PATH="$PATH:%(prefix)s/lib/wxPython/bin:/usr/lib/wxPython/bin" CFLAGS="$RPM_OPT_FLAGS" %(python)s setup.py build
760    '''
761    
762  bdist_rpm_install_script = '''  bdist_rpm_install_script = '''
763  %(python)s setup.py install --root=$RPM_BUILD_ROOT --record=INSTALLED_FILES \  %(python)s setup.py install --root=$RPM_BUILD_ROOT --record=INSTALLED_FILES \
764     --prefix=%(prefix)s     --prefix=%(prefix)s
765  '''  '''
766    
767        
768  class thuban_bdist_rpm(bdist_rpm):  class thuban_bdist_rpm(bdist_rpm):
769    
770      """Thuban specific RPM distribution command"""      """Thuban specific RPM distribution command"""
# Line 720  class thuban_bdist_rpm(bdist_rpm): Line 782  class thuban_bdist_rpm(bdist_rpm):
782          # scripts such as the python interpreter to use are only known          # scripts such as the python interpreter to use are only known
783          # then.          # then.
784          open("bdist_rpm_prep", "w").close()          open("bdist_rpm_prep", "w").close()
785            open("bdist_rpm_build", "w").close()
786          open("bdist_rpm_install", "w").close()          open("bdist_rpm_install", "w").close()
787          bdist_rpm.initialize_options(self)          bdist_rpm.initialize_options(self)
788    
# Line 727  class thuban_bdist_rpm(bdist_rpm): Line 790  class thuban_bdist_rpm(bdist_rpm):
790          # create the scripts for the spec-file. Now we know the python          # create the scripts for the spec-file. Now we know the python
791          # interpreter to use.          # interpreter to use.
792          open("bdist_rpm_prep", "w").write(bdist_rpm_prep_script)          open("bdist_rpm_prep", "w").write(bdist_rpm_prep_script)
793    
794            build = bdist_rpm_build_script % {"python": self.python,
795                                              "prefix": self.prefix}
796            open("bdist_rpm_build", "w").write(build)
797    
798          install = bdist_rpm_install_script % {"python": self.python,          install = bdist_rpm_install_script % {"python": self.python,
799                                                "prefix": self.prefix}                                                "prefix": self.prefix}
800          open("bdist_rpm_install", "w").write(install)          open("bdist_rpm_install", "w").write(install)
# Line 814  class bdist_inno(Command): Line 882  class bdist_inno(Command):
882          """Execute the command. install_options if given, should be a          """Execute the command. install_options if given, should be a
883          directory of additional options to set in the install step"""          directory of additional options to set in the install step"""
884          # Obviously have to build before we can install          # Obviously have to build before we can install
885    
886          if not self.skip_build:          if not self.skip_build:
887              self.run_command('build')              self.run_command('build')
888    
# Line 836  class bdist_inno(Command): Line 905  class bdist_inno(Command):
905          self.execute(write_file, (iss_file, self.generate_iss()),          self.execute(write_file, (iss_file, self.generate_iss()),
906                       "Create Inno Setup script file %s" % iss_file)                       "Create Inno Setup script file %s" % iss_file)
907    
908          # and invoke          # and invoke
909          if self.run_inno:          if self.run_inno:
910              self.spawn(["iscc", iss_file])              self.spawn(["iscc", iss_file])
911    
# Line 902  class bdist_inno(Command): Line 971  class bdist_inno(Command):
971              line = 'Name: "{group}\\%s"; Filename: "%s";' \              line = 'Name: "{group}\\%s"; Filename: "%s";' \
972                     % (icon.title, icon.install_name)                     % (icon.title, icon.install_name)
973              iss.append(line)              iss.append(line)
974                
975          return iss          return iss
976    
977    
# Line 918  class InnoIconItem: Line 987  class InnoIconItem:
987          else:          else:
988              self.install_name = filename              self.install_name = filename
989    
990                
991  class thuban_bdist_inno(bdist_inno):  class thuban_bdist_inno(bdist_inno):
992    
993      """Thuban specific Inno Setup stuff"""      """Thuban specific Inno Setup stuff"""
# Line 926  class thuban_bdist_inno(bdist_inno): Line 995  class thuban_bdist_inno(bdist_inno):
995      def run(self):      def run(self):
996          install_options = {          install_options = {
997              "prefix": ".",              "prefix": ".",
998                "install_lib": "$base",
999                "install_data": "$base",
1000              "install_scripts": "$base",              "install_scripts": "$base",
1001              "warn_dir": 0,              "warn_dir": 0,
1002              "extra_files": ["COPYING", "Lib/proj.dll"],              "extra_files": ["COPYING", "Lib/proj.dll"],
# Line 933  class thuban_bdist_inno(bdist_inno): Line 1004  class thuban_bdist_inno(bdist_inno):
1004          # don't make a symlink because we're simulating windows, so          # don't make a symlink because we're simulating windows, so
1005          # that we can generate the iss-file even on Linux          # that we can generate the iss-file even on Linux
1006          install_options["do_symlink"] = 0          install_options["do_symlink"] = 0
1007    
1008          bdist_inno.run(self, install_options)          bdist_inno.run(self, install_options)
1009        
1010                class thuban_build_docs(Command):
1011    
1012        """Command to generate documentation from source code."""
1013    
1014        description = "Generate documentation."
1015    
1016        user_options = []
1017    
1018        def initialize_options(self): pass
1019    
1020        def finalize_options(self): pass
1021    
1022        def run(self, install_options = None):
1023            self.spawn(["happydoc", "-d./Doc", "./Thuban"])
1024    
1025  #  #
1026  #   Run the script  #   Run the script
1027  #  #
# Line 946  Thuban is a viewer for geographic data w Line 1032  Thuban is a viewer for geographic data w
1032  """  """
1033    
1034  setup(name = "Thuban",  setup(name = "Thuban",
1035        version = "0.1.2",        version = "0.2.0",
1036        description = "Geographic data viewer",        description = "Geographic data viewer",
1037        long_description = long_description,        long_description = long_description,
1038        licence = "GPL",        licence = "GPL",
1039        author = "Intevation GmbH",        author = "Intevation GmbH",
1040        author_email = "[email protected]",        author_email = "[email protected]",
1041        url = "ftp:intevation.de/",        url = "http://thuban.intevation.de/",
1042    
1043        scripts = ["thuban.py"],        scripts = ["thuban.py"],
1044        packages = ["Thuban", "Thuban.Lib", "Thuban.Model", "Thuban.UI"],        packages = ["Thuban", "Thuban.Lib", "Thuban.Model", "Thuban.UI"],
# Line 988  setup(name = "Thuban", Line 1074  setup(name = "Thuban",
1074                    "install": ThubanInstall,                    "install": ThubanInstall,
1075                    "bdist_rpm": thuban_bdist_rpm,                    "bdist_rpm": thuban_bdist_rpm,
1076                    "bdist_inno": thuban_bdist_inno,                    "bdist_inno": thuban_bdist_inno,
1077                    "data_dist": data_dist                    "data_dist": data_dist,
1078                      "build_docs": thuban_build_docs
1079                    })                    })
1080    
1081    

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

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26