Skip to content

Commit eba7998

Browse files
authored
Poetry plugin (#1343)
## Summary Builtin plugin for Poetry that configures it to use the installed version of python, instead of the one that Poetry is built with This also sets some environment variables that create the poetry virtualenv inside the project ## How was it tested? Tested using the example project, also in this PR. Run `poetry env info` to confirm it's using the right version of Poetry
1 parent 02e522e commit eba7998

File tree

7 files changed

+51
-51
lines changed

7 files changed

+51
-51
lines changed

examples/cloud_development/temporal/devbox.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"shell": {
1313
"init_hook": [
1414
"echo 'Setting flags to allow Python C extension compilation'",
15-
"export NIX_CFLAGS_COMPILE=\"$NIX_CFLAGS_COMPILE $(cat $(dirname $(which clang))/../nix-support/libcxx-cxxflags)\"",
15+
"export NIX_CFLAGS_COMPILE=\"$NIX_CFLAGS_COMPILE $(cat $(dirname $(command -v clang))/../nix-support/libcxx-cxxflags)\"",
1616
"echo 'Setting up virtual environment'",
1717
"source $VENV_DIR/bin/activate"
1818
],

examples/development/python/poetry/poetry-demo/devbox.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"packages": [
3-
"python@3.10",
3+
"python@3.8",
44
55
],
66
"shell": {
Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,19 @@
11
{
22
"lockfile_version": "1",
33
"packages": {
4-
"poetry": {
5-
"last_modified": "",
6-
"resolved": "github:NixOS/nixpkgs/f80ac848e3d6f0c12c52758c0f25c10c97ca3b62#poetry",
7-
"version": ""
4+
5+
"last_modified": "2023-05-19T19:44:39Z",
6+
"plugin_version": "0.0.1",
7+
"resolved": "github:NixOS/nixpkgs/4a22f6f0a4b4354778f786425babce9a56f6b5d8#poetry",
8+
"source": "devbox-search",
9+
"version": "1.4.2"
810
},
9-
"python310": {
10-
"last_modified": "",
11-
"resolved": "github:NixOS/nixpkgs/f80ac848e3d6f0c12c52758c0f25c10c97ca3b62#python310",
12-
"version": ""
11+
12+
"last_modified": "2023-06-30T04:44:22Z",
13+
"plugin_version": "0.0.1",
14+
"resolved": "github:NixOS/nixpkgs/3c614fbc76fc152f3e1bc4b2263da6d90adf80fb#python38",
15+
"source": "devbox-search",
16+
"version": "3.8.17"
1317
}
1418
}
15-
}
19+
}

examples/development/python/poetry/poetry-demo/poetry.lock

Lines changed: 19 additions & 39 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/development/python/poetry/poetry-demo/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ description = ""
55
authors = ["John Lago <[email protected]>"]
66

77
[tool.poetry.dependencies]
8-
python = "^3.10"
8+
python = "^3.8"
99
emoji = "^2.1.0"
1010

1111
[tool.poetry.dev-dependencies]

plugins/builtins.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ var builtInMap = map[*regexp.Regexp]string{
3333
regexp.MustCompile(`^mysql?[0-9]*$`): "mysql",
3434
regexp.MustCompile(`^php[0-9]*$`): "php",
3535
regexp.MustCompile(`^python3[0-9]*Packages.pip$`): "pip",
36+
regexp.MustCompile(`^(\w*\.)?poetry$`): "poetry",
3637
regexp.MustCompile(`^postgresql(_[0-9]+)?$`): "postgresql",
3738
regexp.MustCompile(`^python[0-9]*(Full|Minimal|-full|-minimal)?$`): "python",
3839
regexp.MustCompile(`^redis$`): "redis",

plugins/poetry.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"name": "poetry",
3+
"version": "0.0.1",
4+
"readme": "This plugin automatically configures poetry to use the version of python installed in your Devbox shell, instead of the Python version that it is bundled with.",
5+
"env": {
6+
"POETRY_VIRTUALENVS_IN_PROJECT": "true",
7+
"POETRY_VIRTUALENVS_CREATE": "true",
8+
"POETRY_VIRTUALENVS_PATH": "{{.Virtenv}}/.virtualenvs"
9+
},
10+
"shell": {
11+
"init_hook": [
12+
"poetry env use $(command -v python) --quiet --no-interaction"
13+
]
14+
}
15+
}

0 commit comments

Comments
 (0)