-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Rework internal PYTHONPATH maintenance #6922
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
35a174a
Rework PYTHONPATH
steven-johnson 4e0659f
Merge branch 'main' into srj/pythonpath
steven-johnson b4fd6ef
Merge branch 'main' into srj/pythonpath
steven-johnson 53a3362
Move pure-Python file copying logic to build time.
alexreinking 3fc3273
Use TARGET_RUNTIME_DLLS to copy all DLLs instead of just Halide.
alexreinking 4ea676f
Ensure that the last path component for Halide_Python is always `halide`
alexreinking a1947cf
Attempt to fix PYTHONPATH stuff
steven-johnson e3fcb66
Update CMakeLists.txt
steven-johnson a7a78c8
Update CMakeLists.txt
steven-johnson 9f802ed
Remove Duplicates
steven-johnson 31e61cd
Update CMakeLists.txt
steven-johnson 437b71c
wip
steven-johnson f9e7932
Drop the "one level up" dummy target
alexreinking 0954bcf
Simplify __init__.py now that it's copied to build tree
alexreinking 06939ea
Add helper to de-duplicate PYTHONPATH test logic
alexreinking 1d2b23b
Remove CTest label to avoid duplicate test runs
alexreinking 593d264
Use list(PREPEND) consistently
alexreinking File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 @@ | ||
| add_subdirectory(halide) |
This file contains hidden or 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 hidden or 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 |
|---|---|---|
| @@ -1,24 +1,2 @@ | ||
| # TODO(#6870): The following three lines are a stop-gap. This file should just | ||
| # contain the last two imports, at least until the pure-Python part of the | ||
| # library grows. | ||
| # | ||
| # There are three main reasons why this exists: | ||
| # | ||
| # 1. relative imports cannot be overloaded with sys.path | ||
| # 2. for a variety of reasons, copying the python sources next to the | ||
| # halide_.*.so module is difficult to make work in 100% of cases in CMake | ||
| # 3. even if we could copy them reliably, copying these files into the build | ||
| # folder seems inelegant | ||
| # | ||
| # Fortunately, there are apparently other hooks besides sys.path that we could | ||
| # use to redirect a failing relative import. | ||
| # | ||
| # https://docs.python.org/3/reference/import.html#finders-and-loaders | ||
| # https://github.com/halide/Halide/issues/6870 | ||
|
|
||
| import sys | ||
| from pathlib import Path | ||
| sys.path.append(str(Path(__file__).parent.resolve(strict=True))) | ||
|
|
||
| from halide_ import * | ||
| from halide_ import _, _1, _2, _3, _4, _5, _6, _7, _8, _9 | ||
| from .halide_ import * | ||
| from .halide_ import _, _1, _2, _3, _4, _5, _6, _7, _8, _9 |
This file contains hidden or 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 |
|---|---|---|
| @@ -1,29 +1,16 @@ | ||
| set(scripts | ||
| set(tests | ||
| bilateral_grid.py | ||
| blur.py | ||
| erode.py | ||
| interpolate.py | ||
| local_laplacian.py) | ||
|
|
||
| set(PYTHONPATH | ||
| "$<TARGET_FILE_DIR:Halide::Python>" | ||
| "${Halide_SOURCE_DIR}/python_bindings/src") | ||
| list(TRANSFORM PYTHONPATH PREPEND "PYTHONPATH=path_list_prepend:") | ||
|
|
||
| set(TEST_ENV | ||
| "HL_TARGET=${Halide_TARGET}" | ||
| "TEST_TMPDIR=$<SHELL_PATH:${CMAKE_CURRENT_BINARY_DIR}>" | ||
| "TEST_IMAGES_DIR=$<SHELL_PATH:${CMAKE_CURRENT_SOURCE_DIR}/../../../apps/images>" | ||
| ) | ||
|
|
||
| foreach (script IN LISTS scripts) | ||
| cmake_path(GET script STEM base) | ||
| add_test(NAME python_apps_${base} | ||
| COMMAND Python3::Interpreter "$<SHELL_PATH:${CMAKE_CURRENT_SOURCE_DIR}/${script}>") | ||
| set_tests_properties( | ||
| python_apps_${base} PROPERTIES | ||
| LABELS python | ||
| ENVIRONMENT "${TEST_ENV}" | ||
| ENVIRONMENT_MODIFICATION "${PYTHONPATH}" | ||
| foreach (test IN LISTS tests) | ||
| add_python_test( | ||
| FILE "${test}" | ||
| LABEL python_apps | ||
| ENVIRONMENT | ||
| "TEST_TMPDIR=$<SHELL_PATH:${CMAKE_CURRENT_BINARY_DIR}>" | ||
| "TEST_IMAGES_DIR=$<SHELL_PATH:${CMAKE_CURRENT_SOURCE_DIR}/../../../apps/images>" | ||
| ) | ||
| endforeach () |
This file contains hidden or 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 hidden or 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 hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We'll also need some similar logic (in the
pygenbranch) to construct the proper PYTHONPATH for use when driving Python generators (which aren't tests), but we can refactor that after this merges.