diff --git a/examples/development/python/poetry/poetry-demo/README.md b/examples/development/python/poetry/poetry-demo/README.md index 48649f7f294..fea2f153218 100644 --- a/examples/development/python/poetry/poetry-demo/README.md +++ b/examples/development/python/poetry/poetry-demo/README.md @@ -10,7 +10,7 @@ In this directory, run: `devbox shell` -This will automatically activate your poetry shell via the `init_hook`. +To activate your poetry shell add `"eval $(poetry env activate)"` to the `init_hook` otherwise use poetry to run commands, e.g. `poetry run pytest`. To exit the poetry shell, use `exit`. To exit your devbox shell, use `exit` again. diff --git a/examples/development/python/poetry/poetry-demo/devbox.json b/examples/development/python/poetry/poetry-demo/devbox.json index 1b73722da1a..eb0161ff3ef 100644 --- a/examples/development/python/poetry/poetry-demo/devbox.json +++ b/examples/development/python/poetry/poetry-demo/devbox.json @@ -1,6 +1,5 @@ { "packages": [ - "python@latest", "poetry@latest" ], "shell": { diff --git a/examples/development/python/poetry/poetry-demo/devbox.lock b/examples/development/python/poetry/poetry-demo/devbox.lock index e1418150018..e211d2aa812 100644 --- a/examples/development/python/poetry/poetry-demo/devbox.lock +++ b/examples/development/python/poetry/poetry-demo/devbox.lock @@ -2,128 +2,71 @@ "lockfile_version": "1", "packages": { "github:NixOS/nixpkgs/nixpkgs-unstable": { - "last_modified": "2025-06-18T03:01:18Z", - "resolved": "github:NixOS/nixpkgs/5395fb3ab3f97b9b7abca147249fa2e8ed27b192?lastModified=1750215678&narHash=sha256-Rc%2FytpamXRf6z8UA2SGa4aaWxUXRbX2MAWIu2C8M%2Bok%3D" + "last_modified": "2025-09-01T03:15:32Z", + "resolved": "github:NixOS/nixpkgs/58dcbf1ec551914c3756c267b8b9c8c86baa1b2f?lastModified=1756696532&narHash=sha256-6FWagzm0b7I%2FIGigOv9pr6LL7NQ86mextfE8g8Q6HBg%3D" }, "poetry@latest": { - "last_modified": "2024-02-10T18:15:24Z", + "last_modified": "2025-08-11T23:54:17Z", "plugin_version": "0.0.4", - "resolved": "github:NixOS/nixpkgs/10b813040df67c4039086db0f6eaf65c536886c6#poetry", + "resolved": "github:NixOS/nixpkgs/5a983011e0f4b3b286aaa73e011ce32b1449a528#poetry", "source": "devbox-search", - "version": "1.7.1", + "version": "2.1.4", "systems": { "aarch64-darwin": { "outputs": [ { "name": "out", - "path": "/nix/store/0pf30mblcl4clvagdzybfgfyzjqkjkqi-python3.11-poetry-1.7.1", + "path": "/nix/store/40wdkwvhgyak26dvm7nvk79sazsp70p0-python3.13-poetry-2.1.4", "default": true }, { "name": "dist", - "path": "/nix/store/rs4ya5784629m6842b4g1fc360dscc9n-python3.11-poetry-1.7.1-dist" + "path": "/nix/store/pqnpbi6kfcgpliwlw3d07n73iwd4zq10-python3.13-poetry-2.1.4-dist" } ], - "store_path": "/nix/store/0pf30mblcl4clvagdzybfgfyzjqkjkqi-python3.11-poetry-1.7.1" + "store_path": "/nix/store/40wdkwvhgyak26dvm7nvk79sazsp70p0-python3.13-poetry-2.1.4" }, "aarch64-linux": { "outputs": [ { "name": "out", - "path": "/nix/store/knc1livlnrnaxbnfs9118nq69i78jj39-python3.11-poetry-1.7.1", + "path": "/nix/store/1wcnin7zb7p3kgb0a5rdr123k1zm5m79-python3.13-poetry-2.1.4", "default": true }, { "name": "dist", - "path": "/nix/store/xmfkj29vxivcmzsy02lvxrk8fagzp71b-python3.11-poetry-1.7.1-dist" + "path": "/nix/store/x1y9vaw30ibdsp0c3q4k6kb9lsy125ah-python3.13-poetry-2.1.4-dist" } ], - "store_path": "/nix/store/knc1livlnrnaxbnfs9118nq69i78jj39-python3.11-poetry-1.7.1" + "store_path": "/nix/store/1wcnin7zb7p3kgb0a5rdr123k1zm5m79-python3.13-poetry-2.1.4" }, "x86_64-darwin": { "outputs": [ { "name": "out", - "path": "/nix/store/qf2px4ic22dpra0s6mlmjm5q4vvc6dr7-python3.11-poetry-1.7.1", + "path": "/nix/store/ag8lzpbpacp6jfy7z7wjnkwbfic1ikms-python3.13-poetry-2.1.4", "default": true }, { "name": "dist", - "path": "/nix/store/0xg2c7pcfa5kcazibw503ni49lclprj7-python3.11-poetry-1.7.1-dist" + "path": "/nix/store/4hjin62zaapxgysj7z72729s6ww7wk00-python3.13-poetry-2.1.4-dist" } ], - "store_path": "/nix/store/qf2px4ic22dpra0s6mlmjm5q4vvc6dr7-python3.11-poetry-1.7.1" + "store_path": "/nix/store/ag8lzpbpacp6jfy7z7wjnkwbfic1ikms-python3.13-poetry-2.1.4" }, "x86_64-linux": { "outputs": [ { "name": "out", - "path": "/nix/store/fq4cf1xzwlvbhg98ih8dvsq2hsalhzyp-python3.11-poetry-1.7.1", + "path": "/nix/store/0in2k6jizc97cw3w4yivn2v3nipplfrb-python3.13-poetry-2.1.4", "default": true }, { "name": "dist", - "path": "/nix/store/jgn140k0ag3yyl1ysqgz7wikbzgzifdh-python3.11-poetry-1.7.1-dist" + "path": "/nix/store/k5hi65p5y654wi6llza3azcz1xx0l7i5-python3.13-poetry-2.1.4-dist" } ], - "store_path": "/nix/store/fq4cf1xzwlvbhg98ih8dvsq2hsalhzyp-python3.11-poetry-1.7.1" - } - } - }, - "python@latest": { - "last_modified": "2024-02-10T18:15:24Z", - "plugin_version": "0.0.4", - "resolved": "github:NixOS/nixpkgs/10b813040df67c4039086db0f6eaf65c536886c6#python312", - "source": "devbox-search", - "version": "3.12.1", - "systems": { - "aarch64-darwin": { - "outputs": [ - { - "name": "out", - "path": "/nix/store/s1mr5bmvfcy4hm7669d2xx3gqgj481qk-python3-3.12.1", - "default": true - } - ], - "store_path": "/nix/store/s1mr5bmvfcy4hm7669d2xx3gqgj481qk-python3-3.12.1" - }, - "aarch64-linux": { - "outputs": [ - { - "name": "out", - "path": "/nix/store/qv710q1p74qb7bswpwh59px28gfj51b1-python3-3.12.1", - "default": true - }, - { - "name": "debug", - "path": "/nix/store/6i8r0lq7m7rf7lcqjrwizkcaznmhd2cm-python3-3.12.1-debug" - } - ], - "store_path": "/nix/store/qv710q1p74qb7bswpwh59px28gfj51b1-python3-3.12.1" - }, - "x86_64-darwin": { - "outputs": [ - { - "name": "out", - "path": "/nix/store/051hdrw5qmgbplch184mplcnv4djfb8a-python3-3.12.1", - "default": true - } - ], - "store_path": "/nix/store/051hdrw5qmgbplch184mplcnv4djfb8a-python3-3.12.1" - }, - "x86_64-linux": { - "outputs": [ - { - "name": "out", - "path": "/nix/store/y4dxr00qg40pwgxx9nxj61091zk8bsvl-python3-3.12.1", - "default": true - }, - { - "name": "debug", - "path": "/nix/store/n8jysaqvk89q6fbif4mlacni6wwq0sgc-python3-3.12.1-debug" - } - ], - "store_path": "/nix/store/y4dxr00qg40pwgxx9nxj61091zk8bsvl-python3-3.12.1" + "store_path": "/nix/store/0in2k6jizc97cw3w4yivn2v3nipplfrb-python3.13-poetry-2.1.4" } } } diff --git a/examples/development/python/poetry/poetry-demo/poetry.lock b/examples/development/python/poetry/poetry-demo/poetry.lock index 1767ddbd41f..2cd392f98c2 100644 --- a/examples/development/python/poetry/poetry-demo/poetry.lock +++ b/examples/development/python/poetry/poetry-demo/poetry.lock @@ -1,4 +1,4 @@ -# This file is automatically @generated by Poetry 1.7.1 and should not be changed by hand. +# This file is automatically @generated by Poetry 2.1.4 and should not be changed by hand. [[package]] name = "colorama" @@ -6,6 +6,8 @@ version = "0.4.6" description = "Cross-platform colored terminal text." optional = false python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,!=3.6.*,>=2.7" +groups = ["dev"] +markers = "sys_platform == \"win32\"" files = [ {file = "colorama-0.4.6-py2.py3-none-any.whl", hash = "sha256:4f1d9991f5acc0ca119f9d443620b77f9d6b33703e51011c16baf57afb285fc6"}, {file = "colorama-0.4.6.tar.gz", hash = "sha256:08695f5cb7ed6e0531a20572697297273c47b8cae5a63ffc6d6ed5c201be6e44"}, @@ -17,6 +19,7 @@ version = "2.14.1" description = "Emoji for Python" optional = false python-versions = ">=3.7" +groups = ["main"] files = [ {file = "emoji-2.14.1-py3-none-any.whl", hash = "sha256:35a8a486c1460addb1499e3bf7929d3889b2e2841a57401903699fef595e942b"}, {file = "emoji-2.14.1.tar.gz", hash = "sha256:f8c50043d79a2c1410ebfae833ae1868d5941a67a6cd4d18377e2eb0bd79346b"}, @@ -34,6 +37,8 @@ version = "1.3.0" description = "Backport of PEP 654 (exception groups)" optional = false python-versions = ">=3.7" +groups = ["dev"] +markers = "python_version < \"3.11\"" files = [ {file = "exceptiongroup-1.3.0-py3-none-any.whl", hash = "sha256:4d111e6e0c13d0644cad6ddaa7ed0261a0b36971f6d23e7ec9b4b9097da78a10"}, {file = "exceptiongroup-1.3.0.tar.gz", hash = "sha256:b241f5885f560bc56a59ee63ca4c6a8bfa46ae4ad651af316d4e81817bb9fd88"}, @@ -51,6 +56,7 @@ version = "2.1.0" description = "brain-dead simple config-ini parsing" optional = false python-versions = ">=3.8" +groups = ["dev"] files = [ {file = "iniconfig-2.1.0-py3-none-any.whl", hash = "sha256:9deba5723312380e77435581c6bf4935c94cbfab9b1ed33ef8d238ea168eb760"}, {file = "iniconfig-2.1.0.tar.gz", hash = "sha256:3abbd2e30b36733fee78f9c7f7308f2d0050e88f0087fd25c2645f63c773e1c7"}, @@ -62,6 +68,7 @@ version = "25.0" description = "Core utilities for Python packages" optional = false python-versions = ">=3.8" +groups = ["dev"] files = [ {file = "packaging-25.0-py3-none-any.whl", hash = "sha256:29572ef2b1f17581046b3a2227d5c611fb25ec70ca1ba8554b24b0e69331a484"}, {file = "packaging-25.0.tar.gz", hash = "sha256:d443872c98d677bf60f6a1f2f8c1cb748e8fe762d2bf9d3148b5599295b0fc4f"}, @@ -73,6 +80,7 @@ version = "1.5.0" description = "plugin and hook calling mechanisms for python" optional = false python-versions = ">=3.8" +groups = ["dev"] files = [ {file = "pluggy-1.5.0-py3-none-any.whl", hash = "sha256:44e1ad92c8ca002de6377e165f3e0f1be63266ab4d554740532335b9d75ea669"}, {file = "pluggy-1.5.0.tar.gz", hash = "sha256:2cffa88e94fdc978c4c574f15f9e59b7f4201d439195c3715ca9e2486f1d0cf1"}, @@ -88,6 +96,7 @@ version = "7.4.4" description = "pytest: simple powerful testing with Python" optional = false python-versions = ">=3.7" +groups = ["dev"] files = [ {file = "pytest-7.4.4-py3-none-any.whl", hash = "sha256:b090cdf5ed60bf4c45261be03239c2c1c22df034fbffe691abe93cd80cea01d8"}, {file = "pytest-7.4.4.tar.gz", hash = "sha256:2cf0005922c6ace4a3e2ec8b4080eb0d9753fdc93107415332f50ce9e7994280"}, @@ -110,6 +119,8 @@ version = "2.2.1" description = "A lil' TOML parser" optional = false python-versions = ">=3.8" +groups = ["dev"] +markers = "python_version < \"3.11\"" files = [ {file = "tomli-2.2.1-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:678e4fa69e4575eb77d103de3df8a895e1591b48e740211bd1067378c69e8249"}, {file = "tomli-2.2.1-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:023aa114dd824ade0100497eb2318602af309e5a55595f76b626d6d9f3b7b0a6"}, @@ -151,12 +162,14 @@ version = "4.13.2" description = "Backported and Experimental Type Hints for Python 3.8+" optional = false python-versions = ">=3.8" +groups = ["main", "dev"] files = [ {file = "typing_extensions-4.13.2-py3-none-any.whl", hash = "sha256:a439e7c04b49fec3e5d3e2beaa21755cadbbdc391694e28ccdd36ca4a1408f8c"}, {file = "typing_extensions-4.13.2.tar.gz", hash = "sha256:e6c81219bd689f51865d9e372991c540bda33a0379d5573cddb9a3a23f7caaef"}, ] +markers = {main = "python_version == \"3.8\"", dev = "python_version < \"3.11\""} [metadata] -lock-version = "2.0" +lock-version = "2.1" python-versions = "^3.8" -content-hash = "4bd7c2b783a03ead5ba2b81e78a1d22dc6278fd61be0fbf1fdb8467439bd6fd8" +content-hash = "32a1b5a6c87bca8193ab125c88e4f0b6382c3704777ba5ffb79a74716c7d88fc" diff --git a/examples/development/python/poetry/poetry-demo/poetry_demo/__main__.py b/examples/development/python/poetry/poetry-demo/poetry_demo/__main__.py index 28dfa96abbc..333dd4b5036 100644 --- a/examples/development/python/poetry/poetry-demo/poetry_demo/__main__.py +++ b/examples/development/python/poetry/poetry-demo/poetry_demo/__main__.py @@ -1,4 +1,14 @@ from emoji import emojize + +def main(): + """Prints a greeting message. + + This is a separate function so that it can be used as a script in the pyproject.toml + """ + print(emojize(":rocket: Devbox with Poetry :rocket:")) + + if __name__ == "__main__": - print(emojize(":rocket: Devbox with Poetry :rocket:")) \ No newline at end of file + main() + diff --git a/examples/development/python/poetry/poetry-demo/pyproject.toml b/examples/development/python/poetry/poetry-demo/pyproject.toml index b579a942b2e..27bcf569c58 100644 --- a/examples/development/python/poetry/poetry-demo/pyproject.toml +++ b/examples/development/python/poetry/poetry-demo/pyproject.toml @@ -8,9 +8,12 @@ authors = ["John Lago <750845+Lagoja@users.noreply.github.com>"] python = "^3.8" emoji = "^2.1.0" -[tool.poetry.dev-dependencies] +[tool.poetry.group.dev.dependencies] pytest = "^7.2.2" [build-system] requires = ["poetry-core>=1.0.0"] build-backend = "poetry.core.masonry.api" + +[tool.poetry.scripts] +demo = "poetry_demo.__main__:main" diff --git a/plugins/poetry.json b/plugins/poetry.json index 2deee744d50..f11ec9860e0 100644 --- a/plugins/poetry.json +++ b/plugins/poetry.json @@ -1,7 +1,7 @@ { "name": "poetry", "version": "0.0.4", - "description": "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).", + "description": "This plugin lets poetry configure the version of python installed. 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", diff --git a/plugins/poetry/initHook.sh b/plugins/poetry/initHook.sh index e4a5a0ea472..47a84bb2fe1 100644 --- a/plugins/poetry/initHook.sh +++ b/plugins/poetry/initHook.sh @@ -1,3 +1,3 @@ #!/bin/sh -poetry env use $(command -v python) --directory="${DEVBOX_PYPROJECT_DIR:-$DEVBOX_DEFAULT_PYPROJECT_DIR}" --no-interaction --quiet >&2 +poetry env --directory="${DEVBOX_PYPROJECT_DIR:-$DEVBOX_DEFAULT_PYPROJECT_DIR}" --no-interaction --quiet >&2