summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Lib/distutils/util.py28
1 files changed, 28 insertions, 0 deletions
diff --git a/Lib/distutils/util.py b/Lib/distutils/util.py
index 03c0c88..683d167 100644
--- a/Lib/distutils/util.py
+++ b/Lib/distutils/util.py
@@ -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 ()