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


Python sys.executable方法代码示例

本文整理汇总了Python中sys.executable方法的典型用法代码示例。如果您正苦于以下问题:Python sys.executable方法的具体用法?Python sys.executable怎么用?Python sys.executable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在sys的用法示例。


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

示例1: _get_interpreter_argv

# 需要导入模块: import sys [as 别名]
# 或者: from sys import executable [as 别名]
def _get_interpreter_argv():
        """Retrieve current Python interpreter's arguments.

        Returns empty tuple in case of frozen mode, uses built-in arguments
        reproduction function otherwise.

        Frozen mode is possible for the app has been packaged into a binary
        executable using py2exe. In this case the interpreter's arguments are
        already built-in into that executable.

        :seealso: https://github.com/cherrypy/cherrypy/issues/1526
        Ref: https://pythonhosted.org/PyInstaller/runtime-information.html
        """
        return ([]
                if getattr(sys, 'frozen', False)
                else subprocess._args_from_interpreter_flags()) 
开发者ID:cherrypy,项目名称:cherrypy,代码行数:18,代码来源:wspbus.py

示例2: run

# 需要导入模块: import sys [as 别名]
# 或者: from sys import executable [as 别名]
def run(self):
        try:
            self.status('Removing previous builds…')
            rmtree(os.path.join(here, 'dist'))
        except OSError:
            pass

        self.status('Building Source and Wheel (universal) distribution…')
        os.system('{0} setup.py sdist bdist_wheel --universal'.format(
            sys.executable
        ))

        self.status('Uploading the package to PyPi via Twine…')
        os.system('twine upload dist/*')

        sys.exit() 
开发者ID:apirobot,项目名称:django-rest-polymorphic,代码行数:18,代码来源:setup.py

示例3: main

# 需要导入模块: import sys [as 别名]
# 或者: from sys import executable [as 别名]
def main():
    env = os.environ.copy()

    # in case the PYTHONHASHSEED was not set, set to 0 to denote
    # that hash randomization should be disabled and
    # restart python for the changes to take effect
    if 'PYTHONHASHSEED' not in env:
        env['PYTHONHASHSEED'] = "0"
        proc = subprocess.Popen([sys.executable] + sys.argv,
                                env=env)
        proc.communicate()
        exit(proc.returncode)

    # check if hash has been properly de-randomized in python 3
    # by comparing hash of magic tuple
    h = hash(eden.__magic__)
    assert h == eden.__magic_py2hash__ or h == eden.__magic_py3hash__, 'Unexpected hash value: "{}". Please check if python 3 hash normalization is disabled by setting shell variable PYTHONHASHSEED=0.'.format(h)

    # run program and exit
    print("This is the magic python hash restart script.")
    exit(0) 
开发者ID:fabriziocosta,项目名称:EDeN,代码行数:23,代码来源:example_restart_python.py

示例4: run

# 需要导入模块: import sys [as 别名]
# 或者: from sys import executable [as 别名]
def run(self):
        try:
            self.status('Removing previous builds...')
            rmtree(os.path.join(base_path, 'dist'))
        except OSError:
            pass

        self.status('Building Source and Wheel (universal) distribution...')
        os.system('{0} setup.py sdist bdist_wheel'.format(sys.executable))

        self.status('Pushing git tags...')
        os.system('git tag v{0}'.format(get_version()))
        os.system('git push --tags')

        try:
            self.status('Removing build artifacts...')
            rmtree(os.path.join(base_path, 'build'))
            rmtree(os.path.join(base_path, '{}.egg-info'.format(PACKAGE_NAME)))
        except OSError:
            pass

        sys.exit() 
开发者ID:titu1994,项目名称:keras_mixnets,代码行数:24,代码来源:setup.py

示例5: manage

# 需要导入模块: import sys [as 别名]
# 或者: from sys import executable [as 别名]
def manage():
    def call(*args, **kwargs):
        ignore_errors = kwargs.pop("ignore_errors", False)
        assert not kwargs
        cmd = [
            sys.executable,
            os.path.join(os.path.dirname(__file__), "testprj", "manage.py"),
        ] + list(args)
        try:
            return subprocess.check_output(cmd, stderr=subprocess.STDOUT)
        except subprocess.CalledProcessError as e:
            if not ignore_errors:
                raise
            return e.output

    return call 
开发者ID:GaretJax,项目名称:django-click,代码行数:18,代码来源:conftest.py

示例6: shutdown

# 需要导入模块: import sys [as 别名]
# 或者: from sys import executable [as 别名]
def shutdown():
    if lp_events.timer != None:
        lp_events.timer.cancel()
    scripts.to_run = []
    for x in range(9):
        for y in range(9):
            if scripts.threads[x][y] != None:
                scripts.threads[x][y].kill.set()
    if window.lp_connected:
        scripts.unbind_all()
        lp_events.timer.cancel()
        launchpad_connector.disconnect(lp)
        window.lp_connected = False
    logger.stop()
    if window.restart:
        if IS_EXE:
            os.startfile(sys.argv[0])
        else:
            os.execv(sys.executable, ["\"" + sys.executable + "\""] + sys.argv)
    sys.exit("[LPHK] Shutting down...") 
开发者ID:nimaid,项目名称:LPHK,代码行数:22,代码来源:LPHK.py

示例7: save_pyoptix_conf

# 需要导入模块: import sys [as 别名]
# 或者: from sys import executable [as 别名]
def save_pyoptix_conf(nvcc_path, compile_args, include_dirs, library_dirs, libraries):
    try:
        config = ConfigParser()
        config.add_section('pyoptix')

        config.set('pyoptix', 'nvcc_path', nvcc_path)
        config.set('pyoptix', 'compile_args', os.pathsep.join(compile_args))
        config.set('pyoptix', 'include_dirs', os.pathsep.join(include_dirs))
        config.set('pyoptix', 'library_dirs', os.pathsep.join(library_dirs))
        config.set('pyoptix', 'libraries', os.pathsep.join(libraries))

        tmp = NamedTemporaryFile(mode='w+', delete=False)
        config.write(tmp)
        tmp.close()
        config_path = os.path.join(os.path.dirname(sys.executable), 'pyoptix.conf')
        check_call_sudo_if_fails(['cp', tmp.name, config_path])
        check_call_sudo_if_fails(['cp', tmp.name, '/etc/pyoptix.conf'])
        check_call_sudo_if_fails(['chmod', '644', config_path])
        check_call_sudo_if_fails(['chmod', '644', '/etc/pyoptix.conf'])
    except Exception as e:
        print("PyOptiX configuration could not be saved. When you use pyoptix.Compiler, "
              "nvcc path must be in PATH, OptiX library paths must be in LD_LIBRARY_PATH, and pyoptix.Compiler "
              "attributes should be set manually.") 
开发者ID:ozen,项目名称:PyOptiX,代码行数:25,代码来源:setup.py

示例8: test_patch_wheel

# 需要导入模块: import sys [as 别名]
# 或者: from sys import executable [as 别名]
def test_patch_wheel():
    # Check patching of wheel
    with InTemporaryDirectory():
        # First wheel needs proper wheel filename for later unpack test
        out_fname = basename(PURE_WHEEL)
        patch_wheel(PURE_WHEEL, WHEEL_PATCH, out_fname)
        zip2dir(out_fname, 'wheel1')
        with open(pjoin('wheel1', 'fakepkg2', '__init__.py'), 'rt') as fobj:
            assert_equal(fobj.read(), 'print("Am in init")\n')
        # Check that wheel unpack works
        back_tick([sys.executable, '-m', 'wheel', 'unpack', out_fname])
        # Copy the original, check it doesn't have patch
        shutil.copyfile(PURE_WHEEL, 'copied.whl')
        zip2dir('copied.whl', 'wheel2')
        with open(pjoin('wheel2', 'fakepkg2', '__init__.py'), 'rt') as fobj:
            assert_equal(fobj.read(), '')
        # Overwrite input wheel (the default)
        patch_wheel('copied.whl', WHEEL_PATCH)
        # Patched
        zip2dir('copied.whl', 'wheel3')
        with open(pjoin('wheel3', 'fakepkg2', '__init__.py'), 'rt') as fobj:
            assert_equal(fobj.read(), 'print("Am in init")\n')
        # Check bad patch raises error
        assert_raises(RuntimeError,
                      patch_wheel, PURE_WHEEL, WHEEL_PATCH_BAD, 'out.whl') 
开发者ID:matthew-brett,项目名称:delocate,代码行数:27,代码来源:test_wheelies.py

示例9: mpi_fork

# 需要导入模块: import sys [as 别名]
# 或者: from sys import executable [as 别名]
def mpi_fork(n, bind_to_core=False):
    """Re-launches the current script with workers
    Returns "parent" for original parent, "child" for MPI children
    """
    if n<=1: 
        return "child"
    if os.getenv("IN_MPI") is None:
        env = os.environ.copy()
        env.update(
            MKL_NUM_THREADS="1",
            OMP_NUM_THREADS="1",
            IN_MPI="1"
        )
        args = ["mpirun", "-np", str(n)]
        if bind_to_core:
            args += ["-bind-to", "core"]
        args += [sys.executable] + sys.argv
        subprocess.check_call(args, env=env)
        return "parent"
    else:
        return "child" 
开发者ID:Hwhitetooth,项目名称:lirpg,代码行数:23,代码来源:mpi_fork.py

示例10: test_build_calmjs_artifact

# 需要导入模块: import sys [as 别名]
# 或者: from sys import executable [as 别名]
def test_build_calmjs_artifact(self):
        """
        Emulate the execution of ``python setup.py egg_info``.

        Ensure everything is covered.
        """

        # run the step directly to see that the command is registered,
        # though the actual effects cannot be tested, as the test
        # package is not going to be installed and there are no valid
        # artifact build functions defined.
        p = Popen(
            [sys.executable, 'setup.py', 'build_calmjs_artifacts'],
            stdout=PIPE, stderr=PIPE, cwd=self.pkg_root,
        )
        stdout, stderr = p.communicate()
        stdout = stdout.decode(locale)
        self.assertIn('running build_calmjs_artifacts', stdout) 
开发者ID:calmjs,项目名称:calmjs,代码行数:20,代码来源:test_dist.py

示例11: run

# 需要导入模块: import sys [as 别名]
# 或者: from sys import executable [as 别名]
def run(self):
        try:
            self.status('Removing previous builds…')
            rmtree(os.path.join(here, 'dist'))
        except OSError:
            pass

        self.status('Building Source and Wheel (universal) distribution…')
        os.system('{0} setup.py sdist bdist_wheel --universal'.format(sys.executable))

        self.status('Uploading the package to PyPi via Twine…')
        os.system('twine upload dist/*')

        self.status('Pushing git tags…')
        os.system('git tag v{0}'.format(about['__version__']))
        os.system('git push --tags')
        
        sys.exit()


# Where the magic happens: 
开发者ID:zimmerrol,项目名称:keras-utility-layer-collection,代码行数:23,代码来源:setup.py

示例12: mpi_fork

# 需要导入模块: import sys [as 别名]
# 或者: from sys import executable [as 别名]
def mpi_fork(n, extra_mpi_args=[]):
    """Re-launches the current script with workers
    Returns "parent" for original parent, "child" for MPI children
    """
    if n <= 1:
        return "child"
    if os.getenv("IN_MPI") is None:
        env = os.environ.copy()
        env.update(
            MKL_NUM_THREADS="1",
            OMP_NUM_THREADS="1",
            IN_MPI="1"
        )
        # "-bind-to core" is crucial for good performance
        args = ["mpirun", "-np", str(n)] + \
            extra_mpi_args + \
            [sys.executable]

        args += sys.argv
        subprocess.check_call(args, env=env)
        return "parent"
    else:
        install_mpi_excepthook()
        return "child" 
开发者ID:MaxSobolMark,项目名称:HardRLWithYoutube,代码行数:26,代码来源:util.py

示例13: read_config

# 需要导入模块: import sys [as 别名]
# 或者: from sys import executable [as 别名]
def read_config():
    _dict = {}
    if getattr(sys, 'frozen', None):
        config_path = os.path.join(os.path.dirname(sys.executable), 'config', 'config.ini')
    else:
        config_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'config.ini')

    if not os.path.exists(config_path):
        print('can not find the config.ini, use the default sm uploader.'
              'attention: this website may breakdown in the future, only used temporarily.')
        _dict['picture_host'] = 'SmUploader'
        return _dict
    configs = ConfigParser()
    configs.read(config_path)
    _dict['picture_folder'] = configs['basic'].get('picture_folder', '')
    _dict['picture_suffix'] = configs['basic'].get('picture_suffix', '')
    _dict['picture_host'] = configs['basic'].get('picture_host', '')
    _dict['config_path'] = config_path

    if _dict['picture_host']:
        _dict['uploader_info'] = configs[_dict['picture_host']]

    return _dict 
开发者ID:kingname,项目名称:MarkdownPicPicker,代码行数:25,代码来源:__init__.py

示例14: test

# 需要导入模块: import sys [as 别名]
# 或者: from sys import executable [as 别名]
def test(coverage=False):
    """Run the unit tests."""
    if coverage and not os.environ.get('FLASK_COVERAGE'):
        import sys
        os.environ['FLASK_COVERAGE'] = '1'
        os.execvp(sys.executable, [sys.executable] + sys.argv)
    import unittest
    import xmlrunner
    tests = unittest.TestLoader().discover('tests')
    # run tests with unittest-xml-reporting and output to $CIRCLE_TEST_REPORTS on CircleCI or test-reports locally
    xmlrunner.XMLTestRunner(output=os.environ.get('CIRCLE_TEST_REPORTS','test-reports')).run(tests)
    if COV:
        COV.stop()
        COV.save()
        print('Coverage Summary:')
        COV.report()
        basedir = os.path.abspath(os.path.dirname(__file__))
        covdir = os.path.join(basedir, 'tmp/coverage')
        COV.html_report(directory=covdir)
        print('HTML version: file://%s/index.html' % covdir)
        COV.erase() 
开发者ID:CircleCI-Public,项目名称:circleci-demo-python-flask,代码行数:23,代码来源:manage.py

示例15: get_resource_path

# 需要导入模块: import sys [as 别名]
# 或者: from sys import executable [as 别名]
def get_resource_path(*args):
  if is_frozen():
    # MEIPASS explanation:
    # https://pythonhosted.org/PyInstaller/#run-time-operation
    basedir = getattr(sys, '_MEIPASS', None)
    if not basedir:
      basedir = os.path.dirname(sys.executable)
    resource_dir = os.path.join(basedir, 'gooey')
    if not os.path.isdir(resource_dir):
      raise IOError(
        ("Cannot locate Gooey resources. It seems that the program was frozen, "
         "but resource files were not copied into directory of the executable "
         "file. Please copy `languages` and `images` folders from gooey module "
         "directory into `{}{}` directory. Using PyInstaller, a.datas in .spec "
         "file must be specified.".format(resource_dir, os.sep)))
  else:
    resource_dir = os.path.normpath(os.path.join(os.path.dirname(__file__), '..', '..'))
  return os.path.join(resource_dir, *args) 
开发者ID:ME-ICA,项目名称:me-ica,代码行数:20,代码来源:freeze.py


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