Skip to content

Commit

Permalink
hard-reset scipy source directory for recompilation on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
h-vetinari committed May 10, 2023
1 parent fd488cc commit 8370005
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 11 deletions.
9 changes: 9 additions & 0 deletions recipe/bld.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
@echo on
setlocal enabledelayedexpansion

:: copy %SRC_DIR%/base somewhere to be able to hard-reset state in build-output.bat
mkdir .\backup
robocopy base backup /E >nul
:: for whatever reason, robocopy returns 1 in case of success, see
:: https://learn.microsoft.com/en-us/troubleshoot/windows-server/backup-and-storage/return-codes-used-robocopy-utility
if %ERRORLEVEL% neq 1 exit 1
17 changes: 11 additions & 6 deletions recipe/build-output.bat
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
@echo on
setlocal enabledelayedexpansion

:: for reason see source section in meta.yaml & below
cd base

REM these are done automatically for openblas by numpy.distutils, but
REM not for our blas libraries
echo %LIBRARY_LIB%\blas.lib > %LIBRARY_LIB%\blas.fobjects
Expand Down Expand Up @@ -38,8 +41,8 @@ REM TODO: rewrite wrap_g77_abi.f with iso_c_binding when the compiler supports i
cl.exe /I%NP_INC% /I%PY_INC% scipy\_build_utils\src\wrap_g77_abi_c.c -c /MD
if %ERRORLEVEL% neq 0 exit 1
echo. > scipy\_build_utils\src\wrap_g77_abi_c.c
echo %SRC_DIR%\wrap_g77_abi_c.obj >> %LIBRARY_LIB%\lapack.fobjects
echo %SRC_DIR%\wrap_g77_abi_c.obj >> %LIBRARY_LIB%\lapack.cobjects
echo %SRC_DIR%\base\wrap_g77_abi_c.obj >> %LIBRARY_LIB%\lapack.fobjects
echo %SRC_DIR%\base\wrap_g77_abi_c.obj >> %LIBRARY_LIB%\lapack.cobjects

REM Add a file to load the fortran wrapper libraries in scipy/.libs
del scipy\_distributor_init.py
Expand Down Expand Up @@ -79,8 +82,10 @@ if "%PKG_NAME%"=="scipy" (
set "g=%%f"
rmdir /s /q %SP_DIR%\scipy\!g:/=\!
)
)

:: clean up between invocations
rmdir /s /q build
del wrap_g77_abi_c.obj
REM hard-reset %SRC_DIR%\base to original state; see prep in bld.bat
cd ..
rmdir /s /q base
REM `move` can spuriously fail with "Access Denied"; use `robocopy /MOVE` instead
robocopy backup base /E /MOVE >nul
)
3 changes: 3 additions & 0 deletions recipe/build-output.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
#!/bin/bash
set -ex

# for reason see source section in meta.yaml
cd base

# Set a few environment variables that are not set due to
# https://github.com/conda/conda-build/issues/3993
export PIP_NO_BUILD_ISOLATION=True
Expand Down
3 changes: 3 additions & 0 deletions recipe/build.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
#!/bin/bash
set -ex

# for reason see source section in meta.yaml
cd base

mkdir builddir

# HACK: extend $CONDA_PREFIX/meson_cross_file that's created in
Expand Down
12 changes: 7 additions & 5 deletions recipe/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ source:
# the submodules (not in tarball due to dear-github/dear-github#214)
- url: https://github.com/scipy/scipy/archive/refs/tags/v{{ version }}.tar.gz
sha256: 8f08e1742c9b09eb58640fa5a56031d6e1844806899e883fbe7447ca86fe8c55
# need separate folder to do full reset on windows, see build-output.bat
folder: base
patches:
# backport https://github.com/scipy/scipy/pull/18006
- patches/0001-BLD-use-a-relative-path-to-numpy-pybind11-pythran-in.patch
Expand All @@ -32,17 +34,17 @@ source:
# https://github.com/scipy/scipy/tree/v{{ version }}/scipy/_lib
- git_url: https://github.com/scipy/boost-headers-only.git
git_rev: 3af99e6d566043072e95bc882d32c9c26f37e0ba
folder: scipy/_lib/boost
folder: base/scipy/_lib/boost
- git_url: https://github.com/scipy/highs.git
git_rev: 4a122958a82e67e725d08153e099efe4dad099a2
folder: scipy/_lib/highs
folder: base/scipy/_lib/highs
- git_url: https://github.com/scipy/unuran.git
git_rev: a63d39160e5ecc4402e7ed0e8417f4c3ff9634cb
folder: scipy/_lib/unuran
folder: base/scipy/_lib/unuran
# https://github.com/scipy/scipy/tree/v{{ version }}/scipy/sparse/linalg/_propack
- git_url: https://github.com/scipy/PROPACK.git
git_rev: cc32f3ba6cf941e4f9f96d96e2fc5762ea0c1014
folder: scipy/sparse/linalg/_propack/PROPACK
folder: base/scipy/sparse/linalg/_propack/PROPACK

build:
number: 2
Expand Down Expand Up @@ -266,7 +268,7 @@ outputs:
about:
home: http://www.scipy.org/
license: BSD-3-Clause
license_file: LICENSE.txt
license_file: base/LICENSE.txt
summary: Scientific Library for Python
description: |
SciPy is a Python-based ecosystem of open-source software for mathematics,
Expand Down

0 comments on commit 8370005

Please sign in to comment.