Commit 5091929c authored by Greg Ward's avatar Greg Ward

Added 'native_path()' for use on pathnames from the setup script: split on

slashes, and put back together again using the local directory separator.
parent e2b4452d
......@@ -458,3 +458,31 @@ def get_platform ():
return sys.platform
# get_platform()
def native_path (pathname):
"""Return 'pathname' as a name that will work on the native
filesystem, i.e. split it on '/' and put it back together again
using the current directory separator. Needed because filenames in
the setup script are always supplied in Unix style, and have to be
converted to the local convention before we can actually use them in
the filesystem. Raises DistutilsValueError if 'pathname' is
absolute (starts with '/') or contains local directory separators
(unless the local separator is '/', of course)."""
if pathname[0] == '/':
raise DistutilsValueError, "path '%s' cannot be absolute" % pathname
if pathname[-1] == '/':
raise DistutilsValueError, "path '%s' cannot end with '/'" % pathname
if os.sep != '/':
if os.sep in pathname:
raise DistutilsValueError, \
"path '%s' cannot contain '%c' character" % \
(pathname, os.sep)
paths = string.split (pathname, '/')
return apply (os.path.join, paths)
else:
return pathname
# native_path ()
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