Is your feature request related to a problem? Please describe.
I'm programmatically generating Snakemake input and output paths in rules using Python’s pathlib.Path with str(path), which works well on Unix-based systems. However, on Windows, it inserts backslashes (e.g., C:\data\file.tif), which is expected, .as_posix() is the correct method to use there. This is a problem for me, as I want to use the same Snakefile across different operating systems.
Describe the solution you'd like
I suggest internally normalizing paths based on the operating system by substituting slashes as needed. Paths could be written using the str(path) method and then corrected under the hood by Snakemake.
Describe alternatives you've considered
I currently work around this using:
path.as_posix() if os.name == "nt" else str(path)
This reliably produces shell-safe path strings across platforms.
Additional context
It's important to me that the workflow runs reliably across different operating systems. I think this subtle behavior can easily confuse users working on cross-platform pipelines.
Let me know if I'm misunderstanding how Snakemake handles paths internally or if there's already a recommended approach I'm missing.
Is your feature request related to a problem? Please describe.
I'm programmatically generating Snakemake input and output paths in rules using Python’s
pathlib.Pathwithstr(path), which works well on Unix-based systems. However, on Windows, it inserts backslashes (e.g.,C:\data\file.tif), which is expected,.as_posix()is the correct method to use there. This is a problem for me, as I want to use the same Snakefile across different operating systems.Describe the solution you'd like
I suggest internally normalizing paths based on the operating system by substituting slashes as needed. Paths could be written using the
str(path)method and then corrected under the hood by Snakemake.Describe alternatives you've considered
I currently work around this using:
This reliably produces shell-safe path strings across platforms.
Additional context
It's important to me that the workflow runs reliably across different operating systems. I think this subtle behavior can easily confuse users working on cross-platform pipelines.
Let me know if I'm misunderstanding how Snakemake handles paths internally or if there's already a recommended approach I'm missing.