python类executable()的实例源码

wheel.py 文件源码 项目:python- 作者: secondtonone1 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def _base_setup_args(self, req):
        return [
            sys.executable, "-u", '-c',
            SETUPTOOLS_SHIM % req.setup_py
        ] + list(self.global_options)
req_install.py 文件源码 项目:python- 作者: secondtonone1 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def get_install_args(self, global_options, record_filename, root, prefix):
        install_args = [sys.executable, "-u"]
        install_args.append('-c')
        install_args.append(SETUPTOOLS_SHIM % self.setup_py)
        install_args += list(global_options) + \
            ['install', '--record', record_filename]

        if not self.as_egg:
            install_args += ['--single-version-externally-managed']

        if root is not None:
            install_args += ['--root', root]
        if prefix is not None:
            install_args += ['--prefix', prefix]

        if self.pycompile:
            install_args += ["--compile"]
        else:
            install_args += ["--no-compile"]

        if running_under_virtualenv():
            py_ver_str = 'python' + sysconfig.get_python_version()
            install_args += ['--install-headers',
                             os.path.join(sys.prefix, 'include', 'site',
                                          py_ver_str, self.name)]

        return install_args
req_install.py 文件源码 项目:python- 作者: secondtonone1 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def install_editable(self, install_options,
                         global_options=(), prefix=None):
        logger.info('Running setup.py develop for %s', self.name)

        if self.isolated:
            global_options = list(global_options) + ["--no-user-cfg"]

        if prefix:
            prefix_param = ['--prefix={0}'.format(prefix)]
            install_options = list(install_options) + prefix_param

        with indent_log():
            # FIXME: should we do --install-headers here too?
            call_subprocess(
                [
                    sys.executable,
                    '-c',
                    SETUPTOOLS_SHIM % self.setup_py
                ] +
                list(global_options) +
                ['develop', '--no-deps'] +
                list(install_options),

                cwd=self.setup_py_dir,
                show_stdout=False)

        self.install_succeeded = True
test_tagopt.py 文件源码 项目:python- 作者: secondtonone1 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def test_default_tag(temp_pkg):
    subprocess.check_call([sys.executable, 'setup.py', 'bdist_wheel'],
            cwd=str(temp_pkg))
    dist_dir = temp_pkg.join('dist')
    assert dist_dir.check(dir=1)
    wheels = dist_dir.listdir()
    assert len(wheels) == 1
    assert wheels[0].basename == 'Test-1.0-py%s-none-any.whl' % (sys.version[0],)
    assert wheels[0].ext == '.whl'
test_tagopt.py 文件源码 项目:python- 作者: secondtonone1 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def test_universal_tag(temp_pkg):
    subprocess.check_call(
        [sys.executable, 'setup.py', 'bdist_wheel', '--universal'],
        cwd=str(temp_pkg))
    dist_dir = temp_pkg.join('dist')
    assert dist_dir.check(dir=1)
    wheels = dist_dir.listdir()
    assert len(wheels) == 1
    assert wheels[0].basename.startswith('Test-1.0-py2.py3-')
    assert wheels[0].ext == '.whl'
test_tagopt.py 文件源码 项目:python- 作者: secondtonone1 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def test_universal_beats_explicit_tag(temp_pkg):
    subprocess.check_call(
        [sys.executable, 'setup.py', 'bdist_wheel', '--universal', '--python-tag=py32'],
        cwd=str(temp_pkg))
    dist_dir = temp_pkg.join('dist')
    assert dist_dir.check(dir=1)
    wheels = dist_dir.listdir()
    assert len(wheels) == 1
    assert wheels[0].basename.startswith('Test-1.0-py2.py3-')
    assert wheels[0].ext == '.whl'
test_tagopt.py 文件源码 项目:python- 作者: secondtonone1 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def test_universal_in_setup_cfg(temp_pkg):
    temp_pkg.join('setup.cfg').write('[bdist_wheel]\nuniversal=1')
    subprocess.check_call(
        [sys.executable, 'setup.py', 'bdist_wheel'],
        cwd=str(temp_pkg))
    dist_dir = temp_pkg.join('dist')
    assert dist_dir.check(dir=1)
    wheels = dist_dir.listdir()
    assert len(wheels) == 1
    assert wheels[0].basename.startswith('Test-1.0-py2.py3-')
    assert wheels[0].ext == '.whl'
test_tagopt.py 文件源码 项目:python- 作者: secondtonone1 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def test_pythontag_in_setup_cfg(temp_pkg):
    temp_pkg.join('setup.cfg').write('[bdist_wheel]\npython_tag=py32')
    subprocess.check_call(
        [sys.executable, 'setup.py', 'bdist_wheel'],
        cwd=str(temp_pkg))
    dist_dir = temp_pkg.join('dist')
    assert dist_dir.check(dir=1)
    wheels = dist_dir.listdir()
    assert len(wheels) == 1
    assert wheels[0].basename.startswith('Test-1.0-py32-')
    assert wheels[0].ext == '.whl'
test_tagopt.py 文件源码 项目:python- 作者: secondtonone1 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def test_legacy_wheel_section_in_setup_cfg(temp_pkg):
    temp_pkg.join('setup.cfg').write('[wheel]\nuniversal=1')
    subprocess.check_call(
        [sys.executable, 'setup.py', 'bdist_wheel'],
        cwd=str(temp_pkg))
    dist_dir = temp_pkg.join('dist')
    assert dist_dir.check(dir=1)
    wheels = dist_dir.listdir()
    assert len(wheels) == 1
    assert wheels[0].basename.startswith('Test-1.0-py2.py3-')
    assert wheels[0].ext == '.whl'
test_tagopt.py 文件源码 项目:python- 作者: secondtonone1 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def test_plat_name_ext(temp_ext_pkg):
    try:
        subprocess.check_call(
            [sys.executable, 'setup.py', 'bdist_wheel', '--plat-name=testplat.arch'],
            cwd=str(temp_ext_pkg))
    except subprocess.CalledProcessError:
        pytest.skip("Cannot compile C Extensions")
    dist_dir = temp_ext_pkg.join('dist')
    assert dist_dir.check(dir=1)
    wheels = dist_dir.listdir()
    assert len(wheels) == 1
    assert wheels[0].basename.endswith('-testplat_arch.whl')
    assert wheels[0].ext == '.whl'
test_tagopt.py 文件源码 项目:python- 作者: secondtonone1 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def test_plat_name_purepy_in_setupcfg(temp_pkg):
    temp_pkg.join('setup.cfg').write('[bdist_wheel]\nplat_name=testplat.pure')
    subprocess.check_call(
        [sys.executable, 'setup.py', 'bdist_wheel'],
        cwd=str(temp_pkg))
    dist_dir = temp_pkg.join('dist')
    assert dist_dir.check(dir=1)
    wheels = dist_dir.listdir()
    assert len(wheels) == 1
    assert wheels[0].basename.endswith('-testplat_pure.whl')
    assert wheels[0].ext == '.whl'
test_tagopt.py 文件源码 项目:python- 作者: secondtonone1 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def test_plat_name_ext_in_setupcfg(temp_ext_pkg):
    temp_ext_pkg.join('setup.cfg').write('[bdist_wheel]\nplat_name=testplat.arch')
    try:
        subprocess.check_call(
            [sys.executable, 'setup.py', 'bdist_wheel'],
            cwd=str(temp_ext_pkg))
    except subprocess.CalledProcessError:
        pytest.skip("Cannot compile C Extensions")
    dist_dir = temp_ext_pkg.join('dist')
    assert dist_dir.check(dir=1)
    wheels = dist_dir.listdir()
    assert len(wheels) == 1
    assert wheels[0].basename.endswith('-testplat_arch.whl')
    assert wheels[0].ext == '.whl'
install_scripts.py 文件源码 项目:python- 作者: secondtonone1 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def run(self):
        import setuptools.command.easy_install as ei

        self.run_command("egg_info")
        if self.distribution.scripts:
            orig.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')
        exec_param = getattr(bs_cmd, 'executable', None)
        bw_cmd = self.get_finalized_command("bdist_wininst")
        is_wininst = getattr(bw_cmd, '_is_running', False)
        writer = ei.ScriptWriter
        if is_wininst:
            exec_param = "python.exe"
            writer = ei.WindowsScriptWriter
        if exec_param == sys.executable:
            # In case the path to the Python executable contains a space, wrap
            # it so it's not split up.
            exec_param = [exec_param]
        # resolve the writer to the environment
        writer = writer.best()
        cmd = writer.command_spec_class.best().from_param(exec_param)
        for args in writer.get_args(dist, cmd.as_header()):
            self.write_script(*args)
easy_install.py 文件源码 项目:python- 作者: secondtonone1 项目源码 文件源码 阅读 34 收藏 0 点赞 0 评论 0
def write_script(self, script_name, contents, mode="t", blockers=()):
        """Write an executable file to the scripts directory"""
        self.delete_blockers(  # clean up old .py/.pyw w/o a script
            [os.path.join(self.script_dir, x) for x in blockers]
        )
        log.info("Installing %s script to %s", script_name, self.script_dir)
        target = os.path.join(self.script_dir, script_name)
        self.add_output(target)

        mask = current_umask()
        if not self.dry_run:
            ensure_directory(target)
            if os.path.exists(target):
                os.unlink(target)
            with open(target, "w" + mode) as f:
                f.write(contents)
            chmod(target, 0o777 - mask)
easy_install.py 文件源码 项目:python- 作者: secondtonone1 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def report_editable(self, spec, setup_script):
        dirname = os.path.dirname(setup_script)
        python = sys.executable
        return '\n' + self.__editable_msg % locals()
easy_install.py 文件源码 项目:python- 作者: secondtonone1 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def is_sh(executable):
    """Determine if the specified executable is a .sh (contains a #! line)"""
    try:
        with io.open(executable, encoding='latin-1') as fp:
            magic = fp.read(2)
    except (OSError, IOError):
        return executable
    return magic == '#!'
easy_install.py 文件源码 项目:python- 作者: secondtonone1 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def _sys_executable(cls):
        _default = os.path.normpath(sys.executable)
        return os.environ.get('__PYVENV_LAUNCHER__', _default)
easy_install.py 文件源码 项目:python- 作者: secondtonone1 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def get_script_args(cls, dist, executable=None, wininst=False):
        # for backward compatibility
        warnings.warn("Use get_args", DeprecationWarning)
        writer = (WindowsScriptWriter if wininst else ScriptWriter).best()
        header = cls.get_script_header("", executable, wininst)
        return writer.get_args(dist, header)
easy_install.py 文件源码 项目:python- 作者: secondtonone1 项目源码 文件源码 阅读 29 收藏 0 点赞 0 评论 0
def get_header(cls, script_text="", executable=None):
        """Create a #! line, getting options (if any) from script_text"""
        cmd = cls.command_spec_class.best().from_param(executable)
        cmd.install_options(script_text)
        return cmd.as_header()
easy_install.py 文件源码 项目:python- 作者: secondtonone1 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def best(cls):
        """
        Select the best ScriptWriter suitable for Windows
        """
        writer_lookup = dict(
            executable=WindowsExecutableLauncherWriter,
            natural=cls,
        )
        # for compatibility, use the executable launcher by default
        launcher = os.environ.get('SETUPTOOLS_LAUNCHER', 'executable')
        return writer_lookup[launcher]


问题


面经


文章

微信
公众号

扫码关注公众号