Skip to content

Commit b702f8c

Browse files
committed
Get anaconda path from registry.
1 parent 4794b98 commit b702f8c

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

README.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,7 @@ warned, it can easily take several hours, but at least it's automatic)::
388388
389389
vcpkg install mpir:x64-windows glibmm:x64-windows (go have a coffee)
390390
vcpkg install sqlite3:x64-windows boost:x64-windows (go for dinner)
391-
vcpkg install gtkmm:x64-windows (run overnight)
391+
vcpkg install gtkmm:x64-windows winreg:x64-windows (run overnight)
392392
vcpkg integrate install
393393

394394
boost-system:x64-windows

client_server/cadabra-server.cc

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
#ifdef _WIN32
88
#include <Windows.h>
9+
#include <WinReg.hpp>
910
#endif
1011

1112
// Run a simple Cadabra server on a local port.
@@ -14,10 +15,18 @@ int main()
1415
{
1516
#ifdef _WIN32
1617
// The Anaconda people _really_ do not understand packaging...
18+
// We are going to find out the installation path for Anaconda/Miniconda
19+
// by querying a registry key.
1720
std::string pythonhome=Glib::getenv("PYTHONHOME");
18-
std::string pythonpath=Glib::getenv("PYTHONPATH");
19-
Glib::setenv("PYTHONHOME", (pythonhome.size()>0)?(pythonhome+":"):"" + Glib::get_home_dir()+"/Anaconda3");
20-
Glib::setenv("PYTHONPATH", (pythonpath.size()>0)?(pythonpath+":"):"" + Glib::get_home_dir()+"/Anaconda3");
21+
std::string pythonpath=Glib::getenv("PYTHONPATH");
22+
23+
winreg::RegKey key{ winreg::HKEY_CURRENT_USER, L"SOFTWARE\\Python\\PythonCore\\3.7" };
24+
std::wstring s = key.GetStringValue(L"");
25+
26+
// Glib::setenv("PYTHONHOME", (pythonhome.size()>0)?(pythonhome+":"):"" + Glib::get_home_dir()+"/Anaconda3");
27+
// Glib::setenv("PYTHONPATH", (pythonpath.size()>0)?(pythonpath+":"):"" + Glib::get_home_dir()+"/Anaconda3");
28+
Glib::setenv("PYTHONHOME", (pythonhome.size()>0)?(pythonhome+":"):"" + s);
29+
Glib::setenv("PYTHONPATH", (pythonpath.size()>0)?(pythonpath+":"):"" + s);
2130
// std::cerr << "Server::init: using PYTHONPATH = " << Glib::getenv("PYTHONPATH")
2231
// << " and PYTHONHOME = " << Glib::getenv("PYTHONHOME") << "." << std::endl;
2332
#endif

0 commit comments

Comments
 (0)