Commit 6a241540 authored by PJ Eby's avatar PJ Eby

Fix for .py scripts that might be imported (e.g. the "py" library's hideous

'_findpy.py' hack.)

--HG--
branch : setuptools
extra : convert_revision : svn%3A6015fed2-1504-0410-9fe1-9d1591cc4771/sandbox/trunk/setuptools%4041084
parent 2b9b1a6c
...@@ -22,7 +22,7 @@ __all__ = [ ...@@ -22,7 +22,7 @@ __all__ = [
'InvalidOption', 'Distribution', 'Requirement', 'yield_lines', 'InvalidOption', 'Distribution', 'Requirement', 'yield_lines',
'get_importer', 'find_distributions', 'find_on_path', 'register_finder', 'get_importer', 'find_distributions', 'find_on_path', 'register_finder',
'split_sections', 'declare_namespace', 'register_namespace_handler', 'split_sections', 'declare_namespace', 'register_namespace_handler',
'safe_name', 'safe_version', 'run_main', 'BINARY_DIST', 'safe_name', 'safe_version', 'run_main', 'BINARY_DIST', 'run_script',
] ]
import sys, os, zipimport, time, re, imp import sys, os, zipimport, time, re, imp
...@@ -102,15 +102,15 @@ def compatible_platforms(provided,required): ...@@ -102,15 +102,15 @@ def compatible_platforms(provided,required):
# XXX all the tricky cases go here # XXX all the tricky cases go here
return False return False
def run_main(dist_spec, script_name): def run_script(dist_spec, script_name):
"""Locate distribution `dist_spec` and run its `script_name` script""" """Locate distribution `dist_spec` and run its `script_name` script"""
import __main__ ns = sys._getframe(1).f_globals
__main__.__dict__.clear() name = ns['__name__']
__main__.__dict__.update({'__name__':'__main__'}) ns.clear()
require(dist_spec)[0].metadata.run_script(script_name, __main__.__dict__) ns['__name__'] = name
require(dist_spec)[0].metadata.run_script(script_name, ns)
run_main = run_script # backward compatibility
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment