当前位置: 首页>>代码示例>>Python>>正文


Python sysconfig.get_python_version函数代码示例

本文整理汇总了Python中sysconfig.get_python_version函数的典型用法代码示例。如果您正苦于以下问题:Python get_python_version函数的具体用法?Python get_python_version怎么用?Python get_python_version使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了get_python_version函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: finalize_options

    def finalize_options(self):
        self.set_undefined_options("bdist", ("skip_build", "skip_build"))
        if self.bdist_dir is None:
            bdist_base = self.get_finalized_command("bdist").bdist_base
            self.bdist_dir = os.path.join(bdist_base, "msi")
        short_version = get_python_version()
        if not self.target_version and self.distribution.has_ext_modules():
            self.target_version = short_version
        if self.target_version:
            self.versions = [self.target_version]
            if not self.skip_build and self.distribution.has_ext_modules() and self.target_version != short_version:
                raise DistutilsOptionError, "target version can only be %s, or the '--skip-build' option must be specified" % (
                    short_version,
                )
        else:
            self.versions = list(self.all_versions)
        self.set_undefined_options("bdist", ("dist_dir", "dist_dir"), ("plat_name", "plat_name"))
        if self.pre_install_script:
            raise DistutilsOptionError, "the pre-install-script feature is not yet implemented"
        if self.install_script:
            for script in self.distribution.scripts:
                if self.install_script == os.path.basename(script):
                    break
            else:
                raise DistutilsOptionError, "install_script '%s' not found in scripts" % self.install_script

        self.install_script_key = None
        return
开发者ID:webiumsk,项目名称:WOT-0.9.12,代码行数:28,代码来源:bdist_msi.py

示例2: get_install_args

    def get_install_args(
        self,
        global_options,  # type: Sequence[str]
        record_filename,  # type: str
        root,  # type: Optional[str]
        prefix,  # type: Optional[str]
        pycompile  # type: bool
    ):
        # type: (...) -> List[str]
        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]
        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 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
开发者ID:pfmoore,项目名称:pip,代码行数:33,代码来源:req_install.py

示例3: finalize_options

    def finalize_options(self):
        self.set_undefined_options("bdist", ("skip_build", "skip_build"))

        if self.bdist_dir is None:
            if self.skip_build and self.plat_name:
                # If build is skipped and plat_name is overridden, bdist will
                # not see the correct 'plat_name' - so set that up manually.
                bdist = self.distribution.get_command_obj("bdist")
                bdist.plat_name = self.plat_name
                # next the command will be initialized using that name
            bdist_base = self.get_finalized_command("bdist").bdist_base
            self.bdist_dir = os.path.join(bdist_base, "wininst")

        if not self.target_version:
            self.target_version = ""

        if not self.skip_build and self.distribution.has_ext_modules():
            short_version = get_python_version()
            if self.target_version and self.target_version != short_version:
                raise DistutilsOptionError, "target version can only be %s, or the '--skip-build'" " option must be specified" % (
                    short_version,
                )
            self.target_version = short_version

        self.set_undefined_options("bdist", ("dist_dir", "dist_dir"), ("plat_name", "plat_name"))

        if self.install_script:
            for script in self.distribution.scripts:
                if self.install_script == os.path.basename(script):
                    break
            else:
                raise DistutilsOptionError, "install_script '%s' not found in scripts" % self.install_script
开发者ID:kappaIO-Dev,项目名称:kappaIO-toolchain-crosscompile-armhf,代码行数:32,代码来源:bdist_wininst.py

示例4: sysconfig2

def sysconfig2():
    # import sysconfig module - Provide access to Python’s configuration information
    import sysconfig

    # returns an installation path corresponding to the path name
    print("Path Name : ", sysconfig.get_path("stdlib"))
    print()

    # returns a string that identifies the current platform.
    print("Current Platform : ", sysconfig.get_platform())
    print()

    # returns the MAJOR.MINOR Python version number as a string
    print("Python Version Number : ", sysconfig.get_python_version())
    print()

    # returns a tuple containing all path names
    print("Path Names : ", sysconfig.get_path_names())
    print()

    # returns a tuple containing all schemes
    print("Scheme Names : ", sysconfig.get_scheme_names())
    print()

    # returns the value of a single variable name.
    print("Variable name LIBDIR : ", sysconfig.get_config_var('LIBDIR'))

    # returns the value of a single variable name.
    print("Variable name LIBDEST : ", sysconfig.get_config_var('LIBDEST'))
开发者ID:mcclayac,项目名称:LearnSmart1,代码行数:29,代码来源:sysconfigExample.py

示例5: run

 def run(self):
     if not self.skip_build:
         self.run_command('build')
     install = self.reinitialize_command('install', reinit_subcommands=1)
     install.root = self.bdist_dir
     install.skip_build = self.skip_build
     install.warn_dir = 0
     log.info('installing to %s' % self.bdist_dir)
     self.run_command('install')
     archive_basename = '%s.%s' % (self.distribution.get_fullname(), self.plat_name)
     if os.name == 'os2':
         archive_basename = archive_basename.replace(':', '-')
     pseudoinstall_root = os.path.join(self.dist_dir, archive_basename)
     if not self.relative:
         archive_root = self.bdist_dir
     elif self.distribution.has_ext_modules() and install.install_base != install.install_platbase:
         raise DistutilsPlatformError, "can't make a dumb built distribution where base and platbase are different (%s, %s)" % (repr(install.install_base), repr(install.install_platbase))
     else:
         archive_root = os.path.join(self.bdist_dir, ensure_relative(install.install_base))
     filename = self.make_archive(pseudoinstall_root, self.format, root_dir=archive_root, owner=self.owner, group=self.group)
     if self.distribution.has_ext_modules():
         pyversion = get_python_version()
     else:
         pyversion = 'any'
     self.distribution.dist_files.append(('bdist_dumb', pyversion, filename))
     if not self.keep_temp:
         remove_tree(self.bdist_dir, dry_run=self.dry_run)
开发者ID:webiumsk,项目名称:WOT-0.9.15-CT,代码行数:27,代码来源:bdist_dumb.py

示例6: main

def main():
    ''' main function '''

    parser = argparse.ArgumentParser(description='lvdb wrapper for gdb. Assumes .gdbinit contains at least "set logging on."')
    parser.add_argument("fname", help='a binary that to be called with gdb')
    parser.add_argument("-d", "--debug", action="store_true", help="whether to output debugging information in gdb_monitor.log")
    args = parser.parse_args()

    # start monitor with same version of python in the background
    # this is in case the default system version (say 2.6) does not have
    # IPython installed
    python_bin = 'python' + str(sysconfig.get_python_version())
    pid = subprocess.Popen([python_bin, '-c', "import lvdb; lvdb.monitor_gdb_file({})".format(args.debug)]).pid

    # start gdb (waiting until it exits)
    subprocess.call(['gdb', '-x', '.gdbinit', args.fname])

    # kill the gdb monitor and remove temporary files
    subprocess.call(['kill', str(pid)])

    for f in ['.debug_gdb_objs', '.debug_location', '.debug_breakpoint']:
        try:
            os.remove(f)
        except OSError:
            pass
开发者ID:esquires,项目名称:vim-pdb,代码行数:25,代码来源:vim_gdb.py

示例7: finalize_options

    def finalize_options (self):
        if self.bdist_dir is None:
            bdist_base = self.get_finalized_command('bdist').bdist_base
            self.bdist_dir = os.path.join(bdist_base, 'msi')
        short_version = get_python_version()
        if (not self.target_version) and self.distribution.has_ext_modules():
            self.target_version = short_version
        if self.target_version:
            self.versions = [self.target_version]
            if not self.skip_build and self.distribution.has_ext_modules()\
               and self.target_version != short_version:
                raise DistutilsOptionError, \
                      "target version can only be %s, or the '--skip_build'" \
                      " option must be specified" % (short_version,)
        else:
            self.versions = list(self.all_versions)

        self.set_undefined_options('bdist',
                                   ('dist_dir', 'dist_dir'),
                                   ('plat_name', 'plat_name'),
                                   )

        if self.pre_install_script:
            raise DistutilsOptionError, "the pre-install-script feature is not yet implemented"

        if self.install_script:
            for script in self.distribution.scripts:
                if self.install_script == os.path.basename(script):
                    break
            else:
                raise DistutilsOptionError, \
                      "install_script '%s' not found in scripts" % \
                      self.install_script
        self.install_script_key = None
开发者ID:TimSC,项目名称:PyEmbed,代码行数:34,代码来源:bdist_msi.py

示例8: test_editable_egg_conflict

def test_editable_egg_conflict(tmpdir):
    conflicting_package = tmpdir / 'tmp/conflicting_package'
    many_versions_package_2 = tmpdir / 'tmp/many_versions_package_2'

    from shutil import copytree
    copytree(
        str(T.TOP / 'tests/testing/packages/conflicting_package'),
        str(conflicting_package),
    )

    copytree(
        str(T.TOP / 'tests/testing/packages/many_versions_package_2'),
        str(many_versions_package_2),
    )

    with many_versions_package_2.as_cwd():
        from sys import executable as python
        T.run(python, 'setup.py', 'bdist_egg', '--dist-dir', str(conflicting_package))

    with tmpdir.as_cwd():
        T.requirements('-r %s/requirements.d/coverage.txt' % T.TOP)
        T.venv_update()

        T.requirements('-e %s' % conflicting_package)
        with pytest.raises(CalledProcessError) as excinfo:
            T.venv_update()
        assert excinfo.value.returncode == 1
        out, err = excinfo.value.result

        err = T.strip_coverage_warnings(err)
        assert err == ''

        out = T.uncolor(out)
        expected = '\nSuccessfully installed many-versions-package conflicting-package\n'
        assert expected in out
        rest = out.rsplit(expected, 1)[-1]

        if True:  # :pragma:nocover:pylint:disable=using-constant-test
            # Debian de-vendorizes the version of pip it ships
            try:
                from sysconfig import get_python_version
            except ImportError:  # <= python2.6
                from distutils.sysconfig import get_python_version
        assert (
            '''\
Cleaning up...
Error: version conflict: many-versions-package 2 (tmp/conflicting_package/many_versions_package-2-py{0}.egg)'''
            ''' <-> many-versions-package<2 (from conflicting-package==1->-r requirements.txt (line 1))
Storing debug log for failure in {1}/home/.pip/pip.log

Something went wrong! Sending 'venv' back in time, so make knows it's invalid.
'''.format(get_python_version(), tmpdir)
        ) == rest

        assert_venv_marked_invalid(tmpdir.join('venv'))
开发者ID:jolynch,项目名称:pip-faster,代码行数:55,代码来源:conflict_test.py

示例9: run

    def run(self):
        if not self.skip_build:
            self.run_command('build')

        install = self.get_reinitialized_command('install', reinit_subcommands=1)
        install.root = self.bdist_dir
        install.skip_build = self.skip_build
        install.warn_dir = 0

        log.info("installing to %s" % self.bdist_dir)
        self.run_command('install')

        # And make an archive relative to the root of the
        # pseudo-installation tree.
        archive_basename = "%s.%s" % (self.distribution.get_fullname(),
                                      self.plat_name)

        # OS/2 objects to any ":" characters in a filename (such as when
        # a timestamp is used in a version) so change them to hyphens.
        if os.name == "os2":
            archive_basename = archive_basename.replace(":", "-")

        pseudoinstall_root = os.path.join(self.dist_dir, archive_basename)
        if not self.relative:
            archive_root = self.bdist_dir
        else:
            if (self.distribution.has_ext_modules() and
                (install.install_base != install.install_platbase)):
                raise DistutilsPlatformError, \
                      ("can't make a dumb built distribution where "
                       "base and platbase are different (%s, %s)"
                       % (repr(install.install_base),
                          repr(install.install_platbase)))
            else:
                archive_root = os.path.join(
                    self.bdist_dir,
                    self._ensure_relative(install.install_base))

        # Make the archive
        filename = self.make_archive(pseudoinstall_root,
                                     self.format, root_dir=archive_root,
                                     owner=self.owner, group=self.group)
        if self.distribution.has_ext_modules():
            pyversion = get_python_version()
        else:
            pyversion = 'any'
        self.distribution.dist_files.append(('bdist_dumb', pyversion,
                                             filename))

        if not self.keep_temp:
            if self.dry_run:
                log.info('Removing %s' % self.bdist_dir)
            else:
                rmtree(self.bdist_dir)
开发者ID:irslambouf,项目名称:SyncServer,代码行数:54,代码来源:bdist_dumb.py

示例10: _tagged_ext_name

def _tagged_ext_name(base):
  uname = platform.uname()
  tags = (
      grpc_version.VERSION,
      'py{}'.format(sysconfig.get_python_version()),
      uname[0],
      uname[4],
  )
  ucs = 'ucs{}'.format(sysconfig.get_config_var('Py_UNICODE_SIZE'))
  return '{base}-{tags}-{ucs}'.format(
      base=base, tags='-'.join(tags), ucs=ucs)
开发者ID:Aj0Ay,项目名称:grpc,代码行数:11,代码来源:precompiled.py

示例11: get_python_version

def get_python_version(compat):
    """Return the version of Python that an app will use.

    Based on the compat level.
    """
    if compat < 5:
        return '2.7'
    if sys.version_info.major == 3:
        return sysconfig.get_python_version()
    return subprocess.check_output((
        'python3', '-c',
        'import sysconfig; print(sysconfig.get_python_version())'
    )).strip()
开发者ID:yola,项目名称:yodeploy,代码行数:13,代码来源:virtualenv.py

示例12: create_ve

def create_ve(
        app_dir, python_version, platform, pypi=None,
        req_file='requirements.txt',
        verify_req_install=True):
    log.info('Building virtualenv')
    ve_dir = os.path.join(app_dir, 'virtualenv')
    ve_python = os.path.join(ve_dir, 'bin', 'python')
    req_file = os.path.join(os.path.abspath(app_dir), req_file)

    # The venv module makes a lot of our reclocateability problems go away, so
    # we only use the virtualenv library on Python 2.
    if python_version.startswith('3.'):
        subprocess.check_call((
            'python%s' % python_version, '-m', 'venv', ve_dir))
        pip_version = subprocess.check_output((
            ve_python, '-c', 'import ensurepip; print(ensurepip.version())'))
        if parse_version(pip_version) < parse_version('9'):
            pip_install(ve_dir, pypi, '-U', 'pip')
        pip_install(ve_dir, pypi, 'wheel')

    elif python_version == sysconfig.get_python_version():
        virtualenv.create_environment(ve_dir, site_packages=False)
    else:
        subprocess.check_call((
            sys.executable, virtualenv.__file__.rstrip('c'),
            '-p', 'python%s' % python_version,
            '--no-site-packages', ve_dir))

    log.info('Installing requirements')
    pip_install(ve_dir, pypi, '-r', req_file)

    if verify_req_install:
        log.info('Verifying requirements were met')
        check_requirements(ve_dir)

    relocateable_ve(ve_dir, python_version)

    ve_id = get_id(os.path.join(app_dir, req_file), python_version, platform)
    with open(os.path.join(ve_dir, '.hash'), 'w') as f:
        f.write(ve_id)
        f.write('\n')

    log.info('Building virtualenv tarball')
    cwd = os.getcwd()
    os.chdir(app_dir)
    t = tarfile.open('virtualenv.tar.gz', 'w:gz')
    try:
        t.add('virtualenv')
    finally:
        t.close()
        os.chdir(cwd)
开发者ID:yola,项目名称:yodeploy,代码行数:51,代码来源:virtualenv.py

示例13: finalize_options

 def finalize_options(self):
     orig_bdist_egg.finalize_options(self)
     
     # Redo the calculation of the egg's filename since we always have
     # extension modules, but they are not built by setuptools so it
     # doesn't know about them.
     from pkg_resources import Distribution
     from sysconfig import get_python_version
     basename = Distribution(
         None, None, self.ei_cmd.egg_name, self.ei_cmd.egg_version,
         get_python_version(),
         self.plat_name
     ).egg_name()
     self.egg_output = os.path.join(self.dist_dir, basename+'.egg')
开发者ID:ssbb,项目名称:Phoenix,代码行数:14,代码来源:setup.py

示例14: print_benchmarks

def print_benchmarks(times):
    ''' Pretty print for the benchmark results,
        with a detailed CSV at the end.
    '''
    print('\nmazelib benchmarking')
    print(datetime.now().strftime('%Y-%m-%d %H:%M'))
    print('Python version: ' + get_python_version())
    print('\nTotal Time (seconds): %.5f\n' %
          sum([sum(times_row) for times_row in times]))

    print('\nmaze size,' + ','.join([str(s) for s in SIZES]))
    for row in range(len(times)):
        method = GENERATORS[row] + '-' + SOLVERS[row] + ','
        print(method + ','.join(['%.5f' % time for time in times[row]]))
开发者ID:Ridhwanluthra,项目名称:mazelib,代码行数:14,代码来源:benchmarks.py

示例15: get_exe_bytes

        def get_exe_bytes (self):
            cur_version = get_python_version()
            bv=9.0
            directory = os.path.dirname(_bdist_file)
            if self.plat_name != 'win32' and self.plat_name[:3] == 'win':
                sfix = self.plat_name[3:]
            else:
                sfix = ''

            filename = os.path.join(directory, "wininst-%.1f%s.exe" % (bv, sfix))
            f = open(filename, "rb")
            try:
                return f.read()
            finally:
                f.close()
开发者ID:ronidrori,项目名称:gdal-calculations,代码行数:15,代码来源:setup.py


注:本文中的sysconfig.get_python_version函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。