Skip to content

Commit

Permalink
Fix sdist --vendor-crates issue on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
messense committed Feb 22, 2021
1 parent e15ac8e commit 7ff2642
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ jobs:
cd dist
tar -zxf namespace_package-0.1.0.tar.gz
cd namespace_package-0.1.0
cargo build --offline --target ${{ matrix.platform.rust-target }}
cargo build --offline --target ${{ matrix.platform.rust-target }}
test-abi3:
runs-on: ${{ matrix.os }}
Expand Down
9 changes: 6 additions & 3 deletions setuptools_rust/setuptools_ext.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,17 @@ def get_file_list(self):
# See https://docs.rs/clap/latest/clap/struct.Arg.html#method.multiple for detail
command.extend(["--manifest-path", manifest_paths[0], vendor_path])
cargo_config = subprocess.check_output(command)
base_dir_bytes = base_dir.encode(sys.getfilesystemencoding())
cargo_config = cargo_config.replace(base_dir_bytes + os.sep.encode(), b'')
base_dir_bytes = base_dir.encode(sys.getfilesystemencoding()) + os.sep.encode()
if os.sep == '\\':
# TOML escapes backslash \
base_dir_bytes += os.sep.encode()
cargo_config = cargo_config.replace(base_dir_bytes, b'')
if os.altsep:
cargo_config = cargo_config.replace(base_dir_bytes + os.altsep.encode(), b'')

# Check whether `.cargo/config`/`.cargo/config.toml` already exists
existing_cargo_config = None
for filename in (".cargo/config", ".cargo/config.toml"):
for filename in (f".cargo{os.sep}config", f".cargo{os.sep}config.toml"):
if filename in self.filelist.allfiles:
existing_cargo_config = filename
break
Expand Down

0 comments on commit 7ff2642

Please sign in to comment.