diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index de407ec2b..7fb327774 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -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 diff --git a/README.md b/README.md index e632bd675..490334fd3 100644 --- a/README.md +++ b/README.md @@ -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! diff --git a/derive/src/compile_bytecode.rs b/derive/src/compile_bytecode.rs index 43d84c770..e6f3b7c7a 100644 --- a/derive/src/compile_bytecode.rs +++ b/derive/src/compile_bytecode.rs @@ -115,9 +115,18 @@ impl CompilationSource { mode: compile::Mode, ) -> Result, 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, }, ); diff --git a/scripts/symlinks-to-hardlinks.ps1 b/scripts/symlinks-to-hardlinks.ps1 deleted file mode 100644 index 9ec79de4e..000000000 --- a/scripts/symlinks-to-hardlinks.ps1 +++ /dev/null @@ -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 -} diff --git a/vm/src/frozen.rs b/vm/src/frozen.rs index ec94b7ecd..160ae22ab 100644 --- a/vm/src/frozen.rs +++ b/vm/src/frozen.rs @@ -38,7 +38,6 @@ pub fn get_module_inits() -> impl Iterator