我们从Python开源项目中,提取了以下7个代码示例,用于说明如何使用setuptools.command.easy_install.get_script_header()。
def override_get_script_args( dist, executable=os.path.normpath(sys.executable), is_wininst=False): """Override entrypoints console_script.""" header = easy_install.get_script_header("", executable, is_wininst) for group, template in ENTRY_POINTS_MAP.items(): for name, ep in dist.get_entry_map(group).items(): if not ep.attrs or len(ep.attrs) > 2: raise ValueError("Script targets must be of the form " "'func' or 'Class.class_method'.") script_text = template % dict( group=group, module_name=ep.module_name, import_target=ep.attrs[0], invoke_target='.'.join(ep.attrs), ) yield (name, header + script_text)
def override_get_script_args( dist, executable=os.path.normpath(sys.executable), is_wininst=False): """Override entrypoints console_script.""" header = easy_install.get_script_header("", executable, is_wininst) for group in 'console_scripts', 'gui_scripts': for name, ep in dist.get_entry_map(group).items(): if not ep.attrs or len(ep.attrs) > 2: raise ValueError("Script targets must be of the form " "'func' or 'Class.class_method'.") script_text = _script_text % dict( group=group, module_name=ep.module_name, import_target=ep.attrs[0], invoke_target='.'.join(ep.attrs), ) yield (name, header + script_text)
def override_get_script_args( dist, executable=os.path.normpath(sys.executable), is_wininst=False): """Override entrypoints console_script.""" header = easy_install.get_script_header("", executable, is_wininst) for group, template in ENTRY_POINTS_MAP.items(): for name, ep in dist.get_entry_map(group).items(): yield (name, generate_script(group, ep, header, template))
def _make_wsgi_scripts_only(self, dist, executable, is_wininst): header = easy_install.get_script_header("", executable, is_wininst) wsgi_script_template = ENTRY_POINTS_MAP['wsgi_scripts'] for name, ep in dist.get_entry_map('wsgi_scripts').items(): content = generate_script( 'wsgi_scripts', ep, header, wsgi_script_template) self.write_script(name, content)
def test_get_script_header(self): if not sys.platform.startswith('java') or not is_sh(sys.executable): # This test is for non-Jython platforms self.assertEqual(get_script_header('#!/usr/local/bin/python'), '#!%s\n' % os.path.normpath(sys.executable)) self.assertEqual(get_script_header('#!/usr/bin/python -x'), '#!%s -x\n' % os.path.normpath(sys.executable)) self.assertEqual(get_script_header('#!/usr/bin/python', executable=self.non_ascii_exe), '#!%s -x\n' % self.non_ascii_exe)
def test_get_script_header_jython_workaround(self): # This test doesn't work with Python 3 in some locales if (sys.version_info >= (3,) and os.environ.get("LC_CTYPE") in (None, "C", "POSIX")): return class java: class lang: class System: @staticmethod def getProperty(property): return "" sys.modules["java"] = java platform = sys.platform sys.platform = 'java1.5.0_13' stdout, stderr = sys.stdout, sys.stderr try: # A mock sys.executable that uses a shebang line (this file) exe = os.path.normpath(os.path.splitext(__file__)[0] + '.py') self.assertEqual( get_script_header('#!/usr/local/bin/python', executable=exe), '#!/usr/bin/env %s\n' % exe) # Ensure we generate what is basically a broken shebang line # when there's options, with a warning emitted sys.stdout = sys.stderr = StringIO() self.assertEqual(get_script_header('#!/usr/bin/python -x', executable=exe), '#!%s -x\n' % exe) self.assertTrue('Unable to adapt shebang line' in sys.stdout.getvalue()) sys.stdout = sys.stderr = StringIO() self.assertEqual(get_script_header('#!/usr/bin/python', executable=self.non_ascii_exe), '#!%s -x\n' % self.non_ascii_exe) self.assertTrue('Unable to adapt shebang line' in sys.stdout.getvalue()) finally: del sys.modules["java"] sys.platform = platform sys.stdout, sys.stderr = stdout, stderr