Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d4cc04c

Browse files
committed
Add test that script name ends in .py.
Cosmetic changes to usage message (refer to "make install" now).
1 parent f75f80e commit d4cc04c

1 file changed

Lines changed: 10 additions & 9 deletions

File tree

Tools/freeze/freeze.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
# Usage message
1717

1818
usage_msg = """
19-
usage: freeze [-p prefix] [-P exec_prefix] [-e extension] script [module] ...
19+
usage: freeze [-p prefix] [-P exec_prefix] [-e extension] script.py [module]...
2020
2121
-p prefix: This is the prefix used when you ran
2222
'Make inclinstall libainstall' in the Python build directory.
@@ -31,7 +31,7 @@
3131
should also have a Setup file describing the .o files.
3232
More than one -e option may be given.
3333
34-
script: The Python script to be executed by the resulting binary.
34+
script.py: The Python script to be executed by the resulting binary.
3535
It *must* end with a .py suffix!
3636
3737
module ...: Additional Python modules (referenced by pathname)
@@ -41,11 +41,7 @@
4141
NOTES:
4242
4343
In order to use freeze successfully, you must have built Python and
44-
installed it. In particular, the following two non-standard make
45-
targets must have been executed:
46-
47-
make inclinstall
48-
make libainstall # Note: 'liba', not 'lib'
44+
installed it ("make install").
4945
5046
The -p and -P options passed into the freeze script must correspond to
5147
the --prefix and --exec-prefix options passed into Python's configure
@@ -163,6 +159,10 @@ def main():
163159
if not args:
164160
usage('at least one filename argument required')
165161

162+
# check that the script name ends in ".py"
163+
if args[0][-3:] != ".py":
164+
usage('the script name must have a .py suffix')
165+
166166
# check that file arguments exist
167167
for arg in args:
168168
if not os.path.exists(arg):
@@ -291,9 +291,10 @@ def main():
291291
# Print usage message and exit
292292

293293
def usage(msg = None):
294-
if msg:
295-
sys.stderr.write(str(msg) + '\n')
296294
sys.stderr.write(usage_msg)
295+
# Put the error last since the usage message scrolls off the screen
296+
if msg:
297+
sys.stderr.write('\nError: ' + str(msg) + '\n')
297298
sys.exit(2)
298299

299300

0 commit comments

Comments
 (0)