Python_windows.cpp 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /*
  2. * Copyright (c) Contributors to the Open 3D Engine Project.
  3. * For complete copyright and license terms please see the LICENSE at the root of this distribution.
  4. *
  5. * SPDX-License-Identifier: Apache-2.0 OR MIT
  6. *
  7. */
  8. #include <AzCore/PlatformDef.h>
  9. #include <AzCore/std/containers/unordered_set.h>
  10. #include <AzCore/IO/SystemFile.h>
  11. #include <AzCore/IO/Path/Path.h>
  12. #include <AzFramework/StringFunc/StringFunc.h>
  13. namespace Platform
  14. {
  15. extern bool InsertPythonLibraryPath(AZStd::unordered_set<AZStd::string>& paths, const char* pythonPackage, const char* engineRoot, const char* subPath);
  16. bool InsertPythonBinaryLibraryPaths(AZStd::unordered_set<AZStd::string>& paths, const char* pythonPackage, const char* engineRoot)
  17. {
  18. bool succeeded = true;
  19. succeeded = succeeded && InsertPythonLibraryPath(paths, pythonPackage, engineRoot, "python/runtime/%s/python");
  20. succeeded = succeeded && InsertPythonLibraryPath(paths, pythonPackage, engineRoot, "python/runtime/%s/python/lib");
  21. succeeded = succeeded && InsertPythonLibraryPath(paths, pythonPackage, engineRoot, "python/runtime/%s/python/lib/site-packages");
  22. succeeded = succeeded && InsertPythonLibraryPath(paths, pythonPackage, engineRoot, "python/runtime/%s/python/DLLs");
  23. return succeeded;
  24. }
  25. AZStd::string GetPythonHomePath(const char* pythonPackage, const char* engineRoot)
  26. {
  27. // append lib path to Python paths
  28. AZ::IO::FixedMaxPath libPath = engineRoot;
  29. libPath /= AZ::IO::FixedMaxPathString::format("python/runtime/%s/python", pythonPackage);
  30. libPath = libPath.LexicallyNormal();
  31. return libPath.String();
  32. }
  33. AZStd::string GetPythonExecutablePath(const char* engineRoot)
  34. {
  35. // append lib path to Python paths
  36. AZ::IO::FixedMaxPath libPath = engineRoot;
  37. libPath /= AZ::IO::FixedMaxPathString("python/python.cmd");
  38. libPath = libPath.LexicallyNormal();
  39. return libPath.String();
  40. }
  41. }