diffvg
diffvg copied to clipboard
Windows build fail
Thanks for your outstanding contribution!
I encountered some errors while installing@BachiLi.
Could you please help me?
Here's the information.Thank you so much!
Building NVCC (Device) object CMakeFiles/diffvg.dir/Release/diffvg_generated_diffvg.cpp.obj diffvg.cpp C:\Users\LENOVO\Desktop\diffvg-master\pybind11\include\pybind11\cast.h(1405): error : too few arguments for template te mplate parameter "Tuple" [C:\Users\LENOVO\Desktop\diffvg-master\build\temp.win-amd64-3.8\Release\diffvg.vcxproj] detected during instantiation of class "pybind11::detail::tuple_caster<Tuple, Ts...> [with Tuple=std::pair, Ts=<T1, T2>]" (1483): here
C:\Users\LENOVO\Desktop\diffvg-master\pybind11\include\pybind11\cast.h(1479): error : too few arguments for template te mplate parameter "Tuple" [C:\Users\LENOVO\Desktop\diffvg-master\build\temp.win-amd64-3.8\Release\diffvg.vcxproj] detected during instantiation of class "pybind11::detail::tuple_caster<Tuple, Ts...> [with Tuple=std::pair, Ts=<T1, T2>]" (1483): here
C:\Users\LENOVO\Desktop\diffvg-master\pybind11\include\pybind11\cast.h(1041): warning : pointless comparison of unsigne
d integer with zero [C:\Users\LENOVO\Desktop\diffvg-master\build\temp.win-amd64-3.8\Release\diffvg.vcxproj]
detected during:
instantiation of "nv_bool pybind11::detail::type_caster<T, std::enable_if_t<
2 errors detected in the compilation of "c:/users/lenovo/desktop/diffvg-master/diffvg.cpp". diffvg.cpp CMake Error at diffvg_generated_diffvg.cpp.obj.Release.cmake:280 (message): Error generating file C:/Users/LENOVO/Desktop/diffvg-master/build/temp.win-amd64-3.8/Release/CMakeFiles/diffvg.dir//Release/diffvg_genera ted_diffvg.cpp.obj
Traceback (most recent call last):
File "setup.py", line 91, in
I have exactly the same problem... Any clue?
I was able to get this to work after trying a bunch of stuff (Windows 10, Visual Studio 2019, Python 3.9).
- Apply the patch below in the pybind11 submodule dir
- Make sure you have Visual Studio 2019 installed w/ build tools
- Make sure you have the python debug libs installed (run the installed, and enable all checkboxes related to debug)
- From the
diffvgfolder, runpython setup.py --debug install - Go to the newly installed site package of
diffvg, copy the stuff that's inDebugto the parent dir - Rename
diffvgtodiffvg.pyd
I'd try python setup.py install after step 1, just in case it works for you. Only a Debug build worked for me, for whatever reason.
From b33e16c799992a0486670929eafe19630f171645 Mon Sep 17 00:00:00 2001
From: nick porter <[email protected]>
Date: Thu, 9 Sep 2021 21:31:50 -0700
Subject: [PATCH] fix windows compilation issue related to type_caster for
std::pair
---
include/pybind11/cast.h | 39 +++++++++++++++++++++++++++++++++++++--
1 file changed, 37 insertions(+), 2 deletions(-)
diff --git a/include/pybind11/cast.h b/include/pybind11/cast.h
index 3e621eba..11b71fe5 100644
--- a/include/pybind11/cast.h
+++ b/include/pybind11/cast.h
@@ -644,8 +644,43 @@ protected:
Tuple<make_caster<Ts>...> subcasters;
};
-template <typename T1, typename T2> class type_caster<std::pair<T1, T2>>
- : public tuple_caster<std::pair, T1, T2> {};
+
+template <typename T1, typename T2> class type_caster<std::pair<T1, T2>> {
+ typedef std::pair<T1, T2> type;
+public:
+ bool load(handle src, bool convert) {
+ if (!isinstance<sequence>(src))
+ return false;
+ const auto seq = reinterpret_borrow<sequence>(src);
+ if (seq.size() != 2)
+ return false;
+ return first.load(seq[0], convert) && second.load(seq[1], convert);
+ }
+
+ static handle cast(const type &src, return_value_policy policy, handle parent) {
+ auto o1 = reinterpret_steal<object>(make_caster<T1>::cast(src.first, policy, parent));
+ auto o2 = reinterpret_steal<object>(make_caster<T2>::cast(src.second, policy, parent));
+ if (!o1 || !o2)
+ return handle();
+ tuple result(2);
+ PyTuple_SET_ITEM(result.ptr(), 0, o1.release().ptr());
+ PyTuple_SET_ITEM(result.ptr(), 1, o2.release().ptr());
+ return result.release();
+ }
+
+ static constexpr auto name = _("Pair");
+
+ template <typename T> using cast_op_type = type;
+
+ operator type() & { return type(cast_op<T1>(first), cast_op<T2>(second)); }
+ operator type() && { return type(cast_op<T1>(std::move(first)), cast_op<T2>(std::move(second))); }
+protected:
+ make_caster<T1> first;
+ make_caster<T2> second;
+};
+
+// template <typename T1, typename T2> class type_caster<std::pair<T1, T2>>
+// : public tuple_caster<std::pair, T1, T2> {};
template <typename... Ts> class type_caster<std::tuple<Ts...>>
: public tuple_caster<std::tuple, Ts...> {};
--
2.33.0.windows.2
This worked for me in VSCode :)
I was not able to use the above fix.
Maybe I am not reading the instructions correctly. What is meant by:
- Make sure you have the python debug libs installed (run the installed, and enable all checkboxes related to debug)
I assume that by
- From the diffvg folder, run python setup.py --debug install
You actually mean python setup.py build --debug install.
And for
- Go to the newly installed site package of diffvg, copy the stuff that's in Debug to the parent dir
I assume that this is a anaconda3/libs/site-packages/diffvg? That folder is never installed for me since python setup.py build --debug install still causes the same error as above, even after applying the patch.
- Apply the patch below in the pybind11 submodule dir
I am not sure where this code is supposed to go in th pybind11 folder? Am I meant to edit one of the files? TIA @surjikal
i have navigated to \diffvg\pybind11> in powershell and copy and pasted the patch from "diff --git..." onwards but get a flurry of errors.
Do I need to change the "a" in a/include/pybind11/cast.h to my local directory?
@surjikal