diff --git a/.changeset/brown-cougars-cover.md b/.changeset/brown-cougars-cover.md new file mode 100644 index 00000000..abf670f4 --- /dev/null +++ b/.changeset/brown-cougars-cover.md @@ -0,0 +1,5 @@ +--- +"create-anywidget": patch +--- + +Support `uv` and update project instructions diff --git a/packages/create-anywidget/__tests__/__snapshots__/index.test.js.snap b/packages/create-anywidget/__tests__/__snapshots__/index.test.js.snap index 70eb09e2..308017a8 100644 --- a/packages/create-anywidget/__tests__/__snapshots__/index.test.js.snap +++ b/packages/create-anywidget/__tests__/__snapshots__/index.test.js.snap @@ -11,21 +11,41 @@ exports[`create-anywidget (Bun) > template-react 1`] = ` pip install ipyfoo \`\`\` -## Development installation +or with [uv](https://github.com/astral-sh/uv): -Create a virtual environment and and install ipyfoo in *editable* mode with the -optional development dependencies: +\`\`\`sh +uv add ipyfoo +\`\`\` + +## Development + +We recommend using [uv](https://github.com/astral-sh/uv) for development. +It will automatically manage virtual environments and dependencies for you. + +\`\`\`sh +uv run jupyter lab example.ipynb +\`\`\` + +Alternatively, create and manage your own virtual environment: \`\`\`sh python -m venv .venv source .venv/bin/activate pip install -e ".[dev]" +jupyter lab example.ipynb \`\`\` -You then need to install the JavaScript dependencies and run the development server. +The widget front-end code bundles it's JavaScript dependencies. After setting up Python, +make sure to install these dependencies locally: \`\`\`sh npm install +\`\`\` + +While developing, you can run the following in a separate terminal to automatically +rebuild JavaScript as you make changes: + +\`\`\`sh npm run dev \`\`\` @@ -110,12 +130,16 @@ version = "0.0.0" dependencies = ["anywidget"] readme = "README.md" +# For projects not using \`uv\`, you can install these development dependencies with: +# \`pip install -e ".[dev]"\` +# If you're using \`uv\` for development, feel free to remove this section. [project.optional-dependencies] dev = ["watchfiles", "jupyterlab"] -# automatically add the dev feature to the default env (e.g., hatch shell) -[tool.hatch.envs.default] -features = ["dev"] +# Dependency groups (recognized by \`uv\`). For more details, visit: +# https://peps.python.org/pep-0735/ +[dependency-groups] +dev = ["watchfiles", "jupyterlab"] [tool.hatch.build] @@ -215,21 +239,41 @@ exports[`create-anywidget (Bun) > template-react-ts 1`] = ` pip install ipyfoo \`\`\` -## Development installation +or with [uv](https://github.com/astral-sh/uv): + +\`\`\`sh +uv add ipyfoo +\`\`\` -Create a virtual environment and and install ipyfoo in *editable* mode with the -optional development dependencies: +## Development + +We recommend using [uv](https://github.com/astral-sh/uv) for development. +It will automatically manage virtual environments and dependencies for you. + +\`\`\`sh +uv run jupyter lab example.ipynb +\`\`\` + +Alternatively, create and manage your own virtual environment: \`\`\`sh python -m venv .venv source .venv/bin/activate pip install -e ".[dev]" +jupyter lab example.ipynb \`\`\` -You then need to install the JavaScript dependencies and run the development server. +The widget front-end code bundles it's JavaScript dependencies. After setting up Python, +make sure to install these dependencies locally: \`\`\`sh npm install +\`\`\` + +While developing, you can run the following in a separate terminal to automatically +rebuild JavaScript as you make changes: + +\`\`\`sh npm run dev \`\`\` @@ -319,12 +363,16 @@ version = "0.0.0" dependencies = ["anywidget"] readme = "README.md" +# For projects not using \`uv\`, you can install these development dependencies with: +# \`pip install -e ".[dev]"\` +# If you're using \`uv\` for development, feel free to remove this section. [project.optional-dependencies] dev = ["watchfiles", "jupyterlab"] -# automatically add the dev feature to the default env (e.g., hatch shell) -[tool.hatch.envs.default] -features = ["dev"] +# Dependency groups (recognized by \`uv\`). For more details, visit: +# https://peps.python.org/pep-0735/ +[dependency-groups] +dev = ["watchfiles", "jupyterlab"] [tool.hatch.build] @@ -452,21 +500,41 @@ exports[`create-anywidget (Bun) > template-vanilla 1`] = ` pip install ipyfoo \`\`\` -## Development installation +or with [uv](https://github.com/astral-sh/uv): -Create a virtual environment and and install ipyfoo in *editable* mode with the -optional development dependencies: +\`\`\`sh +uv add ipyfoo +\`\`\` + +## Development + +We recommend using [uv](https://github.com/astral-sh/uv) for development. +It will automatically manage virtual environments and dependencies for you. + +\`\`\`sh +uv run jupyter lab example.ipynb +\`\`\` + +Alternatively, create and manage your own virtual environment: \`\`\`sh python -m venv .venv source .venv/bin/activate pip install -e ".[dev]" +jupyter lab example.ipynb \`\`\` -You then need to install the JavaScript dependencies and run the development server. +The widget front-end code bundles it's JavaScript dependencies. After setting up Python, +make sure to install these dependencies locally: \`\`\`sh npm install +\`\`\` + +While developing, you can run the following in a separate terminal to automatically +rebuild JavaScript as you make changes: + +\`\`\`sh npm run dev \`\`\` @@ -547,12 +615,16 @@ version = "0.0.0" dependencies = ["anywidget"] readme = "README.md" +# For projects not using \`uv\`, you can install these development dependencies with: +# \`pip install -e ".[dev]"\` +# If you're using \`uv\` for development, feel free to remove this section. [project.optional-dependencies] dev = ["watchfiles", "jupyterlab"] -# automatically add the dev feature to the default env (e.g., hatch shell) -[tool.hatch.envs.default] -features = ["dev"] +# Dependency groups (recognized by \`uv\`). For more details, visit: +# https://peps.python.org/pep-0735/ +[dependency-groups] +dev = ["watchfiles", "jupyterlab"] [tool.hatch.build] @@ -653,15 +725,28 @@ exports[`create-anywidget (Bun) > template-vanilla-deno-jsdoc 1`] = ` pip install ipyfoo \`\`\` -## Development installation +or with [uv](https://github.com/astral-sh/uv): + +\`\`\`sh +uv add ipyfoo +\`\`\` + +## Development + +We recommend using [uv](https://github.com/astral-sh/uv) for development. +It will automatically manage virtual environments and dependencies for you. + +\`\`\`sh +uv run jupyter lab example.ipynb +\`\`\` -Create a virtual environment and and install ipyfoo in *editable* mode with the -optional development dependencies: +Alternatively, create and manage your own virtual environment: \`\`\`sh python -m venv .venv source .venv/bin/activate pip install -e ".[dev]" +jupyter lab example.ipynb \`\`\` Open \`example.ipynb\` in JupyterLab, VS Code, or your favorite editor @@ -716,12 +801,16 @@ version = "0.0.0" dependencies = ["anywidget"] readme = "README.md" +# For projects not using \`uv\`, you can install these development dependencies with: +# \`pip install -e ".[dev]"\` +# If you're using \`uv\` for development, feel free to remove this section. [project.optional-dependencies] dev = ["watchfiles", "jupyterlab"] -# automatically add the dev feature to the default env (e.g., hatch shell) -[tool.hatch.envs.default] -features = ["dev"] +# Dependency groups (recognized by \`uv\`). For more details, visit: +# https://peps.python.org/pep-0735/ +[dependency-groups] +dev = ["watchfiles", "jupyterlab"] ", "path": "pyproject.toml", }, @@ -850,21 +939,41 @@ exports[`create-anywidget (Bun) > template-vanilla-ts 1`] = ` pip install ipyfoo \`\`\` -## Development installation +or with [uv](https://github.com/astral-sh/uv): + +\`\`\`sh +uv add ipyfoo +\`\`\` + +## Development -Create a virtual environment and and install ipyfoo in *editable* mode with the -optional development dependencies: +We recommend using [uv](https://github.com/astral-sh/uv) for development. +It will automatically manage virtual environments and dependencies for you. + +\`\`\`sh +uv run jupyter lab example.ipynb +\`\`\` + +Alternatively, create and manage your own virtual environment: \`\`\`sh python -m venv .venv source .venv/bin/activate pip install -e ".[dev]" +jupyter lab example.ipynb \`\`\` -You then need to install the JavaScript dependencies and run the development server. +The widget front-end code bundles it's JavaScript dependencies. After setting up Python, +make sure to install these dependencies locally: \`\`\`sh npm install +\`\`\` + +While developing, you can run the following in a separate terminal to automatically +rebuild JavaScript as you make changes: + +\`\`\`sh npm run dev \`\`\` @@ -949,12 +1058,16 @@ version = "0.0.0" dependencies = ["anywidget"] readme = "README.md" +# For projects not using \`uv\`, you can install these development dependencies with: +# \`pip install -e ".[dev]"\` +# If you're using \`uv\` for development, feel free to remove this section. [project.optional-dependencies] dev = ["watchfiles", "jupyterlab"] -# automatically add the dev feature to the default env (e.g., hatch shell) -[tool.hatch.envs.default] -features = ["dev"] +# Dependency groups (recognized by \`uv\`). For more details, visit: +# https://peps.python.org/pep-0735/ +[dependency-groups] +dev = ["watchfiles", "jupyterlab"] [tool.hatch.build] @@ -1090,21 +1203,41 @@ exports[`create-anywidget > template-react 1`] = ` pip install ipyfoo \`\`\` -## Development installation +or with [uv](https://github.com/astral-sh/uv): -Create a virtual environment and and install ipyfoo in *editable* mode with the -optional development dependencies: +\`\`\`sh +uv add ipyfoo +\`\`\` + +## Development + +We recommend using [uv](https://github.com/astral-sh/uv) for development. +It will automatically manage virtual environments and dependencies for you. + +\`\`\`sh +uv run jupyter lab example.ipynb +\`\`\` + +Alternatively, create and manage your own virtual environment: \`\`\`sh python -m venv .venv source .venv/bin/activate pip install -e ".[dev]" +jupyter lab example.ipynb \`\`\` -You then need to install the JavaScript dependencies and run the development server. +The widget front-end code bundles it's JavaScript dependencies. After setting up Python, +make sure to install these dependencies locally: \`\`\`sh npm install +\`\`\` + +While developing, you can run the following in a separate terminal to automatically +rebuild JavaScript as you make changes: + +\`\`\`sh npm run dev \`\`\` @@ -1191,12 +1324,16 @@ version = "0.0.0" dependencies = ["anywidget"] readme = "README.md" +# For projects not using \`uv\`, you can install these development dependencies with: +# \`pip install -e ".[dev]"\` +# If you're using \`uv\` for development, feel free to remove this section. [project.optional-dependencies] dev = ["watchfiles", "jupyterlab"] -# automatically add the dev feature to the default env (e.g., hatch shell) -[tool.hatch.envs.default] -features = ["dev"] +# Dependency groups (recognized by \`uv\`). For more details, visit: +# https://peps.python.org/pep-0735/ +[dependency-groups] +dev = ["watchfiles", "jupyterlab"] [tool.hatch.build] @@ -1296,21 +1433,41 @@ exports[`create-anywidget > template-react-ts 1`] = ` pip install ipyfoo \`\`\` -## Development installation +or with [uv](https://github.com/astral-sh/uv): + +\`\`\`sh +uv add ipyfoo +\`\`\` -Create a virtual environment and and install ipyfoo in *editable* mode with the -optional development dependencies: +## Development + +We recommend using [uv](https://github.com/astral-sh/uv) for development. +It will automatically manage virtual environments and dependencies for you. + +\`\`\`sh +uv run jupyter lab example.ipynb +\`\`\` + +Alternatively, create and manage your own virtual environment: \`\`\`sh python -m venv .venv source .venv/bin/activate pip install -e ".[dev]" +jupyter lab example.ipynb \`\`\` -You then need to install the JavaScript dependencies and run the development server. +The widget front-end code bundles it's JavaScript dependencies. After setting up Python, +make sure to install these dependencies locally: \`\`\`sh npm install +\`\`\` + +While developing, you can run the following in a separate terminal to automatically +rebuild JavaScript as you make changes: + +\`\`\`sh npm run dev \`\`\` @@ -1401,12 +1558,16 @@ version = "0.0.0" dependencies = ["anywidget"] readme = "README.md" +# For projects not using \`uv\`, you can install these development dependencies with: +# \`pip install -e ".[dev]"\` +# If you're using \`uv\` for development, feel free to remove this section. [project.optional-dependencies] dev = ["watchfiles", "jupyterlab"] -# automatically add the dev feature to the default env (e.g., hatch shell) -[tool.hatch.envs.default] -features = ["dev"] +# Dependency groups (recognized by \`uv\`). For more details, visit: +# https://peps.python.org/pep-0735/ +[dependency-groups] +dev = ["watchfiles", "jupyterlab"] [tool.hatch.build] @@ -1534,21 +1695,41 @@ exports[`create-anywidget > template-vanilla 1`] = ` pip install ipyfoo \`\`\` -## Development installation +or with [uv](https://github.com/astral-sh/uv): -Create a virtual environment and and install ipyfoo in *editable* mode with the -optional development dependencies: +\`\`\`sh +uv add ipyfoo +\`\`\` + +## Development + +We recommend using [uv](https://github.com/astral-sh/uv) for development. +It will automatically manage virtual environments and dependencies for you. + +\`\`\`sh +uv run jupyter lab example.ipynb +\`\`\` + +Alternatively, create and manage your own virtual environment: \`\`\`sh python -m venv .venv source .venv/bin/activate pip install -e ".[dev]" +jupyter lab example.ipynb \`\`\` -You then need to install the JavaScript dependencies and run the development server. +The widget front-end code bundles it's JavaScript dependencies. After setting up Python, +make sure to install these dependencies locally: \`\`\`sh npm install +\`\`\` + +While developing, you can run the following in a separate terminal to automatically +rebuild JavaScript as you make changes: + +\`\`\`sh npm run dev \`\`\` @@ -1631,12 +1812,16 @@ version = "0.0.0" dependencies = ["anywidget"] readme = "README.md" +# For projects not using \`uv\`, you can install these development dependencies with: +# \`pip install -e ".[dev]"\` +# If you're using \`uv\` for development, feel free to remove this section. [project.optional-dependencies] dev = ["watchfiles", "jupyterlab"] -# automatically add the dev feature to the default env (e.g., hatch shell) -[tool.hatch.envs.default] -features = ["dev"] +# Dependency groups (recognized by \`uv\`). For more details, visit: +# https://peps.python.org/pep-0735/ +[dependency-groups] +dev = ["watchfiles", "jupyterlab"] [tool.hatch.build] @@ -1737,15 +1922,28 @@ exports[`create-anywidget > template-vanilla-deno-jsdoc 1`] = ` pip install ipyfoo \`\`\` -## Development installation +or with [uv](https://github.com/astral-sh/uv): + +\`\`\`sh +uv add ipyfoo +\`\`\` + +## Development + +We recommend using [uv](https://github.com/astral-sh/uv) for development. +It will automatically manage virtual environments and dependencies for you. + +\`\`\`sh +uv run jupyter lab example.ipynb +\`\`\` -Create a virtual environment and and install ipyfoo in *editable* mode with the -optional development dependencies: +Alternatively, create and manage your own virtual environment: \`\`\`sh python -m venv .venv source .venv/bin/activate pip install -e ".[dev]" +jupyter lab example.ipynb \`\`\` Open \`example.ipynb\` in JupyterLab, VS Code, or your favorite editor @@ -1800,12 +1998,16 @@ version = "0.0.0" dependencies = ["anywidget"] readme = "README.md" +# For projects not using \`uv\`, you can install these development dependencies with: +# \`pip install -e ".[dev]"\` +# If you're using \`uv\` for development, feel free to remove this section. [project.optional-dependencies] dev = ["watchfiles", "jupyterlab"] -# automatically add the dev feature to the default env (e.g., hatch shell) -[tool.hatch.envs.default] -features = ["dev"] +# Dependency groups (recognized by \`uv\`). For more details, visit: +# https://peps.python.org/pep-0735/ +[dependency-groups] +dev = ["watchfiles", "jupyterlab"] ", "path": "pyproject.toml", }, @@ -1934,21 +2136,41 @@ exports[`create-anywidget > template-vanilla-ts 1`] = ` pip install ipyfoo \`\`\` -## Development installation +or with [uv](https://github.com/astral-sh/uv): + +\`\`\`sh +uv add ipyfoo +\`\`\` + +## Development -Create a virtual environment and and install ipyfoo in *editable* mode with the -optional development dependencies: +We recommend using [uv](https://github.com/astral-sh/uv) for development. +It will automatically manage virtual environments and dependencies for you. + +\`\`\`sh +uv run jupyter lab example.ipynb +\`\`\` + +Alternatively, create and manage your own virtual environment: \`\`\`sh python -m venv .venv source .venv/bin/activate pip install -e ".[dev]" +jupyter lab example.ipynb \`\`\` -You then need to install the JavaScript dependencies and run the development server. +The widget front-end code bundles it's JavaScript dependencies. After setting up Python, +make sure to install these dependencies locally: \`\`\`sh npm install +\`\`\` + +While developing, you can run the following in a separate terminal to automatically +rebuild JavaScript as you make changes: + +\`\`\`sh npm run dev \`\`\` @@ -2034,12 +2256,16 @@ version = "0.0.0" dependencies = ["anywidget"] readme = "README.md" +# For projects not using \`uv\`, you can install these development dependencies with: +# \`pip install -e ".[dev]"\` +# If you're using \`uv\` for development, feel free to remove this section. [project.optional-dependencies] dev = ["watchfiles", "jupyterlab"] -# automatically add the dev feature to the default env (e.g., hatch shell) -[tool.hatch.envs.default] -features = ["dev"] +# Dependency groups (recognized by \`uv\`). For more details, visit: +# https://peps.python.org/pep-0735/ +[dependency-groups] +dev = ["watchfiles", "jupyterlab"] [tool.hatch.build] diff --git a/packages/create-anywidget/create.js b/packages/create-anywidget/create.js index ec2f529b..9fcf9f5e 100644 --- a/packages/create-anywidget/create.js +++ b/packages/create-anywidget/create.js @@ -81,12 +81,16 @@ version = "0.0.0" dependencies = ["anywidget"] readme = "README.md" +# For projects not using \`uv\`, you can install these development dependencies with: +# \`pip install -e ".[dev]"\` +# If you're using \`uv\` for development, feel free to remove this section. [project.optional-dependencies] dev = ["watchfiles", "jupyterlab"] -# automatically add the dev feature to the default env (e.g., hatch shell) -[tool.hatch.envs.default] -features = ["dev"] +# Dependency groups (recognized by \`uv\`). For more details, visit: +# https://peps.python.org/pep-0735/ +[dependency-groups] +dev = ["watchfiles", "jupyterlab"] `; /** @@ -160,25 +164,45 @@ let readme = (name, type = "bundled") => { pip install ${name} \`\`\` -## Development installation +or with [uv](https://github.com/astral-sh/uv): + +\`\`\`sh +uv add ${name} +\`\`\` -Create a virtual environment and and install ${name} in *editable* mode with the -optional development dependencies: +## Development + +We recommend using [uv](https://github.com/astral-sh/uv) for development. +It will automatically manage virtual environments and dependencies for you. + +\`\`\`sh +uv run jupyter lab example.ipynb +\`\`\` + +Alternatively, create and manage your own virtual environment: \`\`\`sh python -m venv .venv source .venv/bin/activate pip install -e ".[dev]" +jupyter lab example.ipynb \`\`\` `; if (type === "bundled") { body = body.concat(`\ -You then need to install the JavaScript dependencies and run the development server. +The widget front-end code bundles it's JavaScript dependencies. After setting up Python, +make sure to install these dependencies locally: \`\`\`sh npm install +\`\`\` + +While developing, you can run the following in a separate terminal to automatically +rebuild JavaScript as you make changes: + +\`\`\`sh npm run dev \`\`\`