Python_linux.cpp 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. /*
  2. * All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
  3. * its licensors.
  4. *
  5. * For complete copyright and license terms please see the LICENSE at the root of this
  6. * distribution (the "License"). All use of this software is governed by the License,
  7. * or, if provided, by the license below or the license accompanying this file. Do not
  8. * remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
  9. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. *
  11. */
  12. #include <AzCore/PlatformDef.h>
  13. #include <AzCore/std/containers/unordered_set.h>
  14. #include <AzCore/IO/SystemFile.h>
  15. #include <AzCore/IO/Path/Path.h>
  16. #include <AzFramework/StringFunc/StringFunc.h>
  17. namespace Platform
  18. {
  19. extern bool InsertPythonLibraryPath(AZStd::unordered_set<AZStd::string>& paths, const char* pythonPackage, const char* engineRoot, const char* subPath);
  20. bool InsertPythonBinaryLibraryPaths(AZStd::unordered_set<AZStd::string>& paths, const char* pythonPackage, const char* engineRoot)
  21. {
  22. bool succeeded = true;
  23. succeeded = succeeded && InsertPythonLibraryPath(paths, pythonPackage, engineRoot, "python/runtime/%s/python/lib");
  24. succeeded = succeeded && InsertPythonLibraryPath(paths, pythonPackage, engineRoot, "python/runtime/%s/python/lib/python3.7/lib-dynload");
  25. succeeded = succeeded && InsertPythonLibraryPath(paths, pythonPackage, engineRoot, "python/runtime/%s/python/lib/python3.7");
  26. succeeded = succeeded && InsertPythonLibraryPath(paths, pythonPackage, engineRoot, "python/runtime/%s/python/lib/python3.7/site-packages");
  27. return succeeded;
  28. }
  29. AZStd::string GetPythonHomePath(const char* pythonPackage, const char* engineRoot)
  30. {
  31. // append lib path to Python paths
  32. AZ::IO::FixedMaxPath libPath = engineRoot;
  33. libPath /= AZ::IO::FixedMaxPathString::format("python/runtime/%s/python", pythonPackage);
  34. libPath = libPath.LexicallyNormal();
  35. return libPath.String();
  36. }
  37. }