mirror of
https://github.com/python/cpython.git
synced 2025-11-12 15:09:14 +00:00
Support using -p/-P to point to the source/build directory instead of
the install directory. Added -h option to print the full usage message; by default, only two lines are now printed for errors.
This commit is contained in:
parent
516b6208c7
commit
9a6e855a27
1 changed files with 32 additions and 12 deletions
|
|
@ -6,14 +6,18 @@ usage: freeze [options...] script.py [module]...
|
||||||
|
|
||||||
Options:
|
Options:
|
||||||
|
|
||||||
-p prefix: This is the prefix used when you ran ``name install''
|
-p prefix: This is the prefix used when you ran ``make install''
|
||||||
in the Python build directory.
|
in the Python build directory.
|
||||||
(If you never ran this, freeze won't work.)
|
(If you never ran this, freeze won't work.)
|
||||||
The default is whatever sys.prefix evaluates to.
|
The default is whatever sys.prefix evaluates to.
|
||||||
|
It can also be the top directory of the Python source
|
||||||
|
tree; then -P must point to the build tree.
|
||||||
|
|
||||||
-P exec_prefix: Like -p but this is the 'exec_prefix', used to
|
-P exec_prefix: Like -p but this is the 'exec_prefix', used to
|
||||||
install objects etc. The default is whatever sys.exec_prefix
|
install objects etc. The default is whatever sys.exec_prefix
|
||||||
evaluates to, or the -p argument if given.
|
evaluates to, or the -p argument if given.
|
||||||
|
If -p points to the Python source tree, -P must point
|
||||||
|
to the build tree, if different.
|
||||||
|
|
||||||
-e extension: A directory containing additional .o files that
|
-e extension: A directory containing additional .o files that
|
||||||
may be used to resolve modules. This directory
|
may be used to resolve modules. This directory
|
||||||
|
|
@ -22,6 +26,8 @@ Options:
|
||||||
|
|
||||||
-o dir: Directory where the output files are created; default '.'.
|
-o dir: Directory where the output files are created; default '.'.
|
||||||
|
|
||||||
|
-h: Print this help message.
|
||||||
|
|
||||||
Arguments:
|
Arguments:
|
||||||
|
|
||||||
script.py: The Python script to be executed by the resulting binary.
|
script.py: The Python script to be executed by the resulting binary.
|
||||||
|
|
@ -79,12 +85,15 @@ def main():
|
||||||
|
|
||||||
# parse command line
|
# parse command line
|
||||||
try:
|
try:
|
||||||
opts, args = getopt.getopt(sys.argv[1:], 'e:o:p:P:')
|
opts, args = getopt.getopt(sys.argv[1:], 'he:o:p:P:')
|
||||||
except getopt.error, msg:
|
except getopt.error, msg:
|
||||||
usage('getopt error: ' + str(msg))
|
usage('getopt error: ' + str(msg))
|
||||||
|
|
||||||
# proces option arguments
|
# proces option arguments
|
||||||
for o, a in opts:
|
for o, a in opts:
|
||||||
|
if o == '-h':
|
||||||
|
print __doc__
|
||||||
|
return
|
||||||
if o == '-e':
|
if o == '-e':
|
||||||
extensions.append(a)
|
extensions.append(a)
|
||||||
if o == '-o':
|
if o == '-o':
|
||||||
|
|
@ -103,14 +112,26 @@ def main():
|
||||||
if not prefix:
|
if not prefix:
|
||||||
prefix = sys.prefix
|
prefix = sys.prefix
|
||||||
|
|
||||||
|
# determine whether -p points to the Python source tree
|
||||||
|
ishome = os.path.exists(os.path.join(prefix, 'Include', 'pythonrun.h'))
|
||||||
|
|
||||||
# locations derived from options
|
# locations derived from options
|
||||||
version = sys.version[:3]
|
version = sys.version[:3]
|
||||||
binlib = os.path.join(exec_prefix, 'lib/python%s/config' % version)
|
if ishome:
|
||||||
incldir = os.path.join(prefix, 'include/python%s' % version)
|
print "(Using Python source directory)"
|
||||||
|
binlib = exec_prefix
|
||||||
|
incldir = os.path.join(prefix, 'Include')
|
||||||
|
config_c_in = os.path.join(prefix, 'Modules', 'config.c.in')
|
||||||
|
frozenmain_c = os.path.join(prefix, 'Modules', 'frozenmain.c')
|
||||||
|
makefile_in = os.path.join(exec_prefix, 'Modules', 'Makefile')
|
||||||
|
else:
|
||||||
|
binlib = os.path.join(exec_prefix,
|
||||||
|
'lib', 'python%s' % version, 'config')
|
||||||
|
incldir = os.path.join(prefix, 'include', 'python%s' % version)
|
||||||
config_c_in = os.path.join(binlib, 'config.c.in')
|
config_c_in = os.path.join(binlib, 'config.c.in')
|
||||||
frozenmain_c = os.path.join(binlib, 'frozenmain.c')
|
frozenmain_c = os.path.join(binlib, 'frozenmain.c')
|
||||||
supp_sources = []
|
|
||||||
makefile_in = os.path.join(binlib, 'Makefile')
|
makefile_in = os.path.join(binlib, 'Makefile')
|
||||||
|
supp_sources = []
|
||||||
defines = []
|
defines = []
|
||||||
includes = ['-I' + incldir, '-I' + binlib]
|
includes = ['-I' + incldir, '-I' + binlib]
|
||||||
|
|
||||||
|
|
@ -283,11 +304,10 @@ def main():
|
||||||
|
|
||||||
# Print usage message and exit
|
# Print usage message and exit
|
||||||
|
|
||||||
def usage(msg = None):
|
def usage(msg):
|
||||||
sys.stderr.write(__doc__)
|
sys.stdout = sys.stderr
|
||||||
# Put the error last since the usage message scrolls off the screen
|
print "Error:", msg
|
||||||
if msg:
|
print "Use ``%s -h'' for help" % sys.argv[0]
|
||||||
sys.stderr.write('\nError: ' + str(msg) + '\n')
|
|
||||||
sys.exit(2)
|
sys.exit(2)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue