aboutsummaryrefslogtreecommitdiffstats
path: root/setuptools/command/bdist_egg.py
diff options
context:
space:
mode:
authorPJ Eby <distutils-sig@python.org>2005-07-12 23:43:22 +0000
committerPJ Eby <distutils-sig@python.org>2005-07-12 23:43:22 +0000
commitb9c686a49c0154f849aef99dcacaecffc45378eb (patch)
tree900e06a25dddd2ede3c43c8debf54bededbfd535 /setuptools/command/bdist_egg.py
parentf09fb93d9562fa19bb9d5c7253548a32868fd46b (diff)
downloadexternal_python_setuptools-b9c686a49c0154f849aef99dcacaecffc45378eb.tar.gz
external_python_setuptools-b9c686a49c0154f849aef99dcacaecffc45378eb.tar.bz2
external_python_setuptools-b9c686a49c0154f849aef99dcacaecffc45378eb.zip
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
Diffstat (limited to 'setuptools/command/bdist_egg.py')
-rw-r--r--setuptools/command/bdist_egg.py10
1 files changed, 5 insertions, 5 deletions
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