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

Legend:
Removed from v.209  
changed lines
  Added in v.555

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26