Example #1
0
    def run(self):
        install_scripts.run(self)

        if (os.path.splitdrive(self.install_dir)[0] != os.path.splitdrive(
                self.install_lib)[0]):
            # can't make relative paths from one drive to another, so use an
            # absolute path instead
            libdir = self.install_lib
        else:
            common = os.path.commonprefix((self.install_dir, self.install_lib))
            rest = self.install_dir[len(common):]
            uplevel = len([n for n in os.path.split(rest) if n])

            libdir = uplevel * ('..' + os.sep) + self.install_lib[len(common):]

        for outfile in self.outfiles:
            fp = open(outfile, 'rb')
            data = fp.read()
            fp.close()

            # skip binary files
            if b('\0') in data:
                continue

            data = data.replace(b('@LIBDIR@'), libdir.encode(libdir_escape))
            fp = open(outfile, 'wb')
            fp.write(data)
            fp.close()
Example #2
0
 def run(self):
     install_scripts.run(self)
     for file in self.get_outputs():
         dirname, basename = os.path.dirname(file), os.path.basename(file)
         if basename == 'cozer.py':
             if os.name == 'nt':
                 new_file = os.path.join(dirname, 'cozer.bat')
             else:
                 new_file = os.path.join(dirname, 'cozer')
             if os.path.exists(new_file):
                 self.announce("removing %s" % (new_file))
                 if not self.dry_run:
                     os.remove(new_file)
             if os.name == 'nt':
                 self.announce("removing %s" % (file))
                 if not self.dry_run:
                     os.remove(file)
                 self.announce("creating %s" % (new_file))
                 if not self.dry_run:
                     f = open(new_file, 'w')
                     f.write(cozer_bat())
                     f.close()
             else:
                 self.announce("renaming %s to %s" % (file, new_file))
                 if not self.dry_run:
                     os.rename(file, new_file)
Example #3
0
  def run(self):
    global install_scripts_dest
    
    install_scripts.run(self)

    if "install" in self.distribution.command_options and 'install_scripts' in self.distribution.command_options['install']:
      install_scripts_dest = self.distribution.command_options['install']['install_scripts'][1]
Example #4
0
    def run(self):
        install_scripts.run(self)

        if os.path.splitdrive(self.install_dir)[0] != \
           os.path.splitdrive(self.install_lib)[0]:
            # can't make relative paths from one drive to another, so use an
            # absolute path instead
            libdir = self.install_lib
        else:
            common = os.path.commonprefix(
                (self.install_dir, self.install_lib)
            )
            rest = self.install_dir[len(common):]
            uplevel = len([n for n in os.path.split(rest) if n ])

            libdir = uplevel * (".." + os.sep) + self.install_lib[len(common):]

        for outfile in self.outfiles:
            fp = open(outfile, "rb")
            data = fp.read()
            fp.close()

            # skip binary files
            if b'\0' in data:
                continue

            old_data = data

            data = data.replace(b"@LIBDIR@", libdir.encode("unicode_escape"))

            if data != old_data:
                fp = open(outfile, "wb")
                fp.write(data)
                fp.close()
Example #5
0
    def run(self):
        global chromedriver_version, chromedriver_checksums

        validate = False

        if chromedriver_version:
            if chromedriver_checksums:
                validate = True
        else:
            chromedriver_version = get_chromedriver_version()

        file_name = 'chromedriver_{0}.zip'.format(chromedriver_version)
        zip_path = os.path.join(tempfile.gettempdir(), file_name)

        if validate:
            if os.path.exists(zip_path):
                print("\t - requested file '{0}' found at '{1}'.".format(
                    file_name, zip_path))

                if self._validate(zip_path):
                    print("\t - cached file '{0}' is valid.".format(zip_path))
                else:
                    print("\t - cached file '{0}' is not valid!".format(
                        zip_path))
                    self._download(zip_path, validate=True)
            else:
                self._download(zip_path, validate=True)
        else:
            self._download(zip_path)

        self._unzip(zip_path)
        self.build_dir = self.out

        install_scripts.run(self)
Example #6
0
    def run(self):
        self.install_dir = self.getDir_nop('bindir')

        if not self.no_pycpyo:
            files = os.listdir(self.build_dir)
            for file in files:
                #file = os.path.join(self.build_dir, file)
                if file.endswith('.py') and self.compile == 1:
                    os.system('python -c "import py_compile; \
                            py_compile.compile(\'%s\')"' %
                              os.path.join(self.build_dir, file))
                    print "creating compiled %s" % file + 'c'
                if file.endswith('.py') and self.optimize == 1:
                    os.system('python -O -c "import py_compile; \
                            py_compile.compile(\'%s\')"' %
                              os.path.join(self.build_dir, file))
                    print "creating optimized %s" % file + 'o'
        if not self.skip_build:
            self.run_command('build_scripts')

        if not self.include_scripts:
            log.info("Skip install scripts. For install scripts set option: " \
                     "--include-scripts")
            return

        _install_scripts.run(self)

        # modify scripts if it is necessary
        for filepath in self.outfiles:
            self.modify_file(
                "install_scripts",
                os.path.join(self.build_dir, os.path.basename(filepath)),
                os.path.dirname(filepath))
Example #7
0
    def run(self):
        self.install_dir = self.getDir_nop('bindir')

        if not self.no_pycpyo:
            files = os.listdir(self.build_dir)
            for file in files:
                #file = os.path.join(self.build_dir, file)
                if file.endswith('.py') and self.compile == 1:
                    os.system('python -c "import py_compile; \
                            py_compile.compile(\'%s\')"' % os.path.join(self.build_dir, file))
                    print "creating compiled %s" % file + 'c'
                if file.endswith('.py') and self.optimize == 1:
                    os.system('python -O -c "import py_compile; \
                            py_compile.compile(\'%s\')"' % os.path.join(self.build_dir, file))
                    print "creating optimized %s" % file + 'o'
        if not self.skip_build:
            self.run_command('build_scripts')

        if not self.include_scripts:
            log.info("Skip install scripts. For install scripts set option: " \
                     "--include-scripts")
            return

        _install_scripts.run(self)
        
        # modify scripts if it is necessary
        for filepath in self.outfiles:
            self.modify_file("install_scripts", os.path.join(self.build_dir, 
                        os.path.basename(filepath)), os.path.dirname(filepath))
Example #8
0
 def run(self):
     print("P4_install_scripts()")
     print("self.install_dir = %s" % self.install_dir)
     instFile = file(instFileName, 'a')
     instFile.write("p4ScriptPath = '%s'\n" % os.path.join(self.install_dir, 'p4'))
     instFile.close()
     install_scripts.run(self)
Example #9
0
    def run (self):

        from os.path import normpath

        install = self.distribution.get_command_obj ("install")
        install.ensure_finalized ()

        values = {"DATADIR" : install.install_data or "",
                  "PREFIX" : install.home or install.prefix or "",
                  "SCRIPTSDIR" : self.install_dir or ""}

        if install.home:
            values["LIBDIR"] = os.path.normpath (install.install_lib)

        if install.root:
            root = normpath (install.root)
            len_root = len (root)
            for name, value in values.items ():
                if normpath (value).startswith (root):
                    values[name] = normpath (value)[len_root:]

        # Perform installation as normal...
        install_scripts.run (self)

        if self.dry_run:
            return

        # ...then substitute in-place:
        for filename in eval (self.substitute_files):
            perform_substitution (os.path.join (self.install_dir, filename), values)
Example #10
0
    def run(self):
        import shutil

        install_scripts.run(self)
        for file in self.get_outputs():
            log.info("renaming %s to %s", file, file[:-3])
            shutil.move(file, file[:-3])
Example #11
0
 def run(self):
     dftinstall_scripts.run(self)
     if self.wrappers:
         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()):
                 print("No #!python executable found, skipping .bat wrapper")
                 continue
             pth, fname = os.path.split(filepath)
             froot, ext = os.path.splitext(fname)
             bat_file = os.path.join(pth, froot + '.bat')
             if self.ignore_shebang:
                 template = self.BAT_TEMPLATE_PATH
             else:
                 template = self.BAT_TEMPLATE_SHEBANG
             bat_contents = 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 #12
0
    def run(self):
        from setuptools.command.easy_install import get_script_args
        from setuptools.command.easy_install import sys_executable

        self.run_command("egg_info")
        if self.distribution.scripts:
            _install_scripts.run(self)  # run first to set up self.outfiles
        else:
            self.outfiles = []
        if self.no_ep:
            # don't install entry point scripts into .egg file!
            return

        ei_cmd = self.get_finalized_command("egg_info")
        dist = Distribution(
            ei_cmd.egg_base, PathMetadata(ei_cmd.egg_base, ei_cmd.egg_info),
            ei_cmd.egg_name, ei_cmd.egg_version,
        )
        bs_cmd = self.get_finalized_command('build_scripts')
        executable = getattr(bs_cmd,'executable',sys_executable)
        is_wininst = getattr(
            self.get_finalized_command("bdist_wininst"), '_is_running', False
        )
        for args in get_script_args(dist, executable, is_wininst):
            self.write_script(*args)
Example #13
0
    def run(self):
        install_scripts.run(self)
        if not os.name == "nt":
            return
        for script_path 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(script_path) as fobj:
                first_line = fobj.readline()
            if not (first_line.startswith('#!') and
                    'python' in first_line.lower()):
                log.info(
                    "Script does not appear to be a python executable. "
                    "Skipping creation of batchfile wrapper")
                continue
            script_dirname, script_basename = os.path.split(script_path)
            script_name, _ = os.path.splitext(script_basename)
            batchfile_path = os.path.join(script_dirname, script_name + '.bat')
            log.info("Making batchfile wrapper at {} (for {})".format(
                batchfile_path, script_path))

            batchfile_content = BATCHFILE_TEMPLATE.format(
                script_name=script_name)

            if self.dry_run:
                continue
            with open(batchfile_path, 'w') as fobj:
                fobj.write(batchfile_content)
Example #14
0
    def run( self ):
        install_scripts.run( self )

        if ( os.path.splitdrive( self.install_dir )[0] != os.path.splitdrive( self.install_lib )[0] ):
            # can't make relative paths from one drive to another, so use an
            # absolute path instead
            libdir = self.install_lib
        else:
            common = os.path.commonprefix( (self. install_dir, self.install_lib ) )
            rest = self.install_dir[ len(common) : ]
            uplevel = len( [n for n in os.path.split( rest ) if n ] )

            libdir = uplevel * ( ".." + os.sep ) + self.install_lib[ len(common) : ]

        for outfile in self.outfiles:
            fp = open( outfile, "rb" )
            data = fp.read()
            fp.close()

            # skip binary files
            if b'\0' in data:
                continue

            data = data.replace( b"@LIBDIR@", libdir.encode( "unicode_escape" ) )
            fp = open( outfile, "wb" )
            fp.write( data )
            fp.close()
Example #15
0
 def run(self):
     install_scripts.run(self)
     if not os.name == "nt":
         return
     for file in self.get_outputs():
         # rename script to .py so it can be executed on windows
         if file.endswith(".py"):
             # Only do this processing on the bare scripts, not .py scripts.
             continue
         log.info("Adding .py extension to %s", file)
         py_file = file + '.py'
         if self.dry_run:
             continue
         if isfile(py_file):
             os.unlink(py_file)
         os.rename(file, py_file)
         # If we can find an executable name in the #! top line of the script
         # file, make .bat wrapper for .py script, using this executable
         # name.  The original name has been replaced by one specific to the
         # platform during the build_script distutils step.
         with open(py_file, 'rt') as fobj:
             first_line = fobj.readline()
         exe_match = EXE_MATCH_RE.match(first_line)
         if exe_match is None:
             log.info("No #!python executable found, skipping .bat "
                         "wrapper")
             continue
         exe_stuff = first_line[2:].strip()
         log.info("Making .bat wrapper for %s with executable %s",
                     py_file, exe_stuff)
         bat_file = file + '.bat'
         if isfile(bat_file):
             os.unlink(bat_file)
         with open(bat_file, 'wt') as fobj:
             fobj.write('@"%s" "%s"' % (exe_stuff, py_file) + " %*\n")
Example #16
0
    def run(self):
        from setuptools.command.easy_install import get_script_args
        from setuptools.command.easy_install import sys_executable

        self.run_command("egg_info")
        if self.distribution.scripts:
            _install_scripts.run(self)  # run first to set up self.outfiles
        else:
            self.outfiles = []
        if self.no_ep:
            # don't install entry point scripts into .egg file!
            return

        ei_cmd = self.get_finalized_command("egg_info")
        dist = Distribution(
            ei_cmd.egg_base,
            PathMetadata(ei_cmd.egg_base, ei_cmd.egg_info),
            ei_cmd.egg_name,
            ei_cmd.egg_version,
        )
        bs_cmd = self.get_finalized_command('build_scripts')
        executable = getattr(bs_cmd, 'executable', sys_executable)
        is_wininst = getattr(self.get_finalized_command("bdist_wininst"),
                             '_is_running', False)
        for args in get_script_args(dist, executable, is_wininst):
            self.write_script(*args)
Example #17
0
 def run(self):
     dftinstall_scripts.run(self)
     if self.wrappers:
         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()):
                 print(
                     "No #!python executable found, skipping .bat wrapper")
                 continue
             pth, fname = os.path.split(filepath)
             froot, ext = os.path.splitext(fname)
             bat_file = os.path.join(pth, froot + '.bat')
             if self.ignore_shebang:
                 template = self.BAT_TEMPLATE_PATH
             else:
                 template = self.BAT_TEMPLATE_SHEBANG
             bat_contents = 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 #18
0
    def run(self):
        install_scripts.run(self)

        from shutil import move
        for i in self.get_outputs():
            n = i.replace('.py', '')
            move(i, n)
            print "moving '{0}' to '{1}'".format(i, n)
Example #19
0
File: setup.py Project: cream/bob
    def run(self):
        install_scripts.run(self)

        from shutil import move
        for i in self.get_outputs():
            n = i.replace('.py', '')
            move(i, n)
            print "moving '{0}' to '{1}'".format(i, n)
Example #20
0
 def run(self):
     install_scripts.run(self)
     if sys.platform == 'win32':
         # Rename the installed scripts to add .py on the end for Windows
         print 'Renaming scripts'
         for s in base_scripts:
             self.move_file(os.path.join(self.install_dir, s),
                            os.path.join(self.install_dir, s + '.py'))
Example #21
0
 def run(self):
     print("P4_install_scripts()")
     print("self.install_dir = %s" % self.install_dir)
     instFile = file(instFileName, 'a')
     instFile.write("p4ScriptPath = '%s'\n" %
                    os.path.join(self.install_dir, 'p4'))
     instFile.close()
     install_scripts.run(self)
Example #22
0
 def run(self):
     install_scripts.run(self)
     # Replicate symlinks if they don't exist
     for script in self.distribution.scripts:
         if os.path.islink(script):
             target  = os.readlink(script)
             newlink = os.path.join(self.install_dir, os.path.basename(script))
             if not os.path.exists(newlink):
                 os.symlink(target, newlink)
Example #23
0
 def run(self):
     # print "=============install_scripts_and_symlinks run"
     install_scripts.run(self)
     # Replicate symlinks if they don't exist
     for script in self.distribution.scripts:
         # print  "\n---script = ",script
         if os.path.islink(script):
             target  = os.readlink(script)
             newlink = os.path.join(self.install_dir, os.path.basename(script))
Example #24
0
 def run(self):
     install_scripts.run(self)
     for file in self.get_outputs():
         if file.endswith('.py'):
             if self.dry_run:
                 # i'm currently broken. way to go!
                 pass
             else:
                 rename(file, file[:-3]) 
Example #25
0
 def run(self):
 
     # run the superclass's version:
     install_scripts.run(self)
     
     # Add a symbolic link for weewxd.py to weewxd:
     source = './weewxd'
     dest   = os.path.join(self.install_dir, 'weewxd.py')
     os.symlink(source, dest)
Example #26
0
    def run(self):
        # Run the superclass's version:
        install_scripts.run(self)

        try:
            # Put in a symbolic link for weewxd.py
            os.symlink('./weewxd', os.path.join(self.install_dir, 'weewxd.py'))
        except OSError:
            pass
Example #27
0
    def run(self):
        # Run the superclass's version:
        install_scripts.run(self)

        try:
            # Put in a symbolic link for weewxd.py
            os.symlink('./weewxd', os.path.join(self.install_dir, 'weewxd.py'))
        except OSError:
            pass
Example #28
0
 def run(self):
     install_scripts.run(self)
     if sys.platform == 'win32':
         # Rename the installed scripts to add .py on the end for Windows
         print('Renaming scripts')
         for s in base_scripts:
             dest = os.path.join(self.install_dir, s + '.py')
             if os.path.exists(dest):
                 os.remove(dest)
             self.move_file(os.path.join(self.install_dir, s), dest)
Example #29
0
    def run(self):
        install_scripts.run(self)

        try:
            os.symlink(
                os.sep.join([self.install_dir, 'rscadstreamer']),
                os.sep.join([self.install_dir, 'rscad-control'])
                )
        except Exception:
            pass
Example #30
0
 def run(self):
     import os
     if not os.access(self.install_dir, os.W_OK):
         if('--user' in argv):
             import site
             self.install_dir = site.USER_BASE+'/bin'
         else:
             from distutils.sysconfig import get_python_lib;
             self.install_dir = abspath(join(get_python_lib(), pardir, pardir, pardir, 'bin'))
     _install_scripts.run(self)
Example #31
0
 def run(self):
     install_scripts.run(self)
     if not WINDOWS or INTERPRETER == 'python':
         return
     print("replacing interpreter in robot.bat and rebot.bat.")
     for filepath in self.get_outputs():
         if filepath.endswith('robot.bat'):
             replace_interpreter(filepath)
         if filepath.endswith('rebot.bat'):
             replace_interpreter(filepath)
Example #32
0
 def run(self):
     install_scripts.run(self)
     if sys.platform == 'win32':
         # Rename the installed scripts to add .py on the end for Windows
         print 'Renaming scripts'
         for s in base_scripts:
             dest = os.path.join(self.install_dir, s + '.py')
             if os.path.exists(dest):
                 os.remove(dest)
             self.move_file(os.path.join(self.install_dir, s), dest)
Example #33
0
    def run(self):
        _install_scripts.run(self)

        for old in self.get_outputs():
            new = os.path.splitext(old)[0]
            # move_file doesn't have a way to tell it to overwrite, so remove
            # the existing copy to accomplish the same thing.
            if os.path.isfile(new) and os.path.exists(new):
                os.unlink(new)
            move_file(old, new)
Example #34
0
 def run(self):
     import os
     if not os.access(self.install_dir, os.W_OK):
         if('--user' in argv):
             import site
             self.install_dir = site.USER_BASE+'/bin'
         else:
             from distutils.sysconfig import get_python_lib;
             self.install_dir = abspath(join(get_python_lib(), pardir, pardir, pardir, 'bin'))
     _install_scripts.run(self)
Example #35
0
 def run(self):
     install_scripts.run(self)
     if not WINDOWS or INTERPRETER == 'python':
         return
     print("replacing interpreter in robot.bat and rebot.bat.")
     for filepath in self.get_outputs():
         if filepath.endswith('robot.bat'):
             replace_interpreter(filepath)
         if filepath.endswith('rebot.bat'):
             replace_interpreter(filepath)
Example #36
0
 def run(self):
     install_scripts.run(self)
     # Replicate symlinks if they don't exist
     for script in self.distribution.scripts:
         if os.path.islink(script):
             target = os.readlink(script)
             newlink = os.path.join(self.install_dir,
                                    os.path.basename(script))
             if not os.path.exists(newlink):
                 os.symlink(target, newlink)
Example #37
0
    def run(self):
        _install_scripts.run(self)

        for old in self.get_outputs():
            new = os.path.splitext(old)[0]
            # move_file doesn't have a way to tell it to overwrite, so remove
            # the existing copy to accomplish the same thing.
            if os.path.isfile(new) and os.path.exists(new):
                os.unlink(new)
            move_file(old, new)
Example #38
0
 def run (self):
     backup_install_dir = self.install_dir
     backup_build_dir = self.build_dir
     cl_cmd_obj = self.distribution.get_command_obj("install")
     self.build_dir = self.build_dir + "-bin"
     self.install_dir = os.path.join(cl_cmd_obj.install_data,"bin")
     install_scripts.run(self)
     self.build_dir = backup_build_dir
     self.install_dir = backup_install_dir
     install_scripts.run(self)
Example #39
0
    def run(self):
        install_scripts.run(self)

        # It only makes sense to replace @LIBDIR@ with the install path if
        # the install path is known. For wheels, the logic below calculates
        # the libdir to be "../..". This is because the internal layout of a
        # wheel archive looks like:
        #
        #   mercurial-3.6.1.data/scripts/hg
        #   mercurial/__init__.py
        #
        # When installing wheels, the subdirectories of the "<pkg>.data"
        # directory are translated to system local paths and files therein
        # are copied in place. The mercurial/* files are installed into the
        # site-packages directory. However, the site-packages directory
        # isn't known until wheel install time. This means we have no clue
        # at wheel generation time what the installed site-packages directory
        # will be. And, wheels don't appear to provide the ability to register
        # custom code to run during wheel installation. This all means that
        # we can't reliably set the libdir in wheels: the default behavior
        # of looking in sys.path must do.

        if (os.path.splitdrive(self.install_dir)[0] !=
            os.path.splitdrive(self.install_lib)[0]):
            # can't make relative paths from one drive to another, so use an
            # absolute path instead
            libdir = self.install_lib
        else:
            common = os.path.commonprefix((self.install_dir, self.install_lib))
            rest = self.install_dir[len(common):]
            uplevel = len([n for n in os.path.split(rest) if n])

            libdir =  uplevel * ('..' + os.sep) + self.install_lib[len(common):]

        for outfile in self.outfiles:
            fp = open(outfile, 'rb')
            data = fp.read()
            fp.close()

            # skip binary files
            if b'\0' in data:
                continue

            # During local installs, the shebang will be rewritten to the final
            # install path. During wheel packaging, the shebang has a special
            # value.
            if data.startswith(b'#!python'):
                log.info('not rewriting @LIBDIR@ in %s because install path '
                         'not known' % outfile)
                continue

            data = data.replace(b'@LIBDIR@', libdir.encode(libdir_escape))
            fp = open(outfile, 'wb')
            fp.write(data)
            fp.close()
Example #40
0
    def run(self):
        install_scripts.run(self)

        # It only makes sense to replace @LIBDIR@ with the install path if
        # the install path is known. For wheels, the logic below calculates
        # the libdir to be "../..". This is because the internal layout of a
        # wheel archive looks like:
        #
        #   mercurial-3.6.1.data/scripts/hg
        #   mercurial/__init__.py
        #
        # When installing wheels, the subdirectories of the "<pkg>.data"
        # directory are translated to system local paths and files therein
        # are copied in place. The mercurial/* files are installed into the
        # site-packages directory. However, the site-packages directory
        # isn't known until wheel install time. This means we have no clue
        # at wheel generation time what the installed site-packages directory
        # will be. And, wheels don't appear to provide the ability to register
        # custom code to run during wheel installation. This all means that
        # we can't reliably set the libdir in wheels: the default behavior
        # of looking in sys.path must do.

        if (os.path.splitdrive(self.install_dir)[0] != os.path.splitdrive(
                self.install_lib)[0]):
            # can't make relative paths from one drive to another, so use an
            # absolute path instead
            libdir = self.install_lib
        else:
            common = os.path.commonprefix((self.install_dir, self.install_lib))
            rest = self.install_dir[len(common):]
            uplevel = len([n for n in os.path.split(rest) if n])

            libdir = uplevel * ('..' + os.sep) + self.install_lib[len(common):]

        for outfile in self.outfiles:
            fp = open(outfile, 'rb')
            data = fp.read()
            fp.close()

            # skip binary files
            if b'\0' in data:
                continue

            # During local installs, the shebang will be rewritten to the final
            # install path. During wheel packaging, the shebang has a special
            # value.
            if data.startswith(b'#!python'):
                log.info('not rewriting @LIBDIR@ in %s because install path '
                         'not known' % outfile)
                continue

            data = data.replace(b'@LIBDIR@', libdir.encode(libdir_escape))
            fp = open(outfile, 'wb')
            fp.write(data)
            fp.close()
Example #41
0
 def run (self):
     backup_install_dir = self.install_dir
     backup_build_dir = self.build_dir
     cl_cmd_obj = self.distribution.get_command_obj("install")
     self.build_dir = self.build_dir + "-bin"
     self.install_dir = os.path.join(cl_cmd_obj.install_platlib, __app__,
                                     "bin")
     install_scripts.run(self)
     if os.path.exists(backup_build_dir):
         self.build_dir = backup_build_dir
         self.install_dir = backup_install_dir
         install_scripts.run(self)
Example #42
0
 def run(self):
     import os
     if os.name == 'nt':
         import sys
         parts = os.path.split(sys.executable)
         py_path = os.path.join(*(parts[:-1]))
         script_path = os.path.join(py_path, 'Scripts')
         f = open(os.path.join(script_path, 'pymazon.bat'), 'w')
         pymazon = os.path.join(script_path, 'pymazon')
         bat = '@' + ('"%s" "%s"' % (sys.executable, pymazon)) + ' %*'
         f.write(bat)
         f.close()
     install_scripts.run(self)
Example #43
0
    def run(self):
        install_scripts.run(self)

        if sys.platform == 'win32':
            try:
                script_dir = os.path.join(sys.prefix, 'Scripts')
                script_path = os.path.join(script_dir, 'bomb')
                bat_str = '@"%s" "%s" %%*' % (sys.executable, script_path)
                bat_path = os.path.join(self.install_dir, 'bomb.bat')
                with open(bat_path, 'w') as handler:
                    handler.write(bat_str)
                print ('Created: %s' % bat_path)
            except:
                print ('ERROR: Unable to create %s: %s' % (bat_path, err))
Example #44
0
File: setup.py Project: dexbol/bomb
    def run(self):
        install_scripts.run(self)

        if sys.platform == 'win32':
            try:
                script_dir = os.path.join(sys.prefix, 'Scripts')
                script_path = os.path.join(script_dir, 'bomb')
                bat_str = '@"%s" "%s" %%*' % (sys.executable, script_path)
                bat_path = os.path.join(self.install_dir, 'bomb.bat')
                with open(bat_path, 'w') as handler:
                    handler.write(bat_str)
                print(('Created: %s' % bat_path))
            except:
                print(('ERROR: Unable to create %s: %s' % (bat_path, err)))
Example #45
0
    def run(self):

        _install_scripts.run(self)

        import os
        basedir = self.install_dir

        dwh_script = os.path.join(basedir, 'dwh')

        for n in ['dwhget', 'dwhput', 'dwhtable']:
            sym = os.path.join(basedir, n)
            if os.path.exists(sym):
                os.unlink(sym)
            print 'linking {0} -> {1}'.format(sym, dwh_script)
            os.symlink(dwh_script, sym)
Example #46
0
    def run(self):
        install_scripts.run(self)

        if sys.platform == 'win32':
            try:
                script_dir = os.path.join(sys.prefix, 'Scripts')
                script_path = os.path.join(script_dir, 'markdown')
                bat_str = '@"%s" "%s" %%*' % (sys.executable, script_path)
                bat_path = os.path.join(self.install_dir, 'markdown.bat')
                f = file(bat_path, 'w')
                f.write(bat_str)
                f.close()
                print 'Created:', bat_path
            except Exception, e:
                print 'ERROR: Unable to create %s: %s' % (bat_path, e)
Example #47
0
 def run(self):
     inst = self.distribution.command_options.get('install')
     vars_2_subst = {'PREFIX': inst['prefix'][1] if 'prefix' in inst else '',
                     #'PREFIXCONF' : os.path.join(get_install_conf_dir(inst), 'integron_finder'),
                     'PREFIXDATA' : os.path.join(get_install_data_dir(inst), 'integron_finder'),
                     #'PREFIXDOC' : os.path.join(get_install_doc_dir(inst), 'integron_finder'),
                     'VERSION' : self.distribution.get_version(),
                     }
     for _file in self.distribution.fix_scripts:
         input_file = os.path.join(self.build_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)
     _install_scripts.run(self)
Example #48
0
    def run(self):
        install_scripts.run(self)

        if sys.platform == 'win32':
            try:
                script_dir = os.path.join(sys.prefix, 'Scripts')
                script_path = os.path.join(script_dir, 'markdown')
                bat_str = '@"%s" "%s" %%*' % (sys.executable, script_path)
                bat_path = os.path.join(self.install_dir, 'markdown.bat')
                f = file(bat_path, 'w')
                f.write(bat_str)
                f.close()
                print('Created:', bat_path)
            except Exception as e:
                print('ERROR: Unable to create %s: %s' % (bat_path, e))
Example #49
0
	def run(self):
		import shutil
		install_scripts.run(self)
		for file in self.get_outputs():
			renamed_file = file[:-3]

			log.info('renaming %s to %s', file, renamed_file)
			shutil.move(file, renamed_file)

			if sys.platform == "win32":
				# Generate batch script for wrapper the python script so we could invoke that
				# script directly from command line
				batch_script = "@echo off\n%s %s %%*" % (sys.executable, renamed_file)
				with open("%s.bat" % renamed_file, "w") as bat_file:
					bat_file.write(batch_script)
Example #50
0
 def run(self):
     install_scripts.run(self)  # standard action
     src = os.path.join(self.install_dir, "texttest")
     dst = src + "c.py"
     if os.path.isfile(dst):
         os.remove(dst)
     os.rename(src, dst)
     with open(src + ".pyw", "w") as writeFile:
         with open(dst) as readFile:
             for line in readFile:
                 if line.startswith("#!"):
                     writeFile.write(
                         line.replace("python.exe", "pythonw.exe"))
                 else:
                     writeFile.write(line)
Example #51
0
 def run(self):
     print("=============install_scripts_and_symlinks run")
     install_scripts.run(self)
     # Replicate symlinks if they don't exist
     print(self)
     print("data_files = ",  dir( self.distribution.data_files))
     print(type(self.distribution.data_files))
     print(self.distribution.data_files)
     for script in self.distribution.scripts:
         print("\n---script = ",script)
         if os.path.islink(script):
             target  = os.readlink(script)
             newlink = os.path.join(self.install_dir, os.path.basename(script))
             if not os.path.exists(newlink):
                 print("++++++++++", target, " -> ", newlink)
Example #52
0
	def run(self):
		install_scripts.run(self)
		if sys.platform == 'win32':
			try:
				script_dir = os.path.join(sys.prefix, 'Scripts')
				script_path = os.path.join(script_dir, script_name)
				bat_str = '@"%s" "%s" %%*' % (sys.executable, script_path)
				bat_path = os.path.join(self.install_dir, '%s.bat' % script_name)
				f = open(bat_path, 'w')
				f.write(bat_str)
				f.close()
				print('Created: %s' % bat_path)
			except Exception:
				_, err, _ = sys.exc_info() # for both 2.x & 3.x compatability
				print('ERROR: Unable to create %s: %s' % (bat_path, err))
Example #53
0
 def run(self):
     print("=============install_scripts_and_symlinks run")
     install_scripts.run(self)
     # Replicate symlinks if they don't exist
     print(self)
     print("data_files = ", dir(self.distribution.data_files))
     print(type(self.distribution.data_files))
     print(self.distribution.data_files)
     for script in self.distribution.scripts:
         print("\n---script = ", script)
         if os.path.islink(script):
             target = os.readlink(script)
             newlink = os.path.join(self.install_dir,
                                    os.path.basename(script))
             if not os.path.exists(newlink):
                 print("++++++++++", target, " -> ", newlink)
Example #54
0
 def run(self):
     install_scripts.run(self)
     if sys.platform == 'win32':
         try:
             script_dir = os.path.join(sys.prefix, 'Scripts')
             script_path = os.path.join(script_dir, script_name)
             bat_str = '@"%s" "%s" %%*' % (sys.executable, script_path)
             bat_path = os.path.join(self.install_dir,
                                     '%s.bat' % script_name)
             f = open(bat_path, 'w')
             f.write(bat_str)
             f.close()
             print('Created: %s' % bat_path)
         except Exception:
             _, err, _ = sys.exc_info()  # for both 2.x & 3.x compatability
             print('ERROR: Unable to create %s: %s' % (bat_path, err))
Example #55
0
    def run(self):
        install_scripts.run(self)  # standard action

        if sys.platform == "win32":
            try:
                scripts_dir = os.path.join(sys.prefix, 'Scripts')
                script_path = self._quoted_path(
                    os.path.join(scripts_dir, "brz"))
                python_exe = self._quoted_path(sys.executable)
                batch_str = "@%s %s %%*" % (python_exe, script_path)
                batch_path = os.path.join(self.install_dir, "brz.bat")
                with open(batch_path, "w") as f:
                    f.write(batch_str)
                print(("Created: %s" % batch_path))
            except Exception:
                e = sys.exc_info()[1]
                print(("ERROR: Unable to create %s: %s" % (batch_path, e)))
Example #56
0
 def run(self):
     install_scripts.run(self)
     for file in self.get_outputs():
         if file.endswith("check.py"):
             new_name = os.path.join(os.path.dirname(file), "power_check")
             os.rename(file, new_name)
             file = new_name
         if os.name == "nt":
             with open(file, "rt") as f:
                 shebang = f.readline()
                 if not shebang.startswith("#!"):
                     continue
             with open(file + ".bat", "wt") as f:
                 f.write(f"@set path=%~dp0\n"
                         f"@set script=%path%{os.path.basename(file)}\n"
                         f"@set /p shebang=<%script%\n"
                         f"@set py=%shebang:~2%\n"
                         f"call %py% %script% %*\n")