Commit 8d7ac2a8 authored by Fred Drake's avatar Fred Drake

There are a few places which can raise DistutilsPlatformError; make

sure it's imported!  ;)

Re-wrap the docstrings on get_python_inc() and get_python_lib() to be
closer to the "normal" Python style.  See GvR's "style guide" on the
essays page (http://www.python.org/doc/essays/).

There should never be a space between a function name and the '(' that
opens the argument list (see the style guide again).
parent e150d458
...@@ -13,65 +13,73 @@ import re ...@@ -13,65 +13,73 @@ import re
import string import string
import sys import sys
prefix = os.path.normpath (sys.prefix) from errors import DistutilsPlatformError
exec_prefix = os.path.normpath (sys.exec_prefix)
def get_python_inc (plat_specific=0): prefix = os.path.normpath(sys.prefix)
exec_prefix = os.path.normpath(sys.exec_prefix)
def get_python_inc(plat_specific=0):
"""Return the directory containing installed Python header files. """Return the directory containing installed Python header files.
If 'plat_specific' is false (the default), this is the path to the If 'plat_specific' is false (the default), this is the path to the
non-platform-specific header files, i.e. Python.h and so on; non-platform-specific header files, i.e. Python.h and so on;
otherwise, this is the path to platform-specific header files otherwise, this is the path to platform-specific header files
(namely config.h).""" (namely config.h).
"""
the_prefix = (plat_specific and exec_prefix or prefix) the_prefix = (plat_specific and exec_prefix or prefix)
if os.name == "posix": if os.name == "posix":
return os.path.join (the_prefix, "include", "python" + sys.version[:3]) return os.path.join(the_prefix, "include", "python" + sys.version[:3])
elif os.name == "nt": elif os.name == "nt":
return os.path.join (the_prefix, "Include") # include or Include? return os.path.join(the_prefix, "Include") # include or Include?
elif os.name == "mac": elif os.name == "mac":
return os.path.join (the_prefix, "Include") return os.path.join(the_prefix, "Include")
else: else:
raise DistutilsPlatformError, \ raise DistutilsPlatformError, \
("I don't know where Python installs its C header files " + ("I don't know where Python installs its C header files " +
"on platform '%s'") % os.name "on platform '%s'") % os.name
def get_python_lib (plat_specific=0, standard_lib=0): def get_python_lib(plat_specific=0, standard_lib=0):
"""Return the directory containing the Python library (standard or """Return the directory containing the Python library (standard or
site additions). If 'plat_specific' is true, return the directory site additions).
containing platform-specific modules, i.e. any module from a
non-pure-Python module distribution; otherwise, return the If 'plat_specific' is true, return the directory containing
platform-shared library directory. If 'standard_lib' is true, platform-specific modules, i.e. any module from a non-pure-Python
return the directory containing standard Python library modules; module distribution; otherwise, return the platform-shared library
otherwise, return the directory for site-specific modules.""" directory. If 'standard_lib' is true, return the directory
containing standard Python library modules; otherwise, return the
directory for site-specific modules.
"""
the_prefix = (plat_specific and exec_prefix or prefix) the_prefix = (plat_specific and exec_prefix or prefix)
if os.name == "posix": if os.name == "posix":
libpython = os.path.join (the_prefix, libpython = os.path.join(the_prefix,
"lib", "python" + sys.version[:3]) "lib", "python" + sys.version[:3])
if standard_lib: if standard_lib:
return libpython return libpython
else: else:
return os.path.join (libpython, "site-packages") return os.path.join(libpython, "site-packages")
elif os.name == "nt": elif os.name == "nt":
if standard_lib: if standard_lib:
return os.path.join (the_prefix, "Lib") return os.path.join(the_prefix, "Lib")
else: else:
return the_prefix return the_prefix
elif os.name == "mac": elif os.name == "mac":
if platform_specific: if platform_specific:
if standard_lib: if standard_lib:
return os.path.join (exec_prefix, "Mac", "Plugins") return os.path.join(exec_prefix, "Mac", "Plugins")
else: else:
raise DistutilsPlatformError, \ raise DistutilsPlatformError, \
"OK, where DO site-specific extensions go on the Mac?" "OK, where DO site-specific extensions go on the Mac?"
else: else:
if standard_lib: if standard_lib:
return os.path.join (prefix, "Lib") return os.path.join(prefix, "Lib")
else: else:
raise DistutilsPlatformError, \ raise DistutilsPlatformError, \
"OK, where DO site-specific modules go on the Mac?" "OK, where DO site-specific modules go on the Mac?"
...@@ -80,25 +88,27 @@ def get_python_lib (plat_specific=0, standard_lib=0): ...@@ -80,25 +88,27 @@ def get_python_lib (plat_specific=0, standard_lib=0):
("I don't know where Python installs its library " + ("I don't know where Python installs its library " +
"on platform '%s'") % os.name "on platform '%s'") % os.name
# get_python_lib () # get_python_lib()
def get_config_h_filename(): def get_config_h_filename():
"""Return full pathname of installed config.h file.""" """Return full pathname of installed config.h file."""
inc_dir = get_python_inc (plat_specific=1) inc_dir = get_python_inc(plat_specific=1)
return os.path.join (inc_dir, "config.h") return os.path.join(inc_dir, "config.h")
def get_makefile_filename(): def get_makefile_filename():
"""Return full pathname of installed Makefile from the Python build.""" """Return full pathname of installed Makefile from the Python build."""
lib_dir = get_python_lib (plat_specific=1, standard_lib=1) lib_dir = get_python_lib(plat_specific=1, standard_lib=1)
return os.path.join (lib_dir, "config", "Makefile") return os.path.join(lib_dir, "config", "Makefile")
def parse_config_h(fp, g=None): def parse_config_h(fp, g=None):
"""Parse a config.h-style file. A dictionary containing name/value """Parse a config.h-style file.
pairs is returned. If an optional dictionary is passed in as the second
argument, it is used instead of a new dictionary. A dictionary containing name/value pairs is returned. If an
optional dictionary is passed in as the second argument, it is
used instead of a new dictionary.
""" """
if g is None: if g is None:
g = {} g = {}
...@@ -122,9 +132,12 @@ def parse_config_h(fp, g=None): ...@@ -122,9 +132,12 @@ def parse_config_h(fp, g=None):
return g return g
def parse_makefile(fp, g=None): def parse_makefile(fp, g=None):
"""Parse a Makefile-style file. A dictionary containing name/value """Parse a Makefile-style file.
pairs is returned. If an optional dictionary is passed in as the second
argument, it is used instead of a new dictionary. A dictionary containing name/value pairs is returned. If an
optional dictionary is passed in as the second argument, it is
used instead of a new dictionary.
""" """
if g is None: if g is None:
g = {} g = {}
...@@ -206,11 +219,11 @@ def _init_nt(): ...@@ -206,11 +219,11 @@ def _init_nt():
# load config.h, though I don't know how useful this is # load config.h, though I don't know how useful this is
parse_config_h(open(get_config_h_filename()), g) parse_config_h(open(get_config_h_filename()), g)
# set basic install directories # set basic install directories
g['LIBDEST'] = get_python_lib (plat_specific=0, standard_lib=1) g['LIBDEST'] = get_python_lib(plat_specific=0, standard_lib=1)
g['BINLIBDEST'] = get_python_lib (plat_specific=1, standard_lib=1) g['BINLIBDEST'] = get_python_lib(plat_specific=1, standard_lib=1)
# XXX hmmm.. a normal install puts include files here # XXX hmmm.. a normal install puts include files here
g['INCLUDEPY'] = get_python_inc (plat_specific=0) g['INCLUDEPY'] = get_python_inc(plat_specific=0)
g['SO'] = '.pyd' g['SO'] = '.pyd'
g['exec_prefix'] = exec_prefix g['exec_prefix'] = exec_prefix
...@@ -224,11 +237,11 @@ def _init_mac(): ...@@ -224,11 +237,11 @@ def _init_mac():
parse_config_h(open( parse_config_h(open(
os.path.join(sys.exec_prefix, "Mac", "Include", "config.h")), g) os.path.join(sys.exec_prefix, "Mac", "Include", "config.h")), g)
# set basic install directories # set basic install directories
g['LIBDEST'] = get_python_lib (plat_specific=0, standard_lib=1) g['LIBDEST'] = get_python_lib(plat_specific=0, standard_lib=1)
g['BINLIBDEST'] = get_python_lib (plat_specific=1, standard_lib=1) g['BINLIBDEST'] = get_python_lib(plat_specific=1, standard_lib=1)
# XXX hmmm.. a normal install puts include files here # XXX hmmm.. a normal install puts include files here
g['INCLUDEPY'] = get_python_inc (plat_specific=0) g['INCLUDEPY'] = get_python_inc(plat_specific=0)
g['SO'] = '.ppc.slb' g['SO'] = '.ppc.slb'
g['exec_prefix'] = sys.exec_prefix g['exec_prefix'] = sys.exec_prefix
......
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