Commit d4cc04c6 authored by Guido van Rossum's avatar Guido van Rossum

Add test that script name ends in .py.

Cosmetic changes to usage message (refer to "make install" now).
parent f75f80eb
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
# Usage message # Usage message
usage_msg = """ usage_msg = """
usage: freeze [-p prefix] [-P exec_prefix] [-e extension] script [module] ... usage: freeze [-p prefix] [-P exec_prefix] [-e extension] script.py [module]...
-p prefix: This is the prefix used when you ran -p prefix: This is the prefix used when you ran
'Make inclinstall libainstall' in the Python build directory. 'Make inclinstall libainstall' in the Python build directory.
...@@ -31,7 +31,7 @@ usage: freeze [-p prefix] [-P exec_prefix] [-e extension] script [module] ... ...@@ -31,7 +31,7 @@ usage: freeze [-p prefix] [-P exec_prefix] [-e extension] script [module] ...
should also have a Setup file describing the .o files. should also have a Setup file describing the .o files.
More than one -e option may be given. More than one -e option may be given.
script: The Python script to be executed by the resulting binary. script.py: The Python script to be executed by the resulting binary.
It *must* end with a .py suffix! It *must* end with a .py suffix!
module ...: Additional Python modules (referenced by pathname) module ...: Additional Python modules (referenced by pathname)
...@@ -41,11 +41,7 @@ module ...: Additional Python modules (referenced by pathname) ...@@ -41,11 +41,7 @@ module ...: Additional Python modules (referenced by pathname)
NOTES: NOTES:
In order to use freeze successfully, you must have built Python and In order to use freeze successfully, you must have built Python and
installed it. In particular, the following two non-standard make installed it ("make install").
targets must have been executed:
make inclinstall
make libainstall # Note: 'liba', not 'lib'
The -p and -P options passed into the freeze script must correspond to The -p and -P options passed into the freeze script must correspond to
the --prefix and --exec-prefix options passed into Python's configure the --prefix and --exec-prefix options passed into Python's configure
...@@ -163,6 +159,10 @@ def main(): ...@@ -163,6 +159,10 @@ def main():
if not args: if not args:
usage('at least one filename argument required') usage('at least one filename argument required')
# check that the script name ends in ".py"
if args[0][-3:] != ".py":
usage('the script name must have a .py suffix')
# check that file arguments exist # check that file arguments exist
for arg in args: for arg in args:
if not os.path.exists(arg): if not os.path.exists(arg):
...@@ -291,9 +291,10 @@ def main(): ...@@ -291,9 +291,10 @@ def main():
# Print usage message and exit # Print usage message and exit
def usage(msg = None): def usage(msg = None):
if msg:
sys.stderr.write(str(msg) + '\n')
sys.stderr.write(usage_msg) sys.stderr.write(usage_msg)
# Put the error last since the usage message scrolls off the screen
if msg:
sys.stderr.write('\nError: ' + str(msg) + '\n')
sys.exit(2) sys.exit(2)
......
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