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


Python sys.dont_write_bytecode方法代码示例

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


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

示例1: byte_compile

# 需要导入模块: import sys [as 别名]
# 或者: from sys import dont_write_bytecode [as 别名]
def byte_compile(self, to_compile):
        if sys.dont_write_bytecode:
            self.warn('byte-compiling is disabled, skipping.')
            return

        from distutils.util import byte_compile

        try:
            # try to make the byte compile messages quieter
            log.set_verbosity(self.verbose - 1)

            byte_compile(to_compile, optimize=0, force=1, dry_run=self.dry_run)
            if self.optimize:
                byte_compile(
                    to_compile, optimize=self.optimize, force=1,
                    dry_run=self.dry_run
                )
        finally:
            log.set_verbosity(self.verbose)  # restore original verbosity 
开发者ID:jpush,项目名称:jbox,代码行数:21,代码来源:easy_install.py

示例2: byte_compile

# 需要导入模块: import sys [as 别名]
# 或者: from sys import dont_write_bytecode [as 别名]
def byte_compile(self, to_compile):
        if sys.dont_write_bytecode:
            self.warn('byte-compiling is disabled, skipping.')
            return

        from distutils.util import byte_compile

        try:
            # try to make the byte compile messages quieter
            log.set_verbosity(self.verbose - 1)

            byte_compile(to_compile, optimize=0, force=1, dry_run=self.dry_run)
            if self.optimize:
                byte_compile(
                    to_compile, optimize=self.optimize, force=1,
                    dry_run=self.dry_run,
                )
        finally:
            log.set_verbosity(self.verbose)  # restore original verbosity 
开发者ID:sofia-netsurv,项目名称:python-netsurv,代码行数:21,代码来源:easy_install.py

示例3: byte_compile

# 需要导入模块: import sys [as 别名]
# 或者: from sys import dont_write_bytecode [as 别名]
def byte_compile(self, files):
        if sys.dont_write_bytecode:
            self.warn('byte-compiling is disabled, skipping.')
            return

        from distutils.util import byte_compile
        prefix = self.build_lib
        if prefix[-1] != os.sep:
            prefix = prefix + os.sep

        # XXX this code is essentially the same as the 'byte_compile()
        # method of the "install_lib" command, except for the determination
        # of the 'prefix' string.  Hmmm.

        if self.compile:
            byte_compile(files, optimize=0,
                         force=self.force, prefix=prefix, dry_run=self.dry_run)
        if self.optimize > 0:
            byte_compile(files, optimize=self.optimize,
                         force=self.force, prefix=prefix, dry_run=self.dry_run) 
开发者ID:glmcdona,项目名称:meddle,代码行数:22,代码来源:build_py.py

示例4: byte_compile

# 需要导入模块: import sys [as 别名]
# 或者: from sys import dont_write_bytecode [as 别名]
def byte_compile(self, files):
        if sys.dont_write_bytecode:
            self.warn('byte-compiling is disabled, skipping.')
            return

        from distutils.util import byte_compile

        # Get the "--root" directory supplied to the "install" command,
        # and use it as a prefix to strip off the purported filename
        # encoded in bytecode files.  This is far from complete, but it
        # should at least generate usable bytecode in RPM distributions.
        install_root = self.get_finalized_command('install').root

        if self.compile:
            byte_compile(files, optimize=0,
                         force=self.force, prefix=install_root,
                         dry_run=self.dry_run)
        if self.optimize > 0:
            byte_compile(files, optimize=self.optimize,
                         force=self.force, prefix=install_root,
                         verbose=self.verbose, dry_run=self.dry_run)


    # -- Utility methods ----------------------------------------------- 
开发者ID:glmcdona,项目名称:meddle,代码行数:26,代码来源:install_lib.py

示例5: byte_compile

# 需要导入模块: import sys [as 别名]
# 或者: from sys import dont_write_bytecode [as 别名]
def byte_compile(self, to_compile):
        if sys.dont_write_bytecode:
            return

        from distutils.util import byte_compile

        try:
            # try to make the byte compile messages quieter
            log.set_verbosity(self.verbose - 1)

            byte_compile(to_compile, optimize=0, force=1, dry_run=self.dry_run)
            if self.optimize:
                byte_compile(
                    to_compile, optimize=self.optimize, force=1,
                    dry_run=self.dry_run,
                )
        finally:
            log.set_verbosity(self.verbose)  # restore original verbosity 
开发者ID:ryfeus,项目名称:lambda-packs,代码行数:20,代码来源:easy_install.py

示例6: _check_module

# 需要导入模块: import sys [as 别名]
# 或者: from sys import dont_write_bytecode [as 别名]
def _check_module(self, depth):
        pkg_dir, mod_fname, mod_name = (
               self._make_pkg("x=1\n", depth))
        forget(mod_name)
        try:
            if verbose: print "Running from source:", mod_name
            d1 = run_module(mod_name) # Read from source
            self.assertIn("x", d1)
            self.assertTrue(d1["x"] == 1)
            del d1 # Ensure __loader__ entry doesn't keep file open
            __import__(mod_name)
            os.remove(mod_fname)
            if not sys.dont_write_bytecode:
                if verbose: print "Running from compiled:", mod_name
                d2 = run_module(mod_name) # Read from bytecode
                self.assertIn("x", d2)
                self.assertTrue(d2["x"] == 1)
                del d2 # Ensure __loader__ entry doesn't keep file open
        finally:
            self._del_pkg(pkg_dir, depth, mod_name)
        if verbose: print "Module executed successfully" 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:23,代码来源:test_runpy.py

示例7: _check_package

# 需要导入模块: import sys [as 别名]
# 或者: from sys import dont_write_bytecode [as 别名]
def _check_package(self, depth):
        pkg_dir, mod_fname, mod_name = (
               self._make_pkg("x=1\n", depth, "__main__"))
        pkg_name, _, _ = mod_name.rpartition(".")
        forget(mod_name)
        try:
            if verbose: print "Running from source:", pkg_name
            d1 = run_module(pkg_name) # Read from source
            self.assertIn("x", d1)
            self.assertTrue(d1["x"] == 1)
            del d1 # Ensure __loader__ entry doesn't keep file open
            __import__(mod_name)
            os.remove(mod_fname)
            if not sys.dont_write_bytecode:
                if verbose: print "Running from compiled:", pkg_name
                d2 = run_module(pkg_name) # Read from bytecode
                self.assertIn("x", d2)
                self.assertTrue(d2["x"] == 1)
                del d2 # Ensure __loader__ entry doesn't keep file open
        finally:
            self._del_pkg(pkg_dir, depth, pkg_name)
        if verbose: print "Package executed successfully" 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:24,代码来源:test_runpy.py

示例8: test_coverage_run_script_imports_doubledashsource

# 需要导入模块: import sys [as 别名]
# 或者: from sys import dont_write_bytecode [as 别名]
def test_coverage_run_script_imports_doubledashsource(self):
        # This file imports try_execfile, which compiles it to .pyc, so the
        # first run will have __file__ == "try_execfile.py" and the second will
        # have __file__ == "try_execfile.pyc", which throws off the comparison.
        # Setting dont_write_bytecode True stops the compilation to .pyc and
        # keeps the test working.
        self.make_file("myscript", """\
            import sys; sys.dont_write_bytecode = True
            import process_test.try_execfile
            """)

        # These -m commands assume the coverage tree is on the path.
        out_cov = self.run_command(
            "coverage run --source process_test myscript"
        )
        out_py = self.run_command("python myscript")
        self.assert_tryexecfile_output(out_cov, out_py)

        st, out = self.run_command_status("coverage report")
        self.assertEqual(st, 0)
        self.assertEqual(self.line_count(out), 6, out) 
开发者ID:nedbat,项目名称:coveragepy-bbmirror,代码行数:23,代码来源:test_process.py

示例9: byte_compile

# 需要导入模块: import sys [as 别名]
# 或者: from sys import dont_write_bytecode [as 别名]
def byte_compile(self, files):
        if sys.dont_write_bytecode:
            self.warn('byte-compiling is disabled, skipping.')
            return

        from distutils.util import byte_compile
        prefix = self.build_lib
        if prefix[-1] != os.sep:
            prefix = prefix + os.sep

        # XXX this code is essentially the same as the 'byte_compile()
        # method of the "install_lib" command, except for the determination
        # of the 'prefix' string.  Hmmm.
        if self.compile:
            byte_compile(files, optimize=0,
                         force=self.force, prefix=prefix, dry_run=self.dry_run)
        if self.optimize > 0:
            byte_compile(files, optimize=self.optimize,
                         force=self.force, prefix=prefix, dry_run=self.dry_run) 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:21,代码来源:build_py.py


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