Windows: fix bootstrap and package install failure (#32942)
* Add patches for building clingo with MSVC * Help python find clingo DLL * If an executable is located in "C:\Program Files", Executable was running into issues with the extra space. This quotes the exe to ensure that it is treated as a single value. Signed-off-by: Kiruya Momochi <65301509+KiruyaMomochi@users.noreply.github.com>
This commit is contained in:
parent
5d0ae001a1
commit
4ff8a6a9b7
@ -91,6 +91,14 @@ def _try_import_from_store(module, query_spec, query_info=None):
|
|||||||
os.path.join(candidate_spec.prefix, pkg.platlib),
|
os.path.join(candidate_spec.prefix, pkg.platlib),
|
||||||
] # type: list[str]
|
] # type: list[str]
|
||||||
path_before = list(sys.path)
|
path_before = list(sys.path)
|
||||||
|
|
||||||
|
# Python 3.8+ on Windows does not search dependent DLLs in PATH,
|
||||||
|
# so we need to manually add it using os.add_dll_directory
|
||||||
|
# https://docs.python.org/3/whatsnew/3.8.html#bpo-36085-whatsnew
|
||||||
|
if sys.version_info[:2] >= (3, 8) and sys.platform == "win32":
|
||||||
|
if os.path.isdir(candidate_spec.prefix.bin):
|
||||||
|
os.add_dll_directory(candidate_spec.prefix.bin) # novermin
|
||||||
|
|
||||||
# NOTE: try module_paths first and last, last allows an existing version in path
|
# NOTE: try module_paths first and last, last allows an existing version in path
|
||||||
# to be picked up and used, possibly depending on something in the store, first
|
# to be picked up and used, possibly depending on something in the store, first
|
||||||
# allows the bootstrap version to work when an incompatible version is in
|
# allows the bootstrap version to work when an incompatible version is in
|
||||||
|
@ -10,6 +10,7 @@
|
|||||||
import sys
|
import sys
|
||||||
|
|
||||||
from six import string_types, text_type
|
from six import string_types, text_type
|
||||||
|
from six.moves import shlex_quote
|
||||||
|
|
||||||
import llnl.util.tty as tty
|
import llnl.util.tty as tty
|
||||||
|
|
||||||
@ -333,7 +334,7 @@ def which(*args, **kwargs):
|
|||||||
Executable: The first executable that is found in the path
|
Executable: The first executable that is found in the path
|
||||||
"""
|
"""
|
||||||
exe = which_string(*args, **kwargs)
|
exe = which_string(*args, **kwargs)
|
||||||
return Executable(exe) if exe else None
|
return Executable(shlex_quote(exe)) if exe else None
|
||||||
|
|
||||||
|
|
||||||
class ProcessError(spack.error.SpackError):
|
class ProcessError(spack.error.SpackError):
|
||||||
|
@ -64,6 +64,8 @@ class Clingo(CMakePackage):
|
|||||||
depends_on("py-cffi", type=("build", "run"), when="@5.5.0: platform=cray")
|
depends_on("py-cffi", type=("build", "run"), when="@5.5.0: platform=cray")
|
||||||
|
|
||||||
patch("python38.patch", when="@5.3:5.4.0")
|
patch("python38.patch", when="@5.3:5.4.0")
|
||||||
|
patch("size-t.patch", when="%msvc")
|
||||||
|
patch("vs2022.patch", when="%msvc@19.30:")
|
||||||
|
|
||||||
def patch(self):
|
def patch(self):
|
||||||
# Doxygen is optional but can't be disabled with a -D, so patch
|
# Doxygen is optional but can't be disabled with a -D, so patch
|
||||||
|
22
var/spack/repos/builtin/packages/clingo/size-t.patch
Normal file
22
var/spack/repos/builtin/packages/clingo/size-t.patch
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
diff --git a/libpyclingo/pyclingo.cc b/libpyclingo/pyclingo.cc
|
||||||
|
index ec4a33c..88b6669 100644
|
||||||
|
--- a/libpyclingo/pyclingo.cc
|
||||||
|
+++ b/libpyclingo/pyclingo.cc
|
||||||
|
@@ -116,7 +116,7 @@ struct ObjectProtocoll {
|
||||||
|
Object call(char const *name, Args &&... args);
|
||||||
|
template <class... Args>
|
||||||
|
Object operator()(Args &&... args);
|
||||||
|
- ssize_t size();
|
||||||
|
+ Py_ssize_t size();
|
||||||
|
bool empty() { return size() == 0; }
|
||||||
|
Object getItem(Reference o);
|
||||||
|
Object getItem(char const *key);
|
||||||
|
@@ -232,7 +232,7 @@ Object ObjectProtocoll<T>::operator()(Args &&... args) {
|
||||||
|
return PyObject_CallFunctionObjArgs(toPy_(), Reference(args).toPy()..., nullptr);
|
||||||
|
}
|
||||||
|
template <class T>
|
||||||
|
-ssize_t ObjectProtocoll<T>::size() {
|
||||||
|
+Py_ssize_t ObjectProtocoll<T>::size() {
|
||||||
|
auto ret = PyObject_Size(toPy_());
|
||||||
|
if (PyErr_Occurred()) { throw PyException(); }
|
||||||
|
return ret;
|
18
var/spack/repos/builtin/packages/clingo/vs2022.patch
Normal file
18
var/spack/repos/builtin/packages/clingo/vs2022.patch
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
diff --git a/libpyclingo/pyclingo.cc b/libpyclingo/pyclingo.cc
|
||||||
|
index 88b6669..58e73bd 100644
|
||||||
|
--- a/libpyclingo/pyclingo.cc
|
||||||
|
+++ b/libpyclingo/pyclingo.cc
|
||||||
|
@@ -25,6 +25,13 @@
|
||||||
|
// NOTE: the python header has a linker pragma to link with python_d.lib
|
||||||
|
// when _DEBUG is set which is not part of official python releases
|
||||||
|
#if defined(_MSC_VER) && defined(_DEBUG) && !defined(CLINGO_UNDEF__DEBUG)
|
||||||
|
+// Workaround for a VS 2022 issue.
|
||||||
|
+// NOTE: This workaround knowingly violates the Python.h include order requirement:
|
||||||
|
+// https://docs.python.org/3/c-api/intro.html#include-files
|
||||||
|
+# include <yvals.h>
|
||||||
|
+# if _MSVC_STL_VERSION >= 143
|
||||||
|
+# include <crtdefs.h>
|
||||||
|
+# endif
|
||||||
|
#undef _DEBUG
|
||||||
|
#include <Python.h>
|
||||||
|
#define _DEBUG
|
Loading…
Reference in New Issue
Block a user