getsentry / getsentry/milksnake
Non portable paths issue
- Dominant language
- Python
- Stars
- 805
- Forks
- 34
- PR merge metrics
- No merged PRs in 30d
Description
I had an issue with milksnake when setuping a CI pipeline for Linux, Mac and Windows.
For Windows I `SET` the `CARGO_TARGET_DIR` to a folder I can cache between runs. To prevent issue with Windows backslash being wrongly escaped (or not), I use a path similar to `C:/cargo_cache/project_name/target`.
After some debugging, I've realized that milksnake assumes `/` is used as paths separators when looking for files. See for example https://github.com/getsentry/milksnake/blob/ef0723e41df23d8f6357570c69c1e69cb31f9e9e/milksnake/setuptools_ext.py#L146
and https://github.com/getsentry/milksnake/blob/ef0723e41df23d8f6357570c69c1e69cb31f9e9e/milksnake/setuptools_ext.py#L165
Those two lines will `join()` the search path with the `in_path` argument which is split with forward slashes.
I thus end up with paths that look like `C:cargo_cache/project_name/target` and milksnake can't find the expected files.
It seems those lines attempt to replace the forward slashes with the platform's separator, but it's not doing a proper job.
If that is the expected behaviour, I would suggest doing something like that instead:
```python
path = os.path.join(os.path.normalize(path), *os.path.normalize(in_path).split(os.sep))
```
or even just
```python
path = os.path.join(os.path.normalize(path), os.path.normalize(in_path))
```
or maybe even simpler
```python
path = os.path.normalize(os.path.join(path, in_path))
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.