From b9c686a49c0154f849aef99dcacaecffc45378eb Mon Sep 17 00:00:00 2001 From: PJ Eby Date: Tue, 12 Jul 2005 23:43:22 +0000 Subject: Update zip-safety scanner to check for modules that might be used as ``python -m`` scripts. Misc. fixes for win32.exe support, including changes to support Python 2.4's changed ``bdist_wininst`` format. --HG-- branch : setuptools extra : convert_revision : svn%3A6015fed2-1504-0410-9fe1-9d1591cc4771/sandbox/trunk/setuptools%4041123 --- setuptools/command/bdist_egg.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'setuptools/command/bdist_egg.py') diff --git a/setuptools/command/bdist_egg.py b/setuptools/command/bdist_egg.py index e75a4a9c..0a9d9a0c 100644 --- a/setuptools/command/bdist_egg.py +++ b/setuptools/command/bdist_egg.py @@ -332,14 +332,11 @@ def scan_module(egg_dir, base, name, stubs): filename = os.path.join(base,name) if filename[:-1] in stubs: return True # Extension module - pkg = base[len(egg_dir)+1:].replace(os.sep,'.') module = pkg+(pkg and '.' or '')+os.path.splitext(name)[0] - f = open(filename,'rb'); f.read(8) # skip magic & date code = marshal.load(f); f.close() safe = True - symbols = dict.fromkeys(iter_symbols(code)) for bad in ['__file__', '__path__']: if bad in symbols: @@ -353,7 +350,11 @@ def scan_module(egg_dir, base, name, stubs): ]: if bad in symbols: log.warn("%s: module MAY be using inspect.%s", module, bad) - safe = False + safe = False + if '__name__' in symbols and '__main__' in symbols and '.' not in module: + if get_python_version()>="2.4": + log.warn("%s: top-level module may be 'python -m' script", module) + safe = False return safe def iter_symbols(code): @@ -366,7 +367,6 @@ def iter_symbols(code): for name in iter_symbols(const): yield name - # Attribute names of options for commands that might need to be convinced to # install to the egg build directory -- cgit v1.2.3