aboutsummaryrefslogtreecommitdiffstats
path: root/common/pybindings.cc
diff options
context:
space:
mode:
authorDavid Shah <davey1576@gmail.com>2018-06-08 11:17:04 +0200
committerDavid Shah <davey1576@gmail.com>2018-06-08 11:17:04 +0200
commitc16a971c0fe5980a2d6da23e7d3d6d917cb9dc67 (patch)
tree7258aa4dbe3ff282ecc3a8ed12ff088a06c35a07 /common/pybindings.cc
parent7f330af9f397ab121e11723bdf7b976630b7e450 (diff)
downloadnextpnr-c16a971c0fe5980a2d6da23e7d3d6d917cb9dc67.tar.gz
nextpnr-c16a971c0fe5980a2d6da23e7d3d6d917cb9dc67.tar.bz2
nextpnr-c16a971c0fe5980a2d6da23e7d3d6d917cb9dc67.zip
python: Fixing builds as importable module
Signed-off-by: David Shah <davey1576@gmail.com>
Diffstat (limited to 'common/pybindings.cc')
-rw-r--r--common/pybindings.cc4
1 files changed, 4 insertions, 0 deletions
diff --git a/common/pybindings.cc b/common/pybindings.cc
index 5c86720e..454a571c 100644
--- a/common/pybindings.cc
+++ b/common/pybindings.cc
@@ -113,6 +113,7 @@ static wchar_t *program;
void init_python(const char *executable)
{
+#ifndef PYTHON_MODULE
program = Py_DecodeLocale(executable, NULL);
if (program == NULL) {
fprintf(stderr, "Fatal error: cannot decode executable filename\n");
@@ -129,12 +130,15 @@ void init_python(const char *executable)
std::string perror_str = parse_python_exception();
std::cout << "Error in Python: " << perror_str << std::endl;
}
+#endif
}
void deinit_python()
{
+#ifndef PYTHON_MODULE
Py_Finalize();
PyMem_RawFree(program);
+#endif
}
void execute_python_file(const char *python_file)