Skip to content

Commit 7ff2642

Browse files
committed
Fix sdist --vendor-crates issue on Windows
1 parent e15ac8e commit 7ff2642

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ jobs:
104104
cd dist
105105
tar -zxf namespace_package-0.1.0.tar.gz
106106
cd namespace_package-0.1.0
107-
cargo build --offline --target ${{ matrix.platform.rust-target }}
107+
cargo build --offline --target ${{ matrix.platform.rust-target }}
108108
109109
test-abi3:
110110
runs-on: ${{ matrix.os }}

setuptools_rust/setuptools_ext.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,14 +65,17 @@ def get_file_list(self):
6565
# See https://docs.rs/clap/latest/clap/struct.Arg.html#method.multiple for detail
6666
command.extend(["--manifest-path", manifest_paths[0], vendor_path])
6767
cargo_config = subprocess.check_output(command)
68-
base_dir_bytes = base_dir.encode(sys.getfilesystemencoding())
69-
cargo_config = cargo_config.replace(base_dir_bytes + os.sep.encode(), b'')
68+
base_dir_bytes = base_dir.encode(sys.getfilesystemencoding()) + os.sep.encode()
69+
if os.sep == '\\':
70+
# TOML escapes backslash \
71+
base_dir_bytes += os.sep.encode()
72+
cargo_config = cargo_config.replace(base_dir_bytes, b'')
7073
if os.altsep:
7174
cargo_config = cargo_config.replace(base_dir_bytes + os.altsep.encode(), b'')
7275

7376
# Check whether `.cargo/config`/`.cargo/config.toml` already exists
7477
existing_cargo_config = None
75-
for filename in (".cargo/config", ".cargo/config.toml"):
78+
for filename in (f".cargo{os.sep}config", f".cargo{os.sep}config.toml"):
7679
if filename in self.filelist.allfiles:
7780
existing_cargo_config = filename
7881
break

0 commit comments

Comments
 (0)