コード例 #1
0
    def install_finalize(self):
        """
    Set up dispatchers and assorted shell scripts, create app bundles, etc.
    """
        self.print_header('Finalizing %s installation' % self.product_name)
        log_path = op.join(self.tmp_dir, "install_finalize.log")
        print >> self.out, "Log file: %s" % log_path
        log = open(log_path, "w")

        # Write environment files.
        self.write_environment_files()

        # Regenerate module files.
        if (self.flag_build_gui) and (sys.platform != "darwin"):
            os.environ["LD_LIBRARY_PATH"] = "lib:%s:%s" % \
              (op.join(self.base_dir, "lib"), op.join(self.base_dir, "lib64"))
            regenerate_module_files.run(os.path.join(self.dest_dir, 'base'),
                                        out=self.out)

        # Write dispatcher_include file.
        print >> self.out, "Generating %s environment additions for dispatchers..." % \
          self.product_name
        fnsuffix = '.sh'
        envcmd = "export"
        if sys.platform == "win32":
            fnsuffix = '.bat'
            envcmd = "set"
        dispatcher = op.join(
            self.build_dir,
            "dispatcher_include_%s%s" % (self.dest_dir_prefix, fnsuffix))
        if (op.isfile(dispatcher)):
            os.remove(dispatcher)
        env_prefix = self.product_name.upper()  # e.g. "Phenix" -> "PHENIX"
        prologue = "\n".join([
            "%s %s=\"%s\"" % (envcmd, env_prefix, self.dest_dir),
            "%s %s_VERSION=%s" % (envcmd, env_prefix, self.version),
            "%s %s_ENVIRONMENT=1" % (envcmd, env_prefix),
            "%s %s_MTYPE=%s" % (envcmd, env_prefix, self.mtype),
        ] + self.product_specific_dispatcher_prologue())
        epilogue = "\n".join(self.product_specific_dispatcher_epilogue())
        dispatcher_opts = [
            "--build_dir=%s" % self.build_dir,
            "--base_dir=%s" % self.base_dir,
            "--suffix=%s" % self.dest_dir_prefix,
            "--gtk_version=2.10.0",  # XXX this can change!
            "--quiet",
        ]
        if (not self.flag_build_gui):
            dispatcher_opts.append("--ignore_missing_dirs")
        # FIXME this will happen regardless of whether the GUI modules are being
        # distributed or not - will this be problematic?
        print 'Calling write_gui_dispatcher_include'
        print '  args %s' % dispatcher_opts
        print '  prologue %s' % prologue
        print '  epilogue %s' % epilogue
        write_gui_dispatcher_include.run(args=dispatcher_opts,
                                         prologue=prologue,
                                         epilogue=epilogue,
                                         out=self.out)
        assert op.isfile(dispatcher)

        # Run configure.py to generate dispatchers
        print >> self.out, "Configuring %s components..." % self.product_name
        os.chdir(self.build_dir)
        # ???
        if (op.exists("libtbx_refresh_is_completed")):
            os.remove("libtbx_refresh_is_completed")
        self.reconfigure(log=log)
        os.chdir(self.build_dir)
        assert op.isfile("setpaths%s" % fnsuffix)
        if sys.platform != "win32":
            os.environ["PATH"] = "%s:%s" % (op.join(self.build_dir,
                                                    "bin"), os.environ["PATH"])
        else:
            os.environ["PATH"] = "%s;%s" % (op.join(self.build_dir,
                                                    "bin"), os.environ["PATH"])

        if not self.options.nopycompile:
            # Compile .py files
            print >> self.out, "Precompiling .py files..."
            os.chdir(self.modules_dir)
            call(args="libtbx.py_compile_all", log=log)

        # Copy README et al.
        for file_name in [
                "CHANGES", "LICENSE", "README", "README-DEV", "SOURCES"
        ]:
            src_file = op.join(self.installer_dir, file_name)
            if op.exists(src_file):
                dest_file = op.join(self.dest_dir, file_name)
                # XXX use our own implementation instead of shutil.copyfile
                if sys.platform == "win32" and src_file == dest_file:
                    # writing to the same file on Windows renders it empty
                    continue
                copy_file(src_file, dest_file)

        # generate .app (Mac only)
        apps_built = False
        if ((sys.platform == "darwin") and (len(self.make_apps) > 0)
                and (not self.options.no_app) and self.flag_build_gui):
            os.chdir(self.build_dir)
            for app_name in self.make_apps:
                args = [
                    "libtbx.create_mac_app", app_name,
                    "--app_name=%s-%s" % (app_name, self.version),
                    "--dest=%s" % self.dest_dir, "--alias_build"
                ]
                print >> self.out, "Generating Mac app launcher for %s..." % app_name
                try:
                    call(args=" ".join(args), log=log)
                except RuntimeError as e:
                    print "  ERROR:"
                    print "  " + str(e)
                    print "  installation will continue anyway."
                else:
                    app_file = op.join(self.dest_dir,
                                       "%s-%s.app" % (app_name, self.version))
                    if (not op.exists(app_file)):
                        print >> self.out, " failed."
                        app_file = None
                    else:
                        apps_built = True

        # run custom finalization
        self.product_specific_finalize_install(log)

        # remove source files if desired
        if (self.options.compact):
            self.reduce_installation_size()

        self.display_final_message()

        if sys.platform == "win32":
            return

        # Fix permissions
        call(['chmod', '-R', 'u+rw,a+rX', self.dest_dir])

        # Show the app.
        if apps_built and (not "SSH_CLIENT" in os.environ):
            try:
                call(args=["open", self.dest_dir], log=self.out)
            except Exception:
                # Will fail in non-interactive environments.
                pass
コード例 #2
0
 def install_finalize (self) :
   """
   Set up dispatchers and assorted shell scripts, create app bundles, etc.
   """
   out = self.out
   print >> out, ""
   print >> out, "*" * 72
   print >> out, "FINALIZING %s INSTALLATION" % self.product_name
   log_path = op.join(self.tmp_dir, "install_finalize.log")
   print >> out, "  log file is %s" % log_path
   log = open(log_path, "w")
   if (self.flag_build_gui) and (sys.platform != "darwin") :
     os.environ["LD_LIBRARY_PATH"] = op.join(self.base_dir, "lib")
     regenerate_module_files.run(args=["--build_dir=%s" % self.dest_dir],
       out=out)
   # write dispatcher_include file
   print >> out, "generating %s environment additions for dispatchers" % \
     self.product_name
   print >> out, ""
   dispatcher = op.join(self.build_dir, "dispatcher_include_%s.sh" %
     self.dest_dir_prefix)
   if (op.isfile(dispatcher)) :
     os.remove(dispatcher)
   env_prefix = self.product_name.upper() # e.g. "Phenix" -> "PHENIX"
   prologue = "\n".join([
     "export %s=\"%s\"" % (env_prefix, self.dest_dir),
     "export %s_VERSION=%s" % (env_prefix, self.version),
     "export %s_ENVIRONMENT=1" % env_prefix,
     "export %s_MTYPE=%s" % (env_prefix, self.mtype),
   ] + self.product_specific_dispatcher_prologue())
   epilogue = "\n".join(self.product_specific_dispatcher_epilogue())
   dispatcher_opts = [
     "--build_dir=%s" % self.build_dir,
     "--base_dir=%s" % self.base_dir,
     "--suffix=%s" % self.dest_dir_prefix,
     "--gtk_version=2.10.0", # XXX this can change!
     "--quiet",
   ]
   if (not self.flag_build_gui) :
     dispatcher_opts.append("--ignore_missing_dirs")
   # FIXME this will happen regardless of whether the GUI modules are being
   # distributed or not - will this be problematic?
   write_gui_dispatcher_include.run(
     args=dispatcher_opts,
     prologue=prologue,
     epilogue=epilogue,
     out=out)
   assert op.isfile(dispatcher)
   self.write_environment_files(out)
   # run configure.py to generate dispatchers
   print >> out, "configuring %s components..." % self.product_name
   os.chdir(self.build_dir)
   if (op.exists("libtbx_refresh_is_completed")) :
     os.remove("libtbx_refresh_is_completed")
   self.reconfigure(log=log)
   os.chdir(self.build_dir)
   assert op.isfile("setpaths.sh")
   bin_dir = op.join(self.build_dir, "bin")
   os.environ["PATH"] = "%s:%s" % (bin_dir, os.environ["PATH"])
   # compile .py files
   print >> out, "precompiling .py files...",
   os.chdir(self.modules_dir)
   call(args="libtbx.py_compile_all", log=log)
   print >> out, "ok"
   # copy README et al.
   for file_name in ["CHANGES","LICENSE","README","README-DEV","SOURCES"] :
     src_file = op.join(self.installer_dir, file_name)
     if op.exists(src_file) :
       # XXX use our own implementation instead of shutil.copyfile
       copy_file(src_file, op.join(self.dest_dir, file_name))
   # generate .app (Mac only)
   if ((sys.platform == "darwin") and (len(self.make_apps) > 0) and
       (not self.options.no_app) and self.flag_build_gui) :
     os.chdir(self.build_dir)
     for app_name in self.make_apps :
       args = [
         "libtbx.create_mac_app",
         app_name,
         "--app_name=%s-%s" % (app_name, self.version),
         "--dest=%s" % self.dest_dir,
       ]
       if (self.mtype == "mac-intel-osx-x86_64") :
         args.append("--alias_build")
         #args.append("--python_interpreter=/usr/bin/python")
       print >> out, ("Generating Mac app launcher for %s..." % app_name),
       try :
         call(args=" ".join(args), log=log)
       except RuntimeError, e :
         print ""
         print "  ERROR:"
         print "  " + str(e)
         print "  installation will continue anyway."
       else :
         app_file = op.join(self.dest_dir, "%s-%s.app" %
           (app_name, self.version))
         if (not op.exists(app_file)) :
           print >> out, " failed."
           app_file = None
         else :
           print >> out, "ok"
           self.apps_built = True
コード例 #3
0
    def install_finalize(self):
        """
    Set up dispatchers and assorted shell scripts, create app bundles, etc.
    """
        self.print_header('Finalizing %s installation' % self.product_name)
        log_path = op.join(self.tmp_dir, "install_finalize.log")
        print >> self.out, "Log file: %s" % log_path
        log = open(log_path, "w")

        # Write environment files.
        self.write_environment_files()

        # Regenerate module files.
        if (self.flag_build_gui) and (sys.platform != "darwin"):
            os.environ["LD_LIBRARY_PATH"] = op.join(self.base_dir, "lib")
            regenerate_module_files.run(
                args=["--build_dir=%s" % self.dest_dir], out=self.out)

        # Write dispatcher_include file.
        print >> self.out, "Generating %s environment additions for dispatchers..." % \
          self.product_name
        dispatcher = op.join(self.build_dir,
                             "dispatcher_include_%s.sh" % self.dest_dir_prefix)
        if (op.isfile(dispatcher)):
            os.remove(dispatcher)
        env_prefix = self.product_name.upper()  # e.g. "Phenix" -> "PHENIX"
        prologue = "\n".join([
            "export %s=\"%s\"" % (env_prefix, self.dest_dir),
            "export %s_VERSION=%s" % (env_prefix, self.version),
            "export %s_ENVIRONMENT=1" % env_prefix,
            "export %s_MTYPE=%s" % (env_prefix, self.mtype),
        ] + self.product_specific_dispatcher_prologue())
        epilogue = "\n".join(self.product_specific_dispatcher_epilogue())
        dispatcher_opts = [
            "--build_dir=%s" % self.build_dir,
            "--base_dir=%s" % self.base_dir,
            "--suffix=%s" % self.dest_dir_prefix,
            "--gtk_version=2.10.0",  # XXX this can change!
            "--quiet",
        ]
        if (not self.flag_build_gui):
            dispatcher_opts.append("--ignore_missing_dirs")
        # FIXME this will happen regardless of whether the GUI modules are being
        # distributed or not - will this be problematic?
        write_gui_dispatcher_include.run(args=dispatcher_opts,
                                         prologue=prologue,
                                         epilogue=epilogue,
                                         out=self.out)
        assert op.isfile(dispatcher)

        # Run configure.py to generate dispatchers
        print >> self.out, "Configuring %s components..." % self.product_name
        os.chdir(self.build_dir)
        # ???
        if (op.exists("libtbx_refresh_is_completed")):
            os.remove("libtbx_refresh_is_completed")
        self.reconfigure(log=log)
        os.chdir(self.build_dir)
        assert op.isfile("setpaths.sh")
        os.environ["PATH"] = "%s:%s" % (op.join(self.build_dir,
                                                "bin"), os.environ["PATH"])

        # Compile .py files
        print >> self.out, "Precompiling .py files..."
        os.chdir(self.modules_dir)
        call(args="libtbx.py_compile_all", log=log)

        # Copy README et al.
        for file_name in [
                "CHANGES", "LICENSE", "README", "README-DEV", "SOURCES"
        ]:
            src_file = op.join(self.installer_dir, file_name)
            if op.exists(src_file):
                # XXX use our own implementation instead of shutil.copyfile
                copy_file(src_file, op.join(self.dest_dir, file_name))

        # generate .app (Mac only)
        apps_built = False
        if ((sys.platform == "darwin") and (len(self.make_apps) > 0)
                and (not self.options.no_app) and self.flag_build_gui):
            os.chdir(self.build_dir)
            for app_name in self.make_apps:
                args = [
                    "libtbx.create_mac_app", app_name,
                    "--app_name=%s-%s" % (app_name, self.version),
                    "--dest=%s" % self.dest_dir, "--alias_build"
                ]
                print >> self.out, "Generating Mac app launcher for %s..." % app_name
                try:
                    call(args=" ".join(args), log=log)
                except RuntimeError, e:
                    print "  ERROR:"
                    print "  " + str(e)
                    print "  installation will continue anyway."
                else:
                    app_file = op.join(self.dest_dir,
                                       "%s-%s.app" % (app_name, self.version))
                    if (not op.exists(app_file)):
                        print >> self.out, " failed."
                        app_file = None
                    else:
                        apps_built = True
コード例 #4
0
    def install_finalize(self):
        """
    Set up dispatchers and assorted shell scripts, create app bundles, etc.
    """
        self.print_header("Finalizing %s installation" % self.product_name)
        log_path = op.join(self.tmp_dir, "install_finalize.log")
        print >> self.out, "Log file: %s" % log_path
        log = open(log_path, "w")

        # Write environment files.
        self.write_environment_files()

        # Regenerate module files.
        if (self.flag_build_gui) and (sys.platform != "darwin"):
            os.environ["LD_LIBRARY_PATH"] = "lib:%s" % op.join(self.base_dir, "lib")
            regenerate_module_files.run(os.path.join(self.dest_dir, "base"), out=self.out)

        # Write dispatcher_include file.
        print >> self.out, "Generating %s environment additions for dispatchers..." % self.product_name
        fnsuffix = ".sh"
        envcmd = "export"
        if sys.platform == "win32":
            fnsuffix = ".bat"
            envcmd = "set"
        dispatcher = op.join(self.build_dir, "dispatcher_include_%s%s" % (self.dest_dir_prefix, fnsuffix))
        if op.isfile(dispatcher):
            os.remove(dispatcher)
        env_prefix = self.product_name.upper()  # e.g. "Phenix" -> "PHENIX"
        prologue = "\n".join(
            [
                '%s %s="%s"' % (envcmd, env_prefix, self.dest_dir),
                "%s %s_VERSION=%s" % (envcmd, env_prefix, self.version),
                "%s %s_ENVIRONMENT=1" % (envcmd, env_prefix),
                "%s %s_MTYPE=%s" % (envcmd, env_prefix, self.mtype),
            ]
            + self.product_specific_dispatcher_prologue()
        )
        epilogue = "\n".join(self.product_specific_dispatcher_epilogue())
        dispatcher_opts = [
            "--build_dir=%s" % self.build_dir,
            "--base_dir=%s" % self.base_dir,
            "--suffix=%s" % self.dest_dir_prefix,
            "--gtk_version=2.10.0",  # XXX this can change!
            "--quiet",
        ]
        if not self.flag_build_gui:
            dispatcher_opts.append("--ignore_missing_dirs")
        # FIXME this will happen regardless of whether the GUI modules are being
        # distributed or not - will this be problematic?
        print "Calling write_gui_dispatcher_include"
        print "  args %s" % dispatcher_opts
        print "  prologue %s" % prologue
        print "  epilogue %s" % epilogue
        write_gui_dispatcher_include.run(args=dispatcher_opts, prologue=prologue, epilogue=epilogue, out=self.out)
        assert op.isfile(dispatcher)

        # Run configure.py to generate dispatchers
        print >> self.out, "Configuring %s components..." % self.product_name
        os.chdir(self.build_dir)
        # ???
        if op.exists("libtbx_refresh_is_completed"):
            os.remove("libtbx_refresh_is_completed")
        self.reconfigure(log=log)
        os.chdir(self.build_dir)
        assert op.isfile("setpaths%s" % fnsuffix)
        if sys.platform != "win32":
            os.environ["PATH"] = "%s:%s" % (op.join(self.build_dir, "bin"), os.environ["PATH"])
        else:
            os.environ["PATH"] = "%s;%s" % (op.join(self.build_dir, "bin"), os.environ["PATH"])

        if not self.options.nopycompile:
            # Compile .py files
            print >> self.out, "Precompiling .py files..."
            os.chdir(self.modules_dir)
            call(args="libtbx.py_compile_all", log=log)

        # Copy README et al.
        for file_name in ["CHANGES", "LICENSE", "README", "README-DEV", "SOURCES"]:
            src_file = op.join(self.installer_dir, file_name)
            if op.exists(src_file):
                dest_file = op.join(self.dest_dir, file_name)
                # XXX use our own implementation instead of shutil.copyfile
                if sys.platform == "win32" and src_file == dest_file:
                    # writing to the same file on Windows renders it empty
                    continue
                copy_file(src_file, dest_file)

        # generate .app (Mac only)
        apps_built = False
        if (
            (sys.platform == "darwin")
            and (len(self.make_apps) > 0)
            and (not self.options.no_app)
            and self.flag_build_gui
        ):
            os.chdir(self.build_dir)
            for app_name in self.make_apps:
                args = [
                    "libtbx.create_mac_app",
                    app_name,
                    "--app_name=%s-%s" % (app_name, self.version),
                    "--dest=%s" % self.dest_dir,
                    "--alias_build",
                ]
                print >> self.out, "Generating Mac app launcher for %s..." % app_name
                try:
                    call(args=" ".join(args), log=log)
                except RuntimeError, e:
                    print "  ERROR:"
                    print "  " + str(e)
                    print "  installation will continue anyway."
                else:
                    app_file = op.join(self.dest_dir, "%s-%s.app" % (app_name, self.version))
                    if not op.exists(app_file):
                        print >> self.out, " failed."
                        app_file = None
                    else:
                        apps_built = True