Repository navigation
be-py: put a dashed library's own directory on PYTHONPATH - #614
Open
notactuallytreyanastasio wants to merge 1 commit into
Open
notactuallytreyanastasio wants to merge 1 commit into
notactuallytreyanastasio wants to merge 1 commit into
Conversation
`temper run -b py` on a library named `hello-world` that only prints
fails:
PYTHONPATH=.../temper.out/py/hello_world:.../temper.out/py/temper-core:.../temper.out/py/deps
ModuleNotFoundError: No module named 'hello_world'
The package is at `temper.out/py/hello-world/hello_world/`, so the
directory that has to be on the path is `hello-world`. runPyBestEffort
built the library's path from its Python module name, `hello_world`,
which names no directory. The dependency paths next to it use the
Temper name, and they cover every library in
`transitiveDependencies`, so the run worked whenever the build had
recorded a dependency from the library on another one: an `Int`
addition, which uses temper-core's `int_add`, was enough. A library
that only calls `console.log` records none, and a name with no dash
hid the mismatch because the two names are the same.
The library's own path now uses the Temper name too. Its directory is
then also the one the dependency loop skips, so it is listed once.
RunTest.runPyBackendDashedName runs a `hello-world` library that
prints one line. Before this change it fails with the
ModuleNotFoundError above; after, it prints `I ran`.
Fixes temperlang#609.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Signed-off-by: Bobby Grayson <bobbbygrayson+github@gmail.com>
mikesamuel
reviewed
Oct 12, 2026
| @@ -0,0 +1,3 @@ | |||
| # Test | |||
Contributor
There was a problem hiding this comment.
fyi, we use the header here for the name if it's not specified, so
# Hello World
would be an equivalent config.
| val pyLibraryPath = pyLibraryName?.let { pyDir.resolveDir(pyLibraryName.text) } | ||
| // The library's directory is named for the Temper library, like its dependencies' below, | ||
| // not for its Python module: `hello-world`, not `hello_world`. | ||
| val pyLibraryPath = (request as? RunLibraryRequest)?.let { pyDir.resolveDir(it.libraryName.text) } |
Contributor
There was a problem hiding this comment.
Could this be a when (request) instead of using as? so that we explicitly cover the different request cases. It's ok if we're using null for some cases, just it's clearer if we're deriving this that we've covered our bases.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
temper run -b pyon a library namedhello-worldthat only printsfails:
The package is at
temper.out/py/hello-world/hello_world/, so thedirectory that has to be on the path is
hello-world. runPyBestEffortbuilt the library's path from its Python module name,
hello_world,which names no directory. The dependency paths next to it use the
Temper name, and they cover every library in
transitiveDependencies, so the run worked whenever the build hadrecorded a dependency from the library on another one: an
Intaddition, which uses temper-core's
int_add, was enough. A librarythat only calls
console.logrecords none, and a name with no dashhid the mismatch because the two names are the same.
The library's own path now uses the Temper name too. Its directory is
then also the one the dependency loop skips, so it is listed once.
RunTest.runPyBackendDashedName runs a
hello-worldlibrary thatprints one line. Before this change it fails with the
ModuleNotFoundError above; after, it prints
I ran.Fixes #609.
Reproduction:
56-py-run-hyphenated-library/in temper-issue-repros.🤖 Generated with Claude Code