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
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
## Poetry in a monorepo

This example demonstrates using a poetry project in a sub-folder (`services` in this case)
by specifying the `DEVBOX_PYPROJECT_DIR` that the poetry plugin can use.
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"packages": [
"poetry@latest",
"python3@latest"
],
"env": {
"DEVBOX_PYPROJECT_DIR": "$PWD/service"
},
"shell": {
"init_hook": [
"echo 'Welcome to devbox!' > /dev/null"
],
"scripts": {
"install-service":[
"cd service",
"poetry install"
],
"run_test": [
"devbox run install-service",
"cd service && poetry run pytest"
]
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{
"lockfile_version": "1",
"packages": {
"poetry@latest": {
"last_modified": "2023-10-15T14:24:03Z",
"plugin_version": "0.0.3",
"resolved": "github:NixOS/nixpkgs/12bdeb01ff9e2d3917e6a44037ed7df6e6c3df9d#poetry",
"source": "devbox-search",
"version": "1.6.1",
"systems": {
"aarch64-darwin": {
"store_path": "/nix/store/i7q6kxa3ac7c57zalr4vwa04c1bll3xd-python3.10-poetry-1.6.1"
},
"aarch64-linux": {
"store_path": "/nix/store/7va0dmf3m4iswxfwrynp76290lcffzm1-python3.10-poetry-1.6.1"
},
"x86_64-darwin": {
"store_path": "/nix/store/ymnfx9pbc4y9zp5rg8zcbxq3c14rhz1d-python3.10-poetry-1.6.1"
},
"x86_64-linux": {
"store_path": "/nix/store/s2sqjwgm0h2ak2zvkvvbiw9fz4vsr5il-python3.10-poetry-1.6.1"
}
}
},
"python3@latest": {
"last_modified": "2023-10-06T07:35:11Z",
"plugin_version": "0.0.1",
"resolved": "github:NixOS/nixpkgs/a2eb207f45e4a14a1e3019d9e3863d1e208e2295#python3",
"source": "devbox-search",
"version": "3.10.12",
"systems": {
"aarch64-darwin": {
"store_path": "/nix/store/g5cm6iik6p4k39cj9k7a6sg2p09hl7wf-python3-3.10.12"
},
"aarch64-linux": {
"store_path": "/nix/store/idpjrasbr9n8kij11s5mphrw770sf13s-python3-3.10.12"
},
"x86_64-darwin": {
"store_path": "/nix/store/aa3nnkfyif67k6861vd77g4cm4rgbqh8-python3-3.10.12"
},
"x86_64-linux": {
"store_path": "/nix/store/pzf6dnxg8gf04xazzjdwarm7s03cbrgz-python3-3.10.12"
}
}
}
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[tool.poetry]
name = "poetry-pyproject-subdir-service"
version = "0.1.0"
description = ""
authors = ["Savil Srivastava <[email protected]>"]

[tool.poetry.dependencies]
python = "^3.8"
emoji = "^2.1.0"

[tool.poetry.dev-dependencies]
pytest = "^7.2.2"

[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

def test_always_passes():
assert True

#def test_always_fails():
# assert False
3 changes: 2 additions & 1 deletion plugins/poetry.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
{
"name": "poetry",
"version": "0.0.3",
"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. Your pyproject.toml must be in the same directory as your devbox.json.",
"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. The pyproject.toml location can be configured by setting DEVBOX_PYPROJECT_DIR (defaults to the devbox.json's directory).",
"env": {
"DEVBOX_DEFAULT_PYPROJECT_DIR": "{{ .DevboxProjectDir }}",
"POETRY_VIRTUALENVS_IN_PROJECT": "true",
"POETRY_VIRTUALENVS_CREATE": "true",
"POETRY_VIRTUALENVS_PATH": "{{.Virtenv}}/.virtualenvs"
Expand Down
2 changes: 1 addition & 1 deletion plugins/poetry/initHook.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh

poetry env use $(command -v python) --no-interaction
poetry env use $(command -v python) --directory="${DEVBOX_PYPROJECT_DIR:-$DEVBOX_DEFAULT_PYPROJECT_DIR}" --no-interaction