-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Provide an alternative to
embedded_python_tools.symlink_import()
Until now, we've primarily been symlinking the Python dir into the build folder. However, that has a couple of issues: 1. Occasionally the symlink goes wrong and needs to be deleted manually. This is especially problematic on Windows. 2. The `conanfile.py` syntax is surprising. Even more so with Conan v2 where it requires a manual `sys.path.append()` to work. `symlink_import()` was essentially creating a symlink from `bin/python` to `<conan_package_path>/embedded_python`. The project executable would point `PyConfig::home` to `bin/python`. This commit provides an alternative that simply writes that directory path to a file called `bin/.embedded_python.home`. The executable can read that file on startup and point `PyConfig::home` there. For now, both methods are valid. If the home file works out, we can deprecate `symlink_import()` and remove it down the line.
- Loading branch information
Showing
7 changed files
with
72 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
include_guard(DIRECTORY) | ||
|
||
# For development, we want avoid copying all of Python's `lib` and `site-packages` into our | ||
# build tree every time we re-configure the project. Instead, we can point `PyConfig::home` | ||
# to the contents of this file to gain access to all the Python packages. | ||
# For release/deployment, the entire `Python_ROOT_DIR` should be copied into the app's `bin` | ||
# folder and `PyConfig::home` should point to that. | ||
function(embedded_python_generate_home_file filename content) | ||
if(DEFINED CMAKE_RUNTIME_OUTPUT_DIRECTORY) | ||
set(filename ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${filename}) | ||
endif() | ||
file(GENERATE OUTPUT ${filename} CONTENT "${content}") | ||
endfunction() | ||
|
||
embedded_python_generate_home_file(".embedded_python-core.home" "${Python_ROOT_DIR}") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters