Skip to content

Commit c8bf5fe

Browse files
committed
Fix Windows path separator issue in constraints reference
On Windows, os.path.relpath() returns paths with backslashes, but pip expects forward slashes in constraint file references. This commit normalizes all constraint paths to use forward slashes by adding .replace("\\", "/") after path calculation. This fixes CI test failures on Windows and macOS platforms. Related to #22 and #25
1 parent c5071cd commit c8bf5fe

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

CHANGES.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
## 4.1.2 (unreleased)
44

5-
- Fix #22 and #25: Constraints file path in requirements-out is now correctly calculated as a relative path from the requirements file's directory. This allows requirements and constraints files to be in different directories. Previously, the path was written from the config file's perspective, causing pip to fail when looking for the constraints file.
5+
- Fix #22 and #25: Constraints file path in requirements-out is now correctly calculated as a relative path from the requirements file's directory. This allows requirements and constraints files to be in different directories. Previously, the path was written from the config file's perspective, causing pip to fail when looking for the constraints file. On Windows, paths are now normalized to use forward slashes for pip compatibility.
66
[jensens]
77

88
- Fix #53: Per-package target setting now correctly overrides default-target when constructing checkout paths.

src/mxdev/processing.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -276,10 +276,13 @@ def write(state: State) -> None:
276276
# Calculate relative path from requirements directory to constraints file
277277
try:
278278
constraints_ref = os.path.relpath(const_path, req_path.parent)
279+
# Convert backslashes to forward slashes for pip compatibility
280+
# pip expects forward slashes even on Windows
281+
constraints_ref = constraints_ref.replace("\\", "/")
279282
except ValueError:
280283
# On Windows, relpath can fail if paths are on different drives
281-
# In that case, use absolute path
282-
constraints_ref = str(const_path.absolute())
284+
# In that case, use absolute path with forward slashes
285+
constraints_ref = str(const_path.absolute()).replace("\\", "/")
283286

284287
fio.write("#" * 79 + "\n")
285288
fio.write("# mxdev combined constraints\n")

0 commit comments

Comments
 (0)