diff options
author | Eli Schwartz <eschwartz93@gmail.com> | 2023-03-01 03:46:49 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-03-01 09:46:49 +0100 |
commit | c125e5576e11965f660f07f7cffb71f79c776890 (patch) | |
tree | 4e29a39461e4a3c6b39ae74eaf3ba014beadac34 | |
parent | 0df24962b9747552e95d3d676ed23142e97b8cdf (diff) | |
download | cython-c125e5576e11965f660f07f7cffb71f79c776890.tar.gz |
Fix depfile generation on Windows, across different drives (GH-5283)
Since its first implementation in commit https://github.com/cython/cython/commit/9db1fc39b31b7b3b2ed574a79f5f9fd980ee3be7,
depfiles try to calculate relative paths for files relative to the project
base dir. This usually worked, but fails when the output directory is being
used from another Windows drive letter. This can happen for build systems that
encourage out of source build directories. When that happens, the logical
thing to do is to use an absolute path anyway. That's what those build systems
do as well, so the resulting depfiles still align with the build system manifest.
(cherry picked from master commit https://github.com/cython/cython/commit/038f94e9fd9e3b7ff279b3bd2627e974b94cb946)
See https://github.com/cython/cython/pull/5279
-rw-r--r-- | Cython/Utils.py | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/Cython/Utils.py b/Cython/Utils.py index 69563794c..13f83fb75 100644 --- a/Cython/Utils.py +++ b/Cython/Utils.py @@ -459,9 +459,14 @@ def write_depfile(target, source, dependencies): for fname in dependencies: fname = os.path.abspath(fname) if fname.startswith(src_base_dir): - paths.append(os.path.relpath(fname, cwd)) + try: + newpath = os.path.relpath(fname, cwd) + except ValueError: + # if they are on different Windows drives, absolute is fine + newpath = fname else: - paths.append(fname) + newpath = fname + paths.append(newpath) depline = os.path.relpath(target, cwd) + ": \\\n " depline += " \\\n ".join(paths) + "\n" |