|
16 | 16 | # Usage message |
17 | 17 |
|
18 | 18 | 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]... |
20 | 20 |
|
21 | 21 | -p prefix: This is the prefix used when you ran |
22 | 22 | 'Make inclinstall libainstall' in the Python build directory. |
|
31 | 31 | should also have a Setup file describing the .o files. |
32 | 32 | More than one -e option may be given. |
33 | 33 |
|
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. |
35 | 35 | It *must* end with a .py suffix! |
36 | 36 |
|
37 | 37 | module ...: Additional Python modules (referenced by pathname) |
|
41 | 41 | NOTES: |
42 | 42 |
|
43 | 43 | 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"). |
49 | 45 |
|
50 | 46 | The -p and -P options passed into the freeze script must correspond to |
51 | 47 | the --prefix and --exec-prefix options passed into Python's configure |
@@ -163,6 +159,10 @@ def main(): |
163 | 159 | if not args: |
164 | 160 | usage('at least one filename argument required') |
165 | 161 |
|
| 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 | + |
166 | 166 | # check that file arguments exist |
167 | 167 | for arg in args: |
168 | 168 | if not os.path.exists(arg): |
@@ -291,9 +291,10 @@ def main(): |
291 | 291 | # Print usage message and exit |
292 | 292 |
|
293 | 293 | def usage(msg = None): |
294 | | - if msg: |
295 | | - sys.stderr.write(str(msg) + '\n') |
296 | 294 | 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') |
297 | 298 | sys.exit(2) |
298 | 299 |
|
299 | 300 |
|
|
0 commit comments