Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes15kdownloads
install_scripts.py60 linesDownload Raw Back to command
1"""distutils.command.install_scripts2 3Implements the Distutils 'install_scripts' command, for installing4Python scripts."""5 6# contributed by Bastian Kleineidam7 8import os9from distutils._log import log10from stat import ST_MODE11from typing import ClassVar12 13from ..core import Command14 15 16class install_scripts(Command):17    description = "install scripts (Python or otherwise)"18 19    user_options = [20        ('install-dir=', 'd', "directory to install scripts to"),21        ('build-dir=', 'b', "build directory (where to install from)"),22        ('force', 'f', "force installation (overwrite existing files)"),23        ('skip-build', None, "skip the build steps"),24    ]25 26    boolean_options: ClassVar[list[str]] = ['force', 'skip-build']27 28    def initialize_options(self):29        self.install_dir = None30        self.force = False31        self.build_dir = None32        self.skip_build = None33 34    def finalize_options(self) -> None:35        self.set_undefined_options('build', ('build_scripts', 'build_dir'))36        self.set_undefined_options(37            'install',38            ('install_scripts', 'install_dir'),39            ('force', 'force'),40            ('skip_build', 'skip_build'),41        )42 43    def run(self) -> None:44        if not self.skip_build:45            self.run_command('build_scripts')46        self.outfiles = self.copy_tree(self.build_dir, self.install_dir)47        if os.name == 'posix':48            # Set the executable bits (owner, group, and world) on49            # all the scripts we just installed.50            for file in self.get_outputs():51                mode = ((os.stat(file)[ST_MODE]) | 0o555) & 0o777752                log.info("changing mode of %s to %o", file, mode)53                os.chmod(file, mode)54 55    def get_inputs(self):56        return self.distribution.scripts or []57 58    def get_outputs(self):59        return self.outfiles or []60 
codekingpro/portable-devtools · Team Ai