Example #1
0
    def run(self):
        install_scripts.run(self)
        if not os.name == 'nt':
            return

        for filepath in self.get_outputs():
            # If we can find an executable name in the #! top line of the script
            # file, make .bat wrapper for script.
            with open(filepath, 'rt') as fobj:
                first_line = fobj.readline().lower()

            if not (first_line.startswith('#!') and 'python' in first_line):
                print(NO_PYTHON_ERROR % filepath)
                continue

            path, fname = os.path.split(filepath)
            froot, ext = os.path.splitext(fname)
            bat_file = os.path.join(path, froot + '.bat')
            bat_contents = BAT_TEMPLATE.replace('{FNAME}', fname)

            print('Making %s wrapper for %s' % (bat_file, filepath))
            if self.dry_run:
                continue

            with open(bat_file, 'wt') as fobj:
                fobj.write(bat_contents)
Example #2
0
    def run(self):
        install_scripts.run(self)
        if not os.name == 'nt':
            return

        for filepath in self.get_outputs():
            # If we can find an executable name in the #! top line of the script
            # file, make .bat wrapper for script.
            with open(filepath, 'rt') as fobj:
                first_line = fobj.readline().lower()

            if not (first_line.startswith('#!') and 'python' in first_line):
                printer(NO_PYTHON_ERROR % filepath)
                continue

            path, fname = os.path.split(filepath)
            froot, ext = os.path.splitext(fname)
            bat_file = os.path.join(path, froot + '.bat')
            bat_contents = BAT_TEMPLATE.replace('{FNAME}', fname)

            printer('Making %s wrapper for %s' % (bat_file, filepath))
            if self.dry_run:
                continue

            with open(bat_file, 'wt') as fobj:
                fobj.write(bat_contents)
Example #3
0
    def run(self):
        _install_scripts.run(self)

        # rename manage.py to restauth-manage.py
        source = os.path.join(self.install_dir, 'manage.py')
        target = os.path.join(self.install_dir, 'restauth-manage.py')
        os.rename(source, target)
Example #4
0
 def run(self):
     _install_scripts.run(self)
     # bdist_wheel disables generation of scripts for entry-points[1]
     # and pip/setuptools regenerate them when installing the wheel[2].
     #
     #   [1] https://github.com/pypa/wheel/commit/0d7f398b
     #   [2] https://github.com/pypa/wheel/commit/9aaa6628
     #
     # since setup.py is not included into the wheel, we cannot control
     # entry-point installation when the wheel is installed. However,
     # console script generated when installing the wheel looks like:
     #
     #   #!/path/to/python
     #   # -*- coding: utf-8 -*-
     #   import re
     #   import sys
     #
     #   from gpython import main
     #
     #   if __name__ == '__main__':
     #       sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0])
     #       sys.exit(main())
     #
     # which does not import pkg_resources. Since we also double-check in
     # gpython itself that pkg_resources and other modules are not imported,
     # we are ok with this.
     if not self.no_ep:
         # regular install
         assert self.gpython_installed == 1
     else:
         # bdist_wheel
         assert self.gpython_installed == 0
         assert len(self.outfiles) == 0
Example #5
0
    def run(self):
        def _post_install_scripts():
            #make sure awsume is executable
            execpath = '/usr/local/bin/awsume'
            if os.path.exists(execpath):
                os.chmod(execpath, int('755', 8))

        atexit.register(_post_install_scripts)
        install_scripts.run(self)
    def run(self):
        # old-style class
        install_scripts.run(self)

        self.original_outfiles = self.get_outputs()[:]  # make a copy
        self.outfiles = []  # reset it
        for script in self.original_outfiles:
            # remove suffixes for .py and .sh
            if script.endswith(".py") or script.endswith(".sh"):
                shutil.move(script, script[:-3])
                script = script[:-3]
            self.outfiles.append(script)

            if script.endswith('/mympirun'):
                # make the fake dir, create all symlinks

                # make all links
                # they are create with relative paths !

                rel_script = os.path.basename(script)
                rel_script_dir = os.path.dirname(script)

                # abspath: all_syms = [os.path.join(self.install_dir, x) for x in MYMPIRUN_ALIASES]
                # abspath: all_syms.append(os.path.join(abs_fakepath, 'mpirun'))
                # with relative paths, we also ne to chdir for the fake/mpirun and ref to ../mympirun
                previous_pwd = os.getcwd()

                os.chdir(rel_script_dir)
                for sym_name in MYMPIRUN_ALIASES:
                    if os.path.exists(sym_name):
                        os.remove(sym_name)
                    os.symlink(rel_script, sym_name)
                    newoutfile = os.path.join(rel_script_dir, sym_name)
                    self.outfiles.append(newoutfile)
                    log.info("symlink %s to %s newoutfile %s" % (rel_script, sym_name, newoutfile))

                # fake mpirun
                os.chdir(previous_pwd)
                abs_fakepath = os.path.join(self.install_dir, FAKE_SUBDIRECTORY_NAME)
                if not os.path.isdir(abs_fakepath):
                    log.info("creating abs_fakepath %s" % abs_fakepath)
                    os.mkdir(abs_fakepath)
                else:
                    log.info("not creating abs_fakepath %s (already exists)" % abs_fakepath)

                os.chdir(abs_fakepath)  # abs_fakepath si not always absolute
                fake_mpirun = os.path.join(abs_fakepath, 'mpirun')
                if os.path.exists(fake_mpirun):
                    os.remove(fake_mpirun)

                mympirun_src = '../%s' % rel_script
                os.symlink(mympirun_src, 'mpirun')
                self.outfiles.append(fake_mpirun)
                log.info("symlink %s to %s newoutfile %s" % (mympirun_src, 'mpirun', fake_mpirun))

                os.chdir(previous_pwd)
    def run(self):
        # old-style class
        install_scripts.run(self)

        self.original_outfiles = self.get_outputs()[:]  # make a copy
        self.outfiles = []  # reset it
        for script in self.original_outfiles:
            # remove suffixes for .py and .sh
            if script.endswith(".py") or script.endswith(".sh"):
                shutil.move(script, script[:-3])
                script = script[:-3]
            self.outfiles.append(script)
Example #8
0
    def run(self):
        # old-style class
        install_scripts.run(self)

        self.original_outfiles = self.get_outputs()[:]  # make a copy
        self.outfiles = []  # reset it
        for script in self.original_outfiles:
            # remove suffixes for .py and .sh
            if script.endswith(".py") or script.endswith(".sh"):
                shutil.move(script, script[:-3])
                script = script[:-3]
            self.outfiles.append(script)
Example #9
0
    def run(self):
        # old-style class
        install_scripts.run(self)

        self.original_outfiles = self.get_outputs()[:]  # make a copy
        self.outfiles = []  # reset it
        for script in self.original_outfiles:
            # remove suffixes for .py and .sh
            if REGEXP_REMOVE_SUFFIX.search(script):
                newscript = REGEXP_REMOVE_SUFFIX.sub('', script)
                shutil.move(script, newscript)
                script = newscript
            self.outfiles.append(script)
Example #10
0
    def run(self):
        # old-style class
        install_scripts.run(self)

        self.original_outfiles = self.get_outputs()[:]  # make a copy
        self.outfiles = []  # reset it
        for script in self.original_outfiles:
            # remove suffixes for .py and .sh
            if REGEXP_REMOVE_SUFFIX.search(script):
                newscript = REGEXP_REMOVE_SUFFIX.sub('', script)
                shutil.move(script, newscript)
                script = newscript
            self.outfiles.append(script)
Example #11
0
    def run(self):
        global dir_install_script

        install_scripts.run(self)

        dir_install_script = os.path.abspath(self.install_dir)

        if dir_install_script != None and dir_install_script != "" and os.path.isdir(
                dir_install_script):
            print('')
            print("Detected script installation directory: " +
                  dir_install_script)
            print('')

        return
Example #12
0
 def run(self):
     install_scripts.run(self)
     orig_install_dir = self.install_dir
     self.install_dir = self.install_agents
     eps = EntryPoint.parse_map(self.distribution.entry_points)
     header = get_script_header('')
     for ep in eps.get('resource_agents', {}).values():
         filename = os.path.join(*(ep.name.split('.')))
         contents = header + self.agent_template % {
             'module': ep.module_name,
             'class': ep.attrs[0],
             'method': '.'.join(ep.attrs),
         }
         self.write_script(filename, contents)
     self.install_dir = orig_install_dir
Example #13
0
 def run(self):
     # in this second step we edit the script in the build directory to
     # replace @pythondir@ with the value of install_lib and we rename the
     # script; the modified script will be copied to the installation
     # directory by setuptools
     assert (install_lib is not None)
     in_path = os.path.join(self.build_dir, 'p4c-bmv2.in')
     out_path = os.path.join(self.build_dir, 'p4c-bmv2')
     with open(in_path, "r") as fin:
         with open(out_path, "w") as fout:
             for line in fin:
                 # we use the platform-dependent install path computed by
                 # setuptools
                 fout.write(line.replace('@pythondir@', install_lib))
     os.remove(os.path.join(self.build_dir, 'p4c-bmv2.in'))
     install_scripts.run(self)
Example #14
0
 def run(self):
     # in this second step we edit the script in the build directory to
     # replace @pythondir@ with the value of install_lib and we rename the
     # script; the modified script will be copied to the installation
     # directory by setuptools
     assert(install_lib is not None)
     in_path = os.path.join(self.build_dir, 'p4c-bmv2.in')
     out_path = os.path.join(self.build_dir, 'p4c-bmv2')
     with open(in_path, "r") as fin:
         with open(out_path, "w") as fout:
             for line in fin:
                 # we use the platform-dependent install path computed by
                 # setuptools
                 fout.write(line.replace('@pythondir@', install_lib))
     os.remove(os.path.join(self.build_dir, 'p4c-bmv2.in'))
     install_scripts.run(self)
Example #15
0
 def run(self):
     install_scripts.run(self)
     if not os.name == "nt":
         return
     for filepath in self.get_outputs():
         # If we can find an executable name in the #! top line of the script
         # file, make .bat wrapper for script.
         with open(filepath, "rt") as fobj:
             first_line = fobj.readline()
         if not (first_line.startswith("#!") and "python" in first_line.lower()):
             continue
         pth, fname = os.path.split(filepath)
         froot, ___ = os.path.splitext(fname)
         bat_file = os.path.join(pth, froot + ".bat")
         bat_contents = BAT_TEMPLATE.replace("{FNAME}", fname)
         if self.dry_run:
             continue
         with open(bat_file, "wt") as fobj:
             fobj.write(bat_contents)
Example #16
0
 def run(self):
     install_scripts.run(self)
     if not os.name == "nt":
         return
     for filepath in self.get_outputs():
         # If we can find an executable name in the #! top line of the script
         # file, make .bat wrapper for script.
         with open(filepath, "rt") as fobj:
             first_line = fobj.readline()
         if not (first_line.startswith("#!")
                 and "python" in first_line.lower()):
             continue
         pth, fname = os.path.split(filepath)
         froot, ___ = os.path.splitext(fname)
         bat_file = os.path.join(pth, froot + ".bat")
         bat_contents = BAT_TEMPLATE.replace("{FNAME}", fname)
         if self.dry_run:
             continue
         with open(bat_file, "wt") as fobj:
             fobj.write(bat_contents)
Example #17
0
    def run(self):
        if os.path.exists(self.build_dir):
            installer = 'pip'
        else:
            installer = 'fucking_setuptools'

        script_tmp_dir = self.build_dir if installer != 'fucking_setuptools' else self.install_dir

        def subst_file(_file, vars_2_subst):
            input_file = os.path.join(script_tmp_dir, _file)
            output_file = input_file + '.tmp'
            subst_vars(input_file, output_file, vars_2_subst)
            os.unlink(input_file)
            self.move_file(output_file, input_file)

        # if setup.py install is used without using setup.py build
        # setuptools creates a directory build/bdist.linux-x86_64/egg/EGG-INFO/scripts/
        # but not build/scripts
        # and without attribute to grasp this directory :-(((
        # so we need to run _install_scripts first
        # to create build/scripts (self.build_dir)
        # and then substitute variables in this dir

        if installer == 'fucking_setuptools':
            _install_scripts.run(self)

        inst = self.distribution.command_options.get('install', {})
        if self.distribution.fix_scripts is not None:
            vars_2_subst = {
                'PREFIX':
                inst['prefix'][1] if 'prefix' in inst else '',
                'PREFIXSHARE':
                os.path.join(get_install_data_dir(inst), 'integron_finder'),
                'VERSION':
                self.distribution.get_version(),
            }
            for _file in self.distribution.fix_scripts:
                subst_file(_file, vars_2_subst)
                pass
        if installer == 'pip':
            _install_scripts.run(self)
Example #18
0
 def run(self):
     install_scripts.run(self)
     if not os.name == "nt":
         return
     for filepath in self.get_outputs():
         # If we can find an executable name in the #! top line of the script
         # file, make .bat wrapper for script.
         with open(filepath, 'rt') as fobj:
             first_line = fobj.readline()
         if not (first_line.startswith('#!') and 'python' in first_line.lower()):
             log.info("No #!python executable found, skipping .bat wrapper")
             continue
         pth, fname = psplit(filepath)
         froot, ext = splitext(fname)
         bat_file = pjoin(pth, froot + '.bat')
         bat_contents = BAT_TEMPLATE.replace('{FNAME}', fname)
         log.info("Making %s wrapper for %s" % (bat_file, filepath))
         if self.dry_run:
             continue
         with open(bat_file, 'wt') as fobj:
             fobj.write(bat_contents)
Example #19
0
    def run(self):
        # default behaviors
        install_scripts.run(self)

        # Nothing more to do if this is not Windows
        if not os.name == "nt":
            return

        # For Windows, write batch scripts for all executable python files
        for output_path in self.get_outputs():
            # look for #! at the top
            with open(output_path, "rt") as f:
                first_line = f.readline()
            # skip non-executbale python files
            if not (first_line.startswith("#!") and "python" in first_line.lower()):
                continue
            path_name, file_name = os.path.split(output_path)
            if self.dry_run:
                continue
            bat_file = os.path.join(path_name, os.path.splitext(file_name)[0] + ".bat")
            with open(bat_file, "wt") as f:
                f.write(WINDOWS_BATCH_TEMPLATE.format(file_name=file_name))
Example #20
0
 def run(self):
     install_scripts.run(self)
     if not os.name == "nt":
         return
     for filepath in self.get_outputs():
         # If we can find an executable name in the #! top line of the script
         # file, make .bat wrapper for script.
         with open(filepath, 'rt') as fobj:
             first_line = fobj.readline()
         if not (first_line.startswith('#!') and
                 'python' in first_line.lower()):
             log.info("No #!python executable found, skipping .bat wrapper")
             continue
         pth, fname = os.path.split(filepath)
         froot, ___ = os.path.splitext(fname)
         bat_file = os.path.join(pth, froot + '.bat')
         bat_contents = BAT_TEMPLATE.replace('{FNAME}', fname)
         log.info("Making %s wrapper for %s" % (bat_file, filepath))
         if self.dry_run:
             continue
         with open(bat_file, 'wt') as fobj:
             fobj.write(bat_contents)
Example #21
0
    def run(self):
        # in this second step we edit the scripts in place in the build
        # directory to add install_lib to the PYTHONPATH; the modified scripts
        # will be copied to the installation directory by setuptools
        assert(install_lib is not None)

        def process_one(path):
            with open(path, "r") as fin:
                # add the directory to the PYHTONPATH before the first import
                p = re.compile('(^(?!#).*import.*)', re.MULTILINE)
                text = fin.read()
                new_text = p.sub(r'import sys\n'
                                 'sys.path.append("{}")\n'
                                 '\g<1>'.format(install_lib),
                                 text, count=1)
            with open(path, "w") as fout:
                fout.write(new_text)

        if old_install:
            for s in scripts:
                process_one(os.path.join(self.build_dir, s))

        install_scripts.run(self)
Example #22
0
 def run(self):
     install_scripts.run(self)
     self.distribution.script_install_dir = self.install_dir
Example #23
0
    def run(self) -> None:
        install_scripts.run(self)

        if os.name != 'nt':
            for script in self.get_outputs():
                os.rename(script, script[:-3])
Example #24
0
 def run(self):
     InstallScripts.run(self)
     _maintain_symlinks('script', self.install_dir)
Example #25
0
 def run(self):
     if not dry_run:
         _install_scripts.run(self)
     else:
         print("skipping regular install_scripts")
Example #26
0
 def run(self):
     InstallScripts.run(self)
     _maintain_symlinks('script', self.install_dir)
 def run(self):
     install_scripts.run(self)
     import pythesint as pti
     pti.update_all_vocabularies()
Example #28
0
 def run(self):
     if not create_entry_points:
         install_scripts.run(self)
Example #29
0
 def run(self):
     install_scripts.run(self)
     import pythesint as pti
     pti.update_all_vocabularies()
Example #30
0
 def run(self):
     install_scripts.run(self)
     self.distribution.script_install_dir = self.install_dir
Example #31
0
 def run(self):
     global install_dir
     install_scripts.run(self)
     install_dir=self.install_dir
     if install_dir!=None and install_dir!="":
        print ("detected install dir: "+install_dir)