Skip to content

Commit 7afc0e6

Browse files
committed
Add py-numpy
1 parent 1b75796 commit 7afc0e6

File tree

5 files changed

+187
-1
lines changed

5 files changed

+187
-1
lines changed

.github/workflows/windows.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ jobs:
5757
5858
- name: 🌋 Build
5959
run: |
60-
.\vcpkg\vcpkg.exe install --overlay-ports="${{ github.workspace }}/ports" --triplet=${{ matrix.triplet }} --x-buildtrees-root=C:/vcpkg-build py-pyqt6 py-pyyaml
60+
.\vcpkg\vcpkg.exe install --overlay-ports="${{ github.workspace }}/ports" --triplet=${{ matrix.triplet }} --x-buildtrees-root=C:/vcpkg-build py-pyqt6 py-pyyaml py-numpy
6161
6262
- name: 📑 Upload logs
6363
uses: actions/upload-artifact@v4

ports/py-cython/portfile.cmake

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
vcpkg_from_github(
2+
OUT_SOURCE_PATH SOURCE_PATH
3+
REPO cython/cython
4+
REF ${VERSION}
5+
SHA512 585d3fe810ace55278fcc6ea4508b3b5259320f92998cd688da787cd5f88ac5fc2467025f20da6d968969eb3296ae9c517136d24a4dbb475441271227968f6be
6+
HEAD_REF main
7+
)
8+
9+
vcpkg_python_build_and_install_wheel(SOURCE_PATH "${SOURCE_PATH}")
10+
11+
vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/LICENSE.txt")
12+
13+
if(NOT VCPKG_TARGET_IS_WINDOWS)
14+
vcpkg_copy_tools(TOOL_NAMES cygdb cython cythonize DESTINATION "${CURRENT_PACKAGES_DIR}/${VCPKG_PYTHON3_SCRIPTS}" AUTO_CLEAN)
15+
endif()
16+
17+
set(VCPKG_POLICY_EMPTY_INCLUDE_FOLDER enabled)
18+
set(VCPKG_POLICY_MISMATCHED_NUMBER_OF_BINARIES enabled)

ports/py-cython/vcpkg.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"name": "py-cython",
3+
"version": "3.0.5",
4+
"description": "Cython is a Python compiler that makes writing C extensions for Python as easy as Python itself. Cython is based on Pyrex, but supports more cutting edge functionality and optimizations.",
5+
"homepage": "https://cython.org/",
6+
"license": "Apache-2.0",
7+
"dependencies": [
8+
"py-setuptools",
9+
"python3",
10+
{
11+
"name": "vcpkg-python-scripts",
12+
"host": true
13+
}
14+
]
15+
}

ports/py-numpy/portfile.cmake

Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
set(VCPKG_POLICY_EMPTY_INCLUDE_FOLDER enabled) # Numpy includes are stored in the module itself
2+
set(VCPKG_POLICY_MISMATCHED_NUMBER_OF_BINARIES enabled)
3+
set(VCPKG_BUILD_TYPE release) # No debug builds required for pure python modules since vcpkg does not install a debug python executable.
4+
5+
#TODO: Fix E:\vcpkg_folders\numpy\installed\x64-windows-release\tools\python3\Lib\site-packages\numpy\testing\_private\extbuild.py
6+
7+
set(VCPKG_PYTHON3_BASEDIR "${CURRENT_HOST_INSTALLED_DIR}/tools/python3")
8+
find_program(VCPKG_PYTHON3 NAMES python${PYTHON3_VERSION_MAJOR}.${PYTHON3_VERSION_MINOR} python${PYTHON3_VERSION_MAJOR} python PATHS "${VCPKG_PYTHON3_BASEDIR}" NO_DEFAULT_PATH)
9+
find_program(VCPKG_CYTHON NAMES cython PATHS "${VCPKG_PYTHON3_BASEDIR}" "${VCPKG_PYTHON3_BASEDIR}/Scripts" NO_DEFAULT_PATH)
10+
11+
set(ENV{PYTHON3} "${VCPKG_PYTHON3}")
12+
set(PYTHON3 "${VCPKG_PYTHON3}")
13+
14+
vcpkg_add_to_path(PREPEND "${VCPKG_PYTHON3_BASEDIR}")
15+
if(VCPKG_TARGET_IS_WINDOWS)
16+
vcpkg_add_to_path(PREPEND "${VCPKG_PYTHON3_BASEDIR}/Scripts")
17+
endif()
18+
19+
cmake_path(GET SCRIPT_MESON PARENT_PATH MESON_DIR)
20+
21+
vcpkg_from_github(
22+
OUT_SOURCE_PATH SOURCE_PATH
23+
REPO numpy/numpy
24+
REF v${VERSION}
25+
SHA512 01b6a124c72d082f1dafdd98cdaaa84ab57f2bf0112d89d9355fa458a04deb8309c7e78449767429049971793c040e51412060681218a51c671ac6086dba2fa4
26+
HEAD_REF main
27+
)
28+
29+
vcpkg_from_github(
30+
OUT_SOURCE_PATH SOURCE_PATH_SIMD
31+
REPO intel/x86-simd-sort
32+
REF 0631a88763a4a0a4c9e84d5eeb0ec5d36053730b
33+
SHA512 cd44796fc10e13004932be05d5bee46070e061bcc429c7ee8d9e11520e18c45bdec2f4fcd3555d9769891a763e151b0a0a4c00385ea30f24c99da1c65d736e39
34+
HEAD_REF main
35+
)
36+
37+
file(COPY "${SOURCE_PATH_SIMD}/" DESTINATION "${SOURCE_PATH}/numpy/core/src/npysort/x86-simd-sort")
38+
39+
vcpkg_from_github(
40+
OUT_SOURCE_PATH SOURCE_PATH_MESON_NUMPY
41+
REPO numpy/meson
42+
REF 4e370ca8ab73c07f7b84abe8a4b937caace050a4
43+
SHA512 dec6e3b9428f95790f85a863778227a73e4f432f8f54e87d61fd6499b5a0723c59a334fcaf880afd59ae50c924d8f2cfa340a143f752cb39f976c731ca0ea123
44+
HEAD_REF main
45+
)
46+
47+
file(COPY "${SOURCE_PATH_MESON_NUMPY}/mesonbuild/modules/features" DESTINATION "${MESON_DIR}/mesonbuild/modules")
48+
49+
vcpkg_from_github(
50+
OUT_SOURCE_PATH SOURCE_PATH_SVML
51+
REPO numpy/SVML
52+
REF 1b21e453f6b1ba6a6aca392b1d810d9d41576123
53+
SHA512 c9ea7bf9effbf5750750ddfdfc7db3d95614ed176bd4540d68eddb90a15f819510e9564c9454ef34be02dd6a8e48a7f292a70cb5b63c25c3d1c450a8e3b77d35
54+
HEAD_REF main
55+
)
56+
57+
file(COPY "${SOURCE_PATH_SVML}/" DESTINATION "${SOURCE_PATH}/numpy/core/src/umath/svml")
58+
59+
vcpkg_replace_string("${SOURCE_PATH}/meson.build" "py.dependency()" "dependency('python-3.${PYTHON3_VERSION_MINOR}', method : 'pkg-config')")
60+
61+
#debug replacement
62+
vcpkg_replace_string("${SOURCE_PATH}/numpy/_build_utils/tempita.py" "import argparse" "import argparse\nprint(sys.executable)\nimport os\n
63+
print(os.environ['PATH'])")
64+
65+
if(VCPKG_TARGET_IS_WINDOWS AND VCPKG_CROSSCOMPILING AND VCPKG_TARGET_ARCHITECTURE MATCHES "arm")
66+
set(opts
67+
ADDITIONAL_PROPERTIES
68+
"longdouble_format = 'IEEE_DOUBLE_LE'"
69+
)
70+
endif()
71+
72+
message(STATUS "PATH is: '$ENV{PATH}'")
73+
vcpkg_configure_meson(
74+
SOURCE_PATH "${SOURCE_PATH}"
75+
OPTIONS
76+
-Dblas=blas
77+
-Dlapack=lapack
78+
#-Duse-ilp64=true
79+
ADDITIONAL_BINARIES
80+
cython=['${VCPKG_CYTHON}']
81+
python3=['${VCPKG_PYTHON3}']
82+
# python=['${VCPKG_PYTHON3}']
83+
${opts}
84+
)
85+
message(STATUS "PATH is: '$ENV{PATH}'")
86+
vcpkg_install_meson()
87+
message(STATUS "PATH is: '$ENV{PATH}'")
88+
vcpkg_fixup_pkgconfig()
89+
90+
#E:\vcpkg_folders\numpy\packages\numpy_arm64-windows-release\tools\python3\Lib\site-packages\numpy\__config__.py
91+
# "path": r"E:/vcpkg_folders/numpy/installed/x64-windows-release/tools/python3/python.exe", and full paths to compilers
92+
#"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",
93+
94+
set(subdir "${CURRENT_PACKAGES_DIR}/${PYTHON3_SITE}/")
95+
if(VCPKG_TARGET_IS_WINDOWS)
96+
set(subdir "${CURRENT_PACKAGES_DIR}/lib/site-packages/")
97+
endif()
98+
set(pyfile "${subdir}/numpy/__config__.py")
99+
file(READ "${pyfile}" contents)
100+
string(REPLACE "${CURRENT_INSTALLED_DIR}" "$(prefix)" contents "${contents}")
101+
string(REPLACE "r\"${VCPKG_PYTHON3}\"" "sys.executable" contents "${contents}")
102+
file(WRITE "${pyfile}" "${contents}")
103+
104+
105+
if(VCPKG_TARGET_IS_WINDOWS)
106+
file(MAKE_DIRECTORY "${CURRENT_PACKAGES_DIR}/${PYTHON3_SITE}")
107+
file(RENAME "${CURRENT_PACKAGES_DIR}/lib/site-packages/numpy" "${CURRENT_PACKAGES_DIR}/${PYTHON3_SITE}/numpy")
108+
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/lib")
109+
endif()
110+
111+
file(REMOVE_RECURSE
112+
"${CURRENT_PACKAGES_DIR}/debug/include"
113+
"${CURRENT_PACKAGES_DIR}/debug/share"
114+
)
115+
116+
vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/LICENSE.txt")
117+
118+
# Add required Metadata for some python build plugins
119+
file(WRITE "${CURRENT_PACKAGES_DIR}/${PYTHON3_SITE}/numpy-${VERSION}.dist-info/METADATA"
120+
"Metadata-Version: 2.1\n\
121+
Name: numpy\n\
122+
Version: ${VERSION}"
123+
)
124+
125+
vcpkg_python_test_import(MODULE "numpy")

ports/py-numpy/vcpkg.json

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"name": "py-numpy",
3+
"version": "1.26.4",
4+
"description": "The fundamental package for scientific computing with Python.",
5+
"homepage": "https://www.numpy.org/",
6+
"license": "BSD-3-Clause",
7+
"dependencies": [
8+
"blas",
9+
"lapack",
10+
{
11+
"name": "py-cython",
12+
"host": true
13+
},
14+
"python3",
15+
{
16+
"name": "python3",
17+
"host": true
18+
},
19+
{
20+
"name": "vcpkg-python-scripts",
21+
"host": true
22+
},
23+
{
24+
"name": "vcpkg-tool-meson",
25+
"host": true
26+
}
27+
]
28+
}

0 commit comments

Comments
 (0)