Enably QtForPython for Linux (#5667)

- Fix PALification and include Linux for the QtForPython gem
- Add Linux-only module loader for Pyside2 related modules
- Remove (unnecessary) #if !defined(Q_OS_WIN)

Signed-off-by: Steve Pham <82231385+spham-amzn@users.noreply.github.com>
This commit is contained in:
Steve Pham
2021-11-17 08:28:33 -08:00
committed by GitHub
parent 593f03efb4
commit a051bdeeb0
13 changed files with 142 additions and 6 deletions
@@ -0,0 +1,60 @@
/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#pragma once
#include <AzCore/Debug/Trace.h>
#include <dlfcn.h>
namespace QtForPython
{
const char* s_libPythonLibraryFile = "libpython3.7m.so.1.0";
const char* s_libPyside2LibraryFile = "libpyside2.abi3.so.5.14";
const char* s_libShibokenLibraryFile = "libshiboken2.abi3.so.5.14";
class InitializeEmbeddedPyside2
{
public:
InitializeEmbeddedPyside2()
{
m_libPythonLibraryFile = InitializeEmbeddedPyside2::LoadModule(s_libPythonLibraryFile);
m_libPyside2LibraryFile = InitializeEmbeddedPyside2::LoadModule(s_libPyside2LibraryFile);
m_libShibokenLibraryFile = InitializeEmbeddedPyside2::LoadModule(s_libShibokenLibraryFile);
}
virtual ~InitializeEmbeddedPyside2()
{
InitializeEmbeddedPyside2::UnloadModule(m_libShibokenLibraryFile);
InitializeEmbeddedPyside2::UnloadModule(m_libPyside2LibraryFile);
InitializeEmbeddedPyside2::UnloadModule(m_libPythonLibraryFile);
}
private:
static void* LoadModule(const char* moduleToLoad)
{
void* moduleHandle = dlopen(moduleToLoad, RTLD_NOW | RTLD_GLOBAL);
if (!moduleHandle)
{
const char* loadError = dlerror();
AZ_Error("QtForPython", false, "Unable to load python library %s for Pyside2: %s", moduleToLoad,
loadError ? loadError : "Unknown Error");
}
return moduleHandle;
}
static void UnloadModule(void* moduleHandle)
{
if (moduleHandle)
{
dlclose(moduleHandle);
}
}
void* m_libPythonLibraryFile;
void* m_libPyside2LibraryFile;
void* m_libShibokenLibraryFile;
};
} // namespace QtForPython
@@ -6,4 +6,4 @@
#
#
set(PAL_TRAIT_BUILD_QTFORPYTHON_SUPPORTED FALSE)
set(PAL_TRAIT_BUILD_QTFORPYTHON_SUPPORTED TRUE)
@@ -0,0 +1,11 @@
#
# Copyright (c) Contributors to the Open 3D Engine Project.
# For complete copyright and license terms please see the LICENSE at the root of this distribution.
#
# SPDX-License-Identifier: Apache-2.0 OR MIT
#
#
set(FILES
InitializeEmbeddedPyside2.h
)
@@ -0,0 +1,18 @@
/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#pragma once
namespace QtForPython
{
class InitializeEmbeddedPyside2
{
public:
InitializeEmbeddedPyside2() = default;
virtual ~InitializeEmbeddedPyside2() = default;
};
} // namespace QtForPython
@@ -0,0 +1,11 @@
#
# Copyright (c) Contributors to the Open 3D Engine Project.
# For complete copyright and license terms please see the LICENSE at the root of this distribution.
#
# SPDX-License-Identifier: Apache-2.0 OR MIT
#
#
set(FILES
InitializeEmbeddedPyside2.h
)
@@ -0,0 +1,18 @@
/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#pragma once
namespace QtForPython
{
class InitializeEmbeddedPyside2
{
public:
InitializeEmbeddedPyside2() = default;
virtual ~InitializeEmbeddedPyside2() = default;
};
} // namespace QtForPython
@@ -0,0 +1,11 @@
#
# Copyright (c) Contributors to the Open 3D Engine Project.
# For complete copyright and license terms please see the LICENSE at the root of this distribution.
#
# SPDX-License-Identifier: Apache-2.0 OR MIT
#
#
set(FILES
InitializeEmbeddedPyside2.h
)