Merge pull request #2602 from RustPython/coolreader18/fix-windows-symlinks

Remove symlinks-to-hardlinks.ps1 hack
This commit is contained in:
Jeong YunWon authored and GitHub committed 2021-05-08 03:43:45 +09:00
commit 3144ff8a72
6 files changed
+47 -57

No files matched your search

+2 -6
View File
@@ -29,9 +29,7 @@ jobs:
- uses: actions/checkout@master
- uses: actions-rs/toolchain@v1
- name: Set up the Windows environment
run: |
choco install llvm
powershell.exe scripts/symlinks-to-hardlinks.ps1
run: choco install llvm
if: runner.os == 'Windows'
- name: Set up the Mac environment
run: brew install autoconf automake libtool
@@ -62,9 +60,7 @@ jobs:
with:
python-version: 3.8
- name: Set up the Windows environment
run: |
choco install llvm
powershell.exe scripts/symlinks-to-hardlinks.ps1
run: choco install llvm
if: runner.os == 'Windows'
- name: Set up the Mac environment
run: brew install autoconf automake libtool
-2
View File
@@ -28,8 +28,6 @@ To build RustPython locally, do the following:
$ git clone https://github.com/RustPython/RustPython
$ cd RustPython
# if you're on windows:
$ powershell scripts\symlinks-to-hardlinks.ps1
# --release is needed (at least on windows) to prevent stack overflow
$ cargo run --release demo.py
Hello, RustPython!
+43 -16
View File
@@ -115,9 +115,18 @@ impl CompilationSource {
mode: compile::Mode,
) -> Result<HashMap<String, FrozenModule>, Diagnostic> {
let mut code_map = HashMap::new();
let paths = fs::read_dir(&path).map_err(|err| {
Diagnostic::spans_error(self.span, format!("Error listing dir {:?}: {}", path, err))
})?;
let paths = fs::read_dir(path)
.or_else(|e| {
if cfg!(windows) {
if let Ok(real_path) = fs::read_to_string(path.canonicalize().unwrap()) {
return fs::read_dir(real_path.trim());
}
}
Err(e)
})
.map_err(|err| {
Diagnostic::spans_error(self.span, format!("Error listing dir {:?}: {}", path, err))
})?;
for path in paths {
let path = path.map_err(|err| {
Diagnostic::spans_error(self.span, format!("Failed to list file: {}", err))
@@ -133,12 +142,6 @@ impl CompilationSource {
mode,
)?);
} else if file_name.ends_with(".py") {
let source = fs::read_to_string(&path).map_err(|err| {
Diagnostic::spans_error(
self.span,
format!("Error reading file {:?}: {}", path, err),
)
})?;
let stem = path.file_stem().unwrap().to_str().unwrap();
let is_init = stem == "__init__";
let module_name = if is_init {
@@ -148,15 +151,39 @@ impl CompilationSource {
} else {
format!("{}.{}", parent, stem)
};
let compile_path = |src_path: &Path| {
let source = fs::read_to_string(src_path).map_err(|err| {
Diagnostic::spans_error(
self.span,
format!("Error reading file {:?}: {}", path, err),
)
})?;
self.compile_string(&source, mode, module_name.clone(), || {
path.strip_prefix(&*CARGO_MANIFEST_DIR)
.ok()
.unwrap_or(&path)
.display()
})
};
let code = compile_path(&path).or_else(|e| {
if cfg!(windows) {
if let Ok(real_path) = fs::read_to_string(path.canonicalize().unwrap()) {
let joined = path.parent().unwrap().join(real_path.trim());
if joined.exists() {
return compile_path(&joined);
} else {
return Err(e);
}
}
}
Err(e)
})?;
code_map.insert(
module_name.clone(),
module_name,
FrozenModule {
code: self.compile_string(&source, mode, module_name, || {
path.strip_prefix(&*CARGO_MANIFEST_DIR)
.ok()
.unwrap_or(&path)
.display()
})?,
code,
package: is_init,
},
);
-31
View File
@@ -1,31 +0,0 @@
#!/usr/bin/env powershell
Set-Location -Path $(Split-Path -Parent $PSScriptRoot)
git ls-files -s | Select-String '^120000' | ConvertFrom-String -PropertyNames Get-Content,Hash,_,Path | ForEach-Object {
$symlink = $_.Path
git checkout --quiet -- $symlink
if (Test-Path $symlink -PathType Leaf) {
$parent = (Get-Item $symlink).Directory
} else {
$parent = (Get-Item $symlink).Parent
}
$child = (Get-Content $symlink)
$src = (Join-Path -Path $parent -ChildPath $child)
if (Test-Path $src -PathType Leaf) {
Remove-Item $symlink
New-Item -ItemType HardLink -Name $symlink -Value $src
} elseif (Test-Path $src -PathType Container) {
Remove-Item $symlink
New-Item -ItemType Junction -Name $symlink -Value $src
} else {
Write-Error 'error: git-rm-symlink: Not a valid source\n'
Write-Error '$symlink =/=> $src...'
return
}
git update-index --assume-unchanged $symlink
}
-1
View File
@@ -38,7 +38,6 @@ pub fn get_module_inits() -> impl Iterator<Item = (String, bytecode::FrozenModul
// Python modules that the vm calls into, but are not actually part of the stdlib. They could
// in theory be implemented in Rust, but are easiest to do in Python for one reason or another.
// Includes _importlib_bootstrap and _importlib_bootstrap_external
// For Windows: did you forget to run `powershell scripts\symlinks-to-hardlinks.ps1`?
ext_modules!(iter, dir = "Lib/python_builtins/");
#[cfg(not(feature = "freeze-stdlib"))]
+2 -1
View File
@@ -2764,6 +2764,7 @@ pub(crate) use posix::raw_set_inheritable;
#[pymodule]
mod nt {
use super::*;
#[cfg(target_env = "msvc")]
use crate::builtins::list::PyListRef;
#[cfg(target_env = "msvc")]
use winapi::vc::vcruntime::intptr_t;
@@ -3120,7 +3121,7 @@ mod nt {
}
#[cfg(windows)]
use nt as platform;
#[cfg(windows)]
#[cfg(all(windows, target_env = "msvc"))]
pub use nt::{_set_thread_local_invalid_parameter_handler, silent_iph_handler};
#[cfg(not(any(unix, windows)))]