[pygobject] setup.py: Provide a os.path.samefile fallback for Python 2 under Windows
- From: Christoph Reiter <creiter src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pygobject] setup.py: Provide a os.path.samefile fallback for Python 2 under Windows
- Date: Mon, 11 Dec 2017 15:16:18 +0000 (UTC)
commit 47aeaab6142a716234e91e8bbc3adefeff9ff5c3
Author: Christoph Reiter <creiter src gnome org>
Date: Mon Dec 11 16:14:34 2017 +0100
setup.py: Provide a os.path.samefile fallback for Python 2 under Windows
os.path.samefile is missing from Python 2 under Windows. Implement a
simple fallback which normalizes and compares paths instead.
setup.py | 15 ++++++++++++++-
1 files changed, 14 insertions(+), 1 deletions(-)
---
diff --git a/setup.py b/setup.py
index 95a4fe3..95669db 100644
--- a/setup.py
+++ b/setup.py
@@ -135,6 +135,19 @@ def pkg_config_parse(opt, pkg):
return [x.lstrip(opt) for x in output.split()]
+def samefile(src, dst):
+ # Python 2 on Windows doesn't have os.path.samefile, so we have to provide
+ # a fallback
+
+ if hasattr(os.path, "samefile"):
+ return os.path.samefile(src, dst)
+
+ os.stat(src)
+ os.stat(dst)
+ return (os.path.normcase(os.path.abspath(src)) ==
+ os.path.normcase(os.path.abspath(dst)))
+
+
du_sdist = get_command_class("sdist")
@@ -280,7 +293,7 @@ class build_ext(du_build_ext):
for path_type in ["platlib", "purelib"]:
path = sysconfig.get_path(path_type, scheme)
try:
- if os.path.samefile(path, location):
+ if samefile(path, location):
return sysconfig.get_path(name, scheme)
except EnvironmentError:
pass
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]