Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[numpy] add new port #37409

Draft
wants to merge 49 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
70d0566
[numpy] Add port
Neumann-A Mar 13, 2024
cf6befb
Merge remote-tracking branch 'upstream/master' into add_numpy
Neumann-A Mar 13, 2024
ff1ff2e
opencv use numpy from vcpkg
Neumann-A Mar 13, 2024
515adbb
use sitecustomize.py in python3 for dll search paths
Neumann-A Mar 13, 2024
ad8374d
revert boost-python change
Neumann-A Mar 13, 2024
f88edba
format-manifest try fixing errors
Neumann-A Mar 14, 2024
5b0069e
Fix numpy linux
Neumann-A Mar 15, 2024
582c6e5
Don't test stuff which does not work due to static python
Neumann-A Apr 21, 2024
f9cf981
Merge remote-tracking branch 'upstream/master' into add_numpy
Neumann-A Apr 21, 2024
c219a84
Merge remote-tracking branch 'origin/openimageio-no-static-python' in…
Neumann-A Apr 21, 2024
8f68a37
add implicit fortran libs to pc file
Neumann-A Apr 22, 2024
74b72f4
print path to python executable
Neumann-A Apr 22, 2024
f1d2f50
fix arm64-windows
Neumann-A Apr 22, 2024
900c39d
Merge remote-tracking branch 'upstream/master' into add_numpy
Neumann-A Apr 22, 2024
0b99037
PATH debugging
Neumann-A Apr 22, 2024
c2d8f92
add missing ()
Neumann-A Apr 22, 2024
af8a525
add python to path
Neumann-A Apr 22, 2024
662e6fd
Do not use accelerate on osx
Neumann-A Apr 23, 2024
4c94d93
skip static windows builds
Neumann-A Apr 23, 2024
9324952
fix osx lapack selection
Neumann-A Apr 23, 2024
de3d9c3
also check IMPLICIT_LINK_DIRECTORIES
Neumann-A Apr 23, 2024
d49ef0e
Merge branch 'add_numpy' of https://github.com/Neumann-A/vcpkg into a…
Neumann-A Apr 23, 2024
fbc0b4d
add /usr/local/lib manually
Neumann-A Apr 23, 2024
b14d81e
ci debugging
Neumann-A Apr 23, 2024
2b7c2e2
minimize ci
Neumann-A Apr 23, 2024
f6799c2
more ci testing
Neumann-A Apr 23, 2024
aa21c1b
more printing
Neumann-A Apr 23, 2024
b2e3eb8
fix patch
Neumann-A Apr 23, 2024
b6baeca
move further
Neumann-A Apr 23, 2024
0a696bd
try updating openblas & lapack
Neumann-A Apr 24, 2024
d5f3476
update numpy
Neumann-A Apr 24, 2024
3c1d1b5
back to accelerate
Neumann-A Apr 24, 2024
7c2727d
enable ci
Neumann-A Apr 24, 2024
d11a1ce
Apply suggestions from code review
Neumann-A Apr 24, 2024
111ceda
Merge remote-tracking branch 'upstream/master' into add_numpy
Neumann-A Apr 24, 2024
7f5681f
Merge branch 'add_numpy' of https://github.com/Neumann-A/vcpkg into a…
Neumann-A Apr 24, 2024
f62ce9d
adjust numpy refs
Neumann-A Apr 24, 2024
696c8b2
add -fno-tree-vectorize
Neumann-A Apr 25, 2024
c17f502
Merge remote-tracking branch 'upstream/master' into add_numpy
Neumann-A Apr 25, 2024
d8e0fee
disable cross build imports
Neumann-A Apr 25, 2024
d6cec62
remove prefix patch
Neumann-A Apr 25, 2024
32d953a
fix lapack regressions
Neumann-A Apr 25, 2024
25e84a0
Merge remote-tracking branch 'upstream/master' into add_numpy
Neumann-A May 21, 2024
92739c8
Merge remote-tracking branch 'upstream/master' into add_numpy
Neumann-A Jun 20, 2024
65bae42
Update python stuff
Neumann-A Jun 21, 2024
2a71488
add missing patch
Neumann-A Jun 21, 2024
45ea362
add py-meson
Neumann-A Jun 22, 2024
83078eb
get fixes from other pr
Neumann-A Jun 22, 2024
4e1389a
adjust lapack patches
Neumann-A Jun 23, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index c99d71a..7333110 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -10,6 +10,12 @@ set(
${LAPACK_MAJOR_VERSION}.${LAPACK_MINOR_VERSION}.${LAPACK_PATCH_VERSION}
)
+if(WIN32)
+ set(CMAKE_STATIC_LIBRARY_PREFIX "")
+ set(CMAKE_SHARED_LIBRARY_PREFIX "lib")
+ set(CMAKE_IMPORT_LIBRARY_PREFIX "")
+endif()
+
# Add the CMake directory for custom CMake modules
set(CMAKE_MODULE_PATH "${LAPACK_SOURCE_DIR}/CMAKE" ${CMAKE_MODULE_PATH})
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 73056dc2e9..56356bf354 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -14,6 +14,12 @@ set(
set(CMAKE_STATIC_LIBRARY_PREFIX "lib${LIBRARY_PREFIX}")
set(CMAKE_SHARED_LIBRARY_PREFIX "lib${LIBRARY_PREFIX}")

+if(WIN32 AND CMAKE_GNUtoMS)
+ set(CMAKE_STATIC_LIBRARY_PREFIX "")
+ set(CMAKE_SHARED_LIBRARY_PREFIX "lib")
+ set(CMAKE_IMPORT_LIBRARY_PREFIX "")
+endif()
+
# Add the CMake directory for custom CMake modules
set(CMAKE_MODULE_PATH "${LAPACK_SOURCE_DIR}/CMAKE" ${CMAKE_MODULE_PATH})

16 changes: 0 additions & 16 deletions ports/lapack-reference/lapacke.patch

This file was deleted.

59 changes: 54 additions & 5 deletions ports/lapack-reference/portfile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ if(EXISTS "${CURRENT_INSTALLED_DIR}/share/clapack/copyright")
message(FATAL_ERROR "Can't build ${PORT} if clapack is installed. Please remove clapack:${TARGET_TRIPLET}, and try to install ${PORT}:${TARGET_TRIPLET} again.")
endif()

vcpkg_minimum_required(VERSION 2022-10-12) # for ${VERSION}

include(vcpkg_find_fortran)
SET(VCPKG_POLICY_EMPTY_INCLUDE_FOLDER enabled)
set(VCPKG_POLICY_ALLOW_OBSOLETE_MSVCRT enabled)
Expand All @@ -18,12 +16,12 @@ vcpkg_from_github(
OUT_SOURCE_PATH SOURCE_PATH
REPO "Reference-LAPACK/lapack"
REF "v${VERSION}"
SHA512 fc3258b9d91a833149a68a89c5589b5113e90a8f9f41c3a73fbfccb1ecddd92d9462802c0f870f1c3dab392623452de4ef512727f5874ffdcba6a4845f78fc9a
SHA512 f8f3c733a0221be0b3f5618235408ac59cbd4e5f1c4eab5f509b831a6ec6a9ef14b8849aa6ea10810df1aff90186ca454d15e9438d1dd271c2449d42d3da9dda
HEAD_REF master
PATCHES
fix-prefix.patch
cmake-config.patch
lapacke.patch
fix_prefix.patch
print-implicit-libs.patch
)

if(NOT VCPKG_TARGET_IS_WINDOWS)
Expand Down Expand Up @@ -63,6 +61,7 @@ vcpkg_cmake_configure(
"-DCMAKE_REQUIRE_FIND_PACKAGE_BLAS=${USE_OPTIMIZED_BLAS}"
"-DCBLAS=${CBLAS}"
"-DTEST_FORTRAN_COMPILER=OFF"
"-DCMAKE_Fortran_INIT_FLAGS=-fno-tree-vectorize" # This is used by openblas to compile lapack since there seems to be a bug in gfortran
${FORTRAN_CMAKE}
MAYBE_UNUSED_VARIABLES
CMAKE_REQUIRE_FIND_PACKAGE_BLAS
Expand Down Expand Up @@ -106,6 +105,10 @@ if("cblas" IN_LIST FEATURES)
file(READ "${pcfile}" _contents)
file(WRITE "${pcfile}" "prefix=${CURRENT_INSTALLED_DIR}/debug\n${_contents}")
endif()
vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/lib/pkgconfig/lapack.pc" " blas" " blas cblas")
if(NOT VCPKG_BUILD_TYPE)
vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig/lapack.pc" " blas" " blas cblas")
endif()
endif()
vcpkg_fixup_pkgconfig()

Expand Down Expand Up @@ -152,3 +155,49 @@ file(COPY "${CMAKE_CURRENT_LIST_DIR}/FindLAPACK.cmake" DESTINATION "${CURRENT_PA

file(INSTALL "${CMAKE_CURRENT_LIST_DIR}/usage" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}")
vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/LICENSE")

if(NOT VCPKG_TARGET_IS_WINDOWS)
file(READ "${CURRENT_BUILDTREES_DIR}/config-${TARGET_TRIPLET}-out.log" config_log)
string(REGEX MATCH "CMAKE_C_IMPLICIT_LINK_LIBRARIES:([^\n]+)" implicit_c_libs "${config_log}")
set(implicit_c_libs "${CMAKE_MATCH_1}")
list(REVERSE implicit_c_libs)
list(REMOVE_DUPLICATES implicit_c_libs)
list(REVERSE implicit_c_libs)
string(REGEX MATCH "CMAKE_Fortran_IMPLICIT_LINK_LIBRARIES:([^\n]+)" implicit_fortran_libs "${config_log}")
set(implicit_fortran_libs "${CMAKE_MATCH_1}")
list(REVERSE implicit_fortran_libs)
list(REMOVE_DUPLICATES implicit_fortran_libs)
list(REVERSE implicit_fortran_libs)
list(REMOVE_ITEM implicit_fortran_libs ${implicit_c_libs} quadmath m) # libgfortran already has quadmath and m as a dependency
list(JOIN implicit_fortran_libs " -l" implicit_fortran_libs)

string(REGEX MATCH "CMAKE_C_IMPLICIT_LINK_DIRECTORIES:([^\n]+)" implicit_c_dirs "${config_log}")
set(implicit_c_dirs "${CMAKE_MATCH_1}")
list(REVERSE implicit_c_dirs)
list(REMOVE_DUPLICATES implicit_c_dirs)
list(REVERSE implicit_c_dirs)
string(REGEX MATCH "CMAKE_Fortran_IMPLICIT_LINK_DIRECTORIES:([^\n]+)" implicit_fortran_dirs "${config_log}")
set(implicit_fortran_dirs "${CMAKE_MATCH_1}")
list(REVERSE implicit_fortran_dirs)
list(REMOVE_DUPLICATES implicit_fortran_dirs)
list(REVERSE implicit_fortran_dirs)
list(REMOVE_ITEM implicit_fortran_dirs ${implicit_c_dirs}) # libgfortran already has quadmath and m as a dependency
if(VCPKG_TARGET_IS_OSX)
list(APPEND implicit_fortran_dirs "/usr/local/lib")
endif()
list(JOIN implicit_fortran_dirs " -L" implicit_fortran_dirs)

message(STATUS "implicit_fortran_libs:${implicit_fortran_libs}|implicit_c_libs:${implicit_c_libs}")
message(STATUS "implicit_fortran_dirs:${implicit_fortran_dirs}|implicit_c_dirs:${implicit_c_dirs}")
if(NOT implicit_fortran_libs STREQUAL "" AND NOT implicit_fortran_dirs STREQUAL "")
vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/lib/pkgconfig/lapack-reference.pc" "-llapack" "-llapack -L${implicit_fortran_dirs} -l${implicit_fortran_libs}")
if(NOT VCPKG_BUILD_TYPE)
vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig/lapack-reference.pc" "-llapack" "-llapack -L${implicit_fortran_dirs} -l${implicit_fortran_libs}")
endif()
elseif(NOT implicit_fortran_libs STREQUAL "")
vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/lib/pkgconfig/lapack-reference.pc" "-llapack" "-llapack -l${implicit_fortran_libs}")
if(NOT VCPKG_BUILD_TYPE)
vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig/lapack-reference.pc" "-llapack" "-llapack -l${implicit_fortran_libs}")
endif()
endif()
endif()
14 changes: 14 additions & 0 deletions ports/lapack-reference/print-implicit-libs.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index c99d71a267..34fd8445b1 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -697,3 +697,8 @@ if(BUILD_HTML_DOCUMENTATION OR BUILD_MAN_DOCUMENTATION)

endif()
endif()
+
+message(STATUS "CMAKE_C_IMPLICIT_LINK_LIBRARIES:${CMAKE_C_IMPLICIT_LINK_LIBRARIES}")
+message(STATUS "CMAKE_Fortran_IMPLICIT_LINK_LIBRARIES:${CMAKE_Fortran_IMPLICIT_LINK_LIBRARIES}")
+message(STATUS "CMAKE_C_IMPLICIT_LINK_DIRECTORIES:${CMAKE_C_IMPLICIT_LINK_DIRECTORIES}")
+message(STATUS "CMAKE_Fortran_IMPLICIT_LINK_DIRECTORIES:${CMAKE_Fortran_IMPLICIT_LINK_DIRECTORIES}")
\ No newline at end of file
3 changes: 1 addition & 2 deletions ports/lapack-reference/vcpkg.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"name": "lapack-reference",
"version": "3.11.0",
"port-version": 6,
"version": "3.12.0",
"description": "LAPACK - Linear Algebra PACKage",
"homepage": "https://netlib.org/lapack/",
"license": "BSD-3-Clause-Open-MPI",
Expand Down
36 changes: 36 additions & 0 deletions ports/numpy/fix-tests.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
diff --git a/numpy/testing/_private/extbuild.py b/numpy/testing/_private/extbuild.py
index 292060e76f..49dd3b3556 100644
--- a/numpy/testing/_private/extbuild.py
+++ b/numpy/testing/_private/extbuild.py
@@ -182,7 +182,7 @@ def _c_compile(cfile, outputfilename, include_dirs=[], libraries=[],
library_dirs=[]):
if sys.platform == 'win32':
compile_extra = ["/we4013"]
+ link_extra = ["/LIBPATH:" + os.path.join(sys.base_prefix, '../../lib')]
- link_extra = ["/LIBPATH:" + os.path.join(sys.base_prefix, 'libs')]
elif sys.platform.startswith('linux'):
compile_extra = [
"-O0", "-g", "-Werror=implicit-function-declaration", "-fPIC"]
@@ -229,17 +229,19 @@ def build(cfile, outputfilename, compile_extra, link_extra,
name_suffix: 'dummy',
)
"""))
+ meson = os.environ.get('MESON', "meson.py")
+
if sys.platform == "win32":
- subprocess.check_call(["meson", "setup",
+ subprocess.check_call([sys.executable, meson, "setup",
"--buildtype=release",
"--vsenv", ".."],
cwd=build_dir,
)
else:
- subprocess.check_call(["meson", "setup", "--vsenv", ".."],
+ subprocess.check_call([sys.executable, meson, "setup", "--vsenv", ".."],
cwd=build_dir
)
- subprocess.check_call(["meson", "compile"], cwd=build_dir)
+ subprocess.check_call([sys.executable, meson, "compile"], cwd=build_dir)
os.rename(str(build_dir / so_name) + ".dummy", cfile.parent / so_name)

def get_so_suffix():
137 changes: 137 additions & 0 deletions ports/numpy/portfile.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
set(VCPKG_POLICY_EMPTY_INCLUDE_FOLDER enabled) # Numpy includes are stored in the module itself
set(VCPKG_POLICY_MISMATCHED_NUMBER_OF_BINARIES enabled)
set(VCPKG_BUILD_TYPE release) # No debug builds required for pure python modules since vcpkg does not install a debug python executable.

#TODO: Fix E:\vcpkg_folders\numpy\installed\x64-windows-release\tools\python3\Lib\site-packages\numpy\testing\_private\extbuild.py

vcpkg_get_vcpkg_installed_python(VCPKG_PYTHON3)
cmake_path(GET VCPKG_PYTHON3 PARENT_PATH VCPKG_PYTHON3_BASEDIR)

find_program(VCPKG_CYTHON NAMES cython PATHS "${VCPKG_PYTHON3_BASEDIR}" "${CURRENT_HOST_INSTALLED_DIR}/tools/python3/Scripts" NO_DEFAULT_PATH)

set(ENV{PYTHON3} "${VCPKG_PYTHON3}")
set(PYTHON3 "${VCPKG_PYTHON3}")

cmake_path(GET SCRIPT_MESON PARENT_PATH MESON_DIR)
vcpkg_add_to_path(PREPEND "${VCPKG_PYTHON3_BASEDIR}")
if(VCPKG_TARGET_IS_WINDOWS)
cmake_path(GET VCPKG_CYTHON PARENT_PATH CYTHON_DIR)
vcpkg_add_to_path(PREPEND "${CYTHON_DIR}")
endif()

cmake_path(GET SCRIPT_MESON PARENT_PATH MESON_DIR)
set(ENV{MESON} "${SCRIPT_MESON}")

vcpkg_from_github(
OUT_SOURCE_PATH SOURCE_PATH
REPO numpy/numpy
REF v${VERSION}
SHA512 01b6a124c72d082f1dafdd98cdaaa84ab57f2bf0112d89d9355fa458a04deb8309c7e78449767429049971793c040e51412060681218a51c671ac6086dba2fa4
HEAD_REF main
PATCHES
fix-tests.patch
)

vcpkg_from_github(
OUT_SOURCE_PATH SOURCE_PATH_SIMD
REPO intel/x86-simd-sort
REF 0631a88763a4a0a4c9e84d5eeb0ec5d36053730b
SHA512 cd44796fc10e13004932be05d5bee46070e061bcc429c7ee8d9e11520e18c45bdec2f4fcd3555d9769891a763e151b0a0a4c00385ea30f24c99da1c65d736e39
HEAD_REF main
)

file(COPY "${SOURCE_PATH_SIMD}/" DESTINATION "${SOURCE_PATH}/numpy/core/src/npysort/x86-simd-sort")

vcpkg_from_github(
OUT_SOURCE_PATH SOURCE_PATH_MESON_NUMPY
REPO numpy/meson
REF 4e370ca8ab73c07f7b84abe8a4b937caace050a4
SHA512 dec6e3b9428f95790f85a863778227a73e4f432f8f54e87d61fd6499b5a0723c59a334fcaf880afd59ae50c924d8f2cfa340a143f752cb39f976c731ca0ea123
HEAD_REF main
)

file(COPY "${SOURCE_PATH_MESON_NUMPY}/mesonbuild/modules/features" DESTINATION "${MESON_DIR}/mesonbuild/modules")

vcpkg_from_github(
OUT_SOURCE_PATH SOURCE_PATH_SVML
REPO numpy/SVML
REF 1b21e453f6b1ba6a6aca392b1d810d9d41576123
SHA512 c9ea7bf9effbf5750750ddfdfc7db3d95614ed176bd4540d68eddb90a15f819510e9564c9454ef34be02dd6a8e48a7f292a70cb5b63c25c3d1c450a8e3b77d35
HEAD_REF main
)

file(COPY "${SOURCE_PATH_SVML}/" DESTINATION "${SOURCE_PATH}/numpy/core/src/umath/svml")

vcpkg_replace_string("${SOURCE_PATH}/meson.build" "py.dependency()" "dependency('python-3.${PYTHON3_VERSION_MINOR}', method : 'pkg-config')")

#debug replacement
vcpkg_replace_string("${SOURCE_PATH}/numpy/_build_utils/tempita.py" "import argparse" "import argparse\nprint(sys.executable)\nimport os\n
print(os.environ['PATH'])")

if(VCPKG_TARGET_IS_WINDOWS AND VCPKG_CROSSCOMPILING AND VCPKG_TARGET_ARCHITECTURE MATCHES "arm")
set(opts
ADDITIONAL_PROPERTIES
"longdouble_format = 'IEEE_DOUBLE_LE'"
)
endif()

vcpkg_generate_meson_cmd_args(
OUTPUT meson_opts
CONFIG RELEASE
LANGUAGES C;CXX
${opts}
)

z_vcpkg_setup_pkgconfig_path(CONFIG "RELEASE")

list(APPEND meson_opts "--python.platlibdir" "${CURRENT_INSTALLED_DIR}/lib")
list(JOIN meson_opts "\",\"" meson_opts)

set(build_dir "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel")
file(REMOVE_RECURSE "${build_dir}")
file(MAKE_DIRECTORY "${build_dir}")

vcpkg_python_build_and_install_wheel(
SOURCE_PATH "${SOURCE_PATH}"
OPTIONS
--config-json "{\"setup-args\" : [\"-Dblas=blas\", \"-Dlapack=lapack\", \"-Duse-ilp64=false\", \"-Dallow-noblas=true\", \"${meson_opts}\" ], \"build-dir\" : \"${build_dir}\" }"
)


# message(STATUS "PATH is: '$ENV{PATH}'")
# vcpkg_configure_meson(
# SOURCE_PATH "${SOURCE_PATH}"
# OPTIONS
# -Dblas=blas
# -Dlapack=lapack
# #-Duse-ilp64=true
# ADDITIONAL_BINARIES
# cython=['${VCPKG_CYTHON}']
# python3=['${VCPKG_PYTHON3}']
# python=['${VCPKG_PYTHON3}']
# ${opts}
# )
# message(STATUS "PATH is: '$ENV{PATH}'")
# vcpkg_install_meson()
# message(STATUS "PATH is: '$ENV{PATH}'")
# vcpkg_fixup_pkgconfig()

# #E:\vcpkg_folders\numpy\packages\numpy_arm64-windows-release\tools\python3\Lib\site-packages\numpy\__config__.py
# # "path": r"E:/vcpkg_folders/numpy/installed/x64-windows-release/tools/python3/python.exe", and full paths to compilers
# #"commands": "C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.39.33519/bin/Hostx64/arm64/cl.exe, -DWIN32, -D_WINDOWS, -W3, -utf-8, -MP, -MD, -O2, -Oi, -Gy, -DNDEBUG, -Z7",

find_program(REAL_PYTHON3_LOCATION NAMES python${PYTHON3_VERSION_MAJOR}.${PYTHON3_VERSION_MINOR} python${PYTHON3_VERSION_MAJOR} python PATHS "${CURRENT_HOST_INSTALLED_DIR}/tools/python3" PATH_SUFFIXES "bin" NO_DEFAULT_PATH)
file(TO_NATIVE_PATH "${REAL_PYTHON3_LOCATION}" REAL_PYTHON3_LOCATION)


set(subdir "${CURRENT_PACKAGES_DIR}/${PYTHON3_SITE}/")
set(pyfile "${subdir}/numpy/__config__.py")
file(READ "${pyfile}" contents)
string(REPLACE "${CURRENT_INSTALLED_DIR}" "$(prefix)" contents "${contents}")
string(REPLACE "r\"${REAL_PYTHON3_LOCATION}\"" "sys.executable" contents "${contents}")
file(WRITE "${pyfile}" "import sys\n${contents}")


vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/LICENSE.txt")

vcpkg_python_test_import(MODULE "numpy")
36 changes: 36 additions & 0 deletions ports/numpy/vcpkg.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"name": "numpy",
"version": "1.26.4",
"description": "The fundamental package for scientific computing with Python.",
"homepage": "https://www.numpy.org/",
"license": "BSD-3-Clause",
"dependencies": [
"blas",
"lapack",
{
"name": "py-cython",
"host": true
},
{
"name": "py-meson",
"host": true
},
{
"name": "py-setuptools",
"host": true
},
"python3",
{
"name": "python3",
"host": true
},
{
"name": "vcpkg-python-scripts",
"host": true
},
{
"name": "vcpkg-tool-meson",
"host": true
}
]
}
2 changes: 0 additions & 2 deletions ports/opencv3/portfile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,6 @@ if("python" IN_LIST FEATURES)
if (VCPKG_LIBRARY_LINKAGE STREQUAL static AND VCPKG_TARGET_IS_WINDOWS)
message(WARNING "The python module is currently unsupported on Windows when building static OpenCV libraries")
else()
x_vcpkg_get_python_packages(PYTHON_VERSION "3" PACKAGES numpy OUT_PYTHON_VAR "PYTHON3")
set(ENV{PYTHON} "${PYTHON3}")
set(BUILD_opencv_python3 ON)
set(WITH_PYTHON ON)
endif()
Expand Down
1 change: 1 addition & 0 deletions ports/opencv3/vcpkg.json
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@
"python": {
"description": "Python wrapper support for opencv",
"dependencies": [
"numpy",
{
"name": "opencv3",
"default-features": false,
Expand Down
Loading
Loading