Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
17 changes: 17 additions & 0 deletions ports/py-lazy-loader/portfile.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
set(VCPKG_BUILD_TYPE release)

vcpkg_from_pythonhosted(
OUT_SOURCE_PATH SOURCE_PATH
PACKAGE_NAME "lazy-loader"
VERSION ${VERSION}
SHA512 29e3589929869351ea62cf7cbba86b581bd7935918b54cfd5ac107cbf7cc427d6d4e050ec1f9bef084587e55286d7afa31d5cdb6deb7d072d25493d19d6bbce6
FILENAME lazy_loader
)

vcpkg_python_build_and_install_wheel(SOURCE_PATH "${SOURCE_PATH}")

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

vcpkg_python_test_import(MODULE "lazy_loader")

set(VCPKG_POLICY_EMPTY_INCLUDE_FOLDER enabled)
18 changes: 18 additions & 0 deletions ports/py-lazy-loader/vcpkg.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"name": "py-lazy-loader",
"version": "0.4",
"description": "Makes it easy to load subpackages and functions on demand.",
"homepage": "https://scientific-python.org/specs/spec-0001/",
"dependencies": [
"py-packaging",
{
"name": "py-setuptools",
"host": true
},
"python3",
{
"name": "vcpkg-python-scripts",
"host": true
}
]
}
2 changes: 2 additions & 0 deletions ports/py-pysal/vcpkg.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
{
"name": "py-pysal",
"version": "26.1",
"port-version": 1,
"description": "Python Spatial Analysis Library - meta-package for the PySAL ecosystem.",
"homepage": "https://pysal.org/",
"dependencies": [
"py-lazy-loader",
{
"name": "py-setuptools",
"host": true
Expand Down
79 changes: 45 additions & 34 deletions ports/py-scipy/portfile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,40 @@ endif()
cmake_path(GET VCPKG_CYTHON PARENT_PATH CYTHON_DIR)
vcpkg_add_to_path("${CYTHON_DIR}")

set(z_vcpkg_python_func_python ${PYTHON3})

# Scipy depends on NumPy's command-line f2py utility, but
# the open-vcpkg py-numpy port doesn't install it. Here, we
# create it from scratch based on the one pip/PyPi installs.
# At present, it is a unix-like only solution.

# TODO: figure out how pip creates/installs this
if(NOT VCPKG_HOST_IS_WINDOWS)
file(WRITE "${CURRENT_HOST_INSTALLED_DIR}/tools/tmp/f2py"
"\
#!/bin/sh\n\
'''exec' ${PYTHON3} \"$0\" \"$@\"\n\
' '''\n\
import sys\n\
from numpy.f2py.f2py2e import main\n\
if __name__ == '__main__':\n\
if sys.argv[0].endswith('.exe'):\n\
sys.argv[0] = sys.argv[0][:-4]\n\
sys.exit(main())\n\
\n\
"
)
endif()

vcpkg_from_pythonhosted(
OUT_SOURCE_PATH SOURCE_PATH
PACKAGE_NAME scipy
VERSION ${VERSION}
SHA512 299339cf7885ae6ad81bb29ab1a9128c1e7baef387e64e03a5ca784c14f08de1fe58c8d58b25c76c9068b09d8d97fc8b38d2e03922f0f8ada4e5d00910d56dae
)

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

vcpkg_mesonpy_prepare_build_options(OUTPUT meson_opts)

z_vcpkg_setup_pkgconfig_path(CONFIG "RELEASE")
Expand All @@ -45,50 +72,34 @@ else()
)
endif()

# Scipy depends on NumPy's command-line f2py utility, but
# the open-vcpkg py-numpy port doesn't install it. Here, we
# create it from scratch based on the one pip/PyPi installs.
# At present, it is a unix-like only solution.

# TODO: figure out how pip creates/installs this
if(NOT VCPKG_HOST_IS_WINDOWS)
file(WRITE "${CURRENT_HOST_INSTALLED_DIR}/tools/tmp/f2py"
"\
#!/bin/sh\n\
'''exec' ${PYTHON3} \"$0\" \"$@\"\n\
' '''\n\
import sys\n\
from numpy.f2py.f2py2e import main\n\
if __name__ == '__main__':\n\
if sys.argv[0].endswith('.exe'):\n\
sys.argv[0] = sys.argv[0][:-4]\n\
sys.exit(main())\n\
\n\
"
)
endif()
file(COPY "${CURRENT_HOST_INSTALLED_DIR}/tools/tmp/f2py" DESTINATION ${CURRENT_HOST_INSTALLED_DIR}/tools/numpy/bin FILE_PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ GROUP_EXECUTE GROUP_READ)
file(REMOVE_RECURSE "${CURRENT_HOST_INSTALLED_DIR}/tools/tmp")
vcpkg_add_to_path("${CURRENT_HOST_INSTALLED_DIR}/tools/numpy/bin")

vcpkg_configure_meson(
SOURCE_PATH "${SOURCE_PATH}"
OPTIONS ${meson_opts}
ADDITIONAL_BINARIES
cython=['${VCPKG_CYTHON}']
python3=['${VCPKG_PYTHON3}']
list(APPEND meson_opts "--python.platlibdir" "${CURRENT_INSTALLED_DIR}/lib")
list(JOIN meson_opts "\",\"" meson_opts)

vcpkg_python_build_and_install_wheel(
SOURCE_PATH "${SOURCE_PATH}"
OPTIONS
--config-json "{\"setup-args\" : [\"${meson_opts}\" ] }"
)

vcpkg_install_meson()
vcpkg_fixup_pkgconfig()
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/wheels") # don't need to keep the wheel

set(subdir "${CURRENT_PACKAGES_DIR}/${PYTHON3_SITE}/")
if(VCPKG_TARGET_IS_WINDOWS)
set(subdir "${CURRENT_PACKAGES_DIR}/lib/site-packages/")
endif()
set(pyfile "${subdir}/scipy/__config__.py")
file(READ "${pyfile}" contents)
string(REPLACE "${CURRENT_INSTALLED_DIR}" "$(prefix)" contents "${contents}")
string(REPLACE "r\"${VCPKG_PYTHON3}\"" "sys.executable" contents "${contents}")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In QGIS, sys.executable is set to the qgis executable. I guess, this poses a problem here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I copied that from the NumPy port ,which also uses a __config__.py, to resolve a vcpkg warning about absolute paths in the resulting package, but on inspection, it doesn't look like that second replace actually does anything -- there are no instances of the word "executable" in the resulting file (neither for scipy nor for numpy).

The __config__.py file appears to be purely informational -- for use by extension developers to ensure they are using the same paths/same library versions/same build environments as the scipy package they are linking against. I'm happy to remove that line for purposes of this PR.

file(WRITE "${pyfile}" "${contents}")

file(GLOB licenses "${SOURCE_PATH}/LICENSE*")
vcpkg_install_copyright(FILE_LIST ${licenses})

# vcpkg_python_test_import uses z_vckpkg_python_func_python instead of PYTHON3
# and somehow, that variable is getting set to the system python instead of the
# vcpkg-built python
set(z_vcpkg_python_func_python ${PYTHON3})
vcpkg_python_test_import(MODULE "scipy")

# Add required Metadata for some python build plugins
Expand Down
1 change: 1 addition & 0 deletions ports/py-scipy/vcpkg.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"name": "py-scipy",
"version": "1.17.0",
"port-version": 1,
"description": "Fundamental algorithms for scientific computing in Python",
"homepage": "https://scipy.org/",
"dependencies": [
Expand Down
8 changes: 6 additions & 2 deletions versions/baseline.json
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,10 @@
"baseline": "1.4.5",
"port-version": 0
},
"py-lazy-loader": {
"baseline": "0.4",
"port-version": 0
},
"py-lxml": {
"baseline": "6.0.2",
"port-version": 2
Expand Down Expand Up @@ -322,7 +326,7 @@
},
"py-pysal": {
"baseline": "26.1",
"port-version": 0
"port-version": 1
},
"py-pyspnego": {
"baseline": "0.12.0",
Expand Down Expand Up @@ -374,7 +378,7 @@
},
"py-scipy": {
"baseline": "1.17.0",
"port-version": 0
"port-version": 1
},
"py-semantic-version": {
"baseline": "2.10.0",
Expand Down
9 changes: 9 additions & 0 deletions versions/p-/py-lazy-loader.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"versions": [
{
"git-tree": "ec9268444c993f14d67d2ba298e342797aa8004d",
"version": "0.4",
"port-version": 0
}
]
}
5 changes: 5 additions & 0 deletions versions/p-/py-pysal.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
{
"versions": [
{
"git-tree": "34ec0ba0e4600ba5333314463a3495e18810ed57",
"version": "26.1",
"port-version": 1
},
{
"git-tree": "2d716c71491dc13a427e554fb88824fc2627d69e",
"version": "26.1",
Expand Down
5 changes: 5 additions & 0 deletions versions/p-/py-scipy.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
{
"versions": [
{
"git-tree": "3ff048c0846f7d1e5c113407ab43fa45c97fa1dc",
"version": "1.17.0",
"port-version": 1
},
{
"git-tree": "3742d07c9df93f25546ba4ebb99089f2dd01f92a",
"version": "1.17.0",
Expand Down
Loading