Skip to content

[poetry plugin] enable pyproject-dir to be configurable #1567

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 4 commits into from
Oct 18, 2023

Conversation

savil
Copy link
Collaborator

@savil savil commented Oct 17, 2023

Summary

We can enable the poetry project to exist in a sub-directory of the devbox-project by allowing a user to set DEVBOX_PYPROJECT_DIR.

Note, this only works if there is a single poetry project in the devbox-project. For multiple poetry projects in a monorepo, I think users may need to define distinct devbox-projects.

Fixes #1563

How was it tested?

In the added example, ran devbox run run_test. Previously, this would fail.

Also verified the default directory is the project dir, by removing the DEVBOX_PYPROJECT_DIR env-var, and seeing this error message:

examples/development/python/poetry/poetry-pyproject-subdir/service> devbox run run_test

Poetry could not find a pyproject.toml file in /Users/savil/code/jetpack/devbox/examples/development/python/poetry/poetry-pyproject-subdir or its parents
Error: error running script "run_test" in Devbox: exit status 1

Copy link
Collaborator Author

savil commented Oct 17, 2023

Current dependencies on/for this PR:

This comment was auto-generated by Graphite.

@savil savil requested a review from mikeland73 October 17, 2023 21:33
@savil savil marked this pull request as ready for review October 17, 2023 21:33
Copy link
Contributor

@mikeland73 mikeland73 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is OK, but does it solve the bug in question? I think the user wanted to use this in a multi pyproject repo.

I feel like a better solution is to only run poetry env use if there's a pyproject file

(or maybe a combination of both)

@@ -235,6 +235,7 @@ func buildConfig(pkg Includable, projectDir, content string) (*config, error) {
"DevboxDir": filepath.Join(projectDir, devboxDirName, name),
"DevboxDirRoot": filepath.Join(projectDir, devboxDirName),
"DevboxProfileDefault": filepath.Join(projectDir, nix.ProfilePath),
"ProjectDir": projectDir,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this already exists and is called DevboxProjectDir

@savil
Copy link
Collaborator Author

savil commented Oct 17, 2023

I think this is OK, but does it solve the bug in question? I think the user wanted to use this in a multi pyproject repo.

Yes, it solves it. The user has a single poetry service folder.

@savil
Copy link
Collaborator Author

savil commented Oct 17, 2023

@mikeland73 I'm not a fan of the conditional check, because then the poetry plugin is less robust. It'll use the python-from-devbox-json in some circumstances and not in others, which could lead to more subtle bugs.

@savil savil merged commit bb5b0aa into main Oct 18, 2023
@savil savil deleted the savil/poetry-plugin-enable-pyproject-dir branch October 18, 2023 00:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: Repo with poetry submodule failing since 0.7
2 participants