Skip to content

Commit

Permalink
maint: migrate from hatch to rye
Browse files Browse the repository at this point in the history
  • Loading branch information
juba committed May 24, 2024
1 parent 1803f77 commit 9596507
Show file tree
Hide file tree
Showing 11 changed files with 454 additions and 66 deletions.
7 changes: 4 additions & 3 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ jobs:
python-version: "3.11"
cache: "pip"

- name: Install hatch
run: pipx install hatch
- name: Install rye
run: curl -sSf https://rye.astral.sh/get | bash

- name: Bundle
run: npm run bundle
Expand All @@ -46,4 +46,5 @@ jobs:
run: |
git config --global user.email "[email protected]"
git config --global user.name "Julien Barnier"
hatch -e docs run quarto publish gh-pages doc
source .venv/bin/activate
quarto publish gh-pages doc
6 changes: 3 additions & 3 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ jobs:
npm ci
npm ci --workspaces
- name: Install hatch
run: pipx install hatch
- name: Install rye
run: curl -sSf https://rye.astral.sh/get | bash

- name: Install Python
uses: actions/setup-python@v5
Expand All @@ -37,7 +37,7 @@ jobs:
cache: "pip"

- name: Run pytest
run: hatch run test
run: rye run test

JS-tests:
runs-on: ubuntu-latest
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ dist/
*_files/
*_cache/
.ipynb_checkpoints/
.python-version
examples/test*
**/test-results/
**/playwright-report/
**/playwright/.cache/
*-snapshots/
/.luarc.json
/.venv/
1 change: 1 addition & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.11.9
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
This is done by converting figures using [typst](https://typst.app). Many thanks to
@wirhabenzeit and @harrylojames for the idea, the underlying code and the feedback.
- Update Observable Plot to 0.6.14
- Migrate build system from hatch to rye

## pyobsplot 0.4.2

Expand Down
2 changes: 1 addition & 1 deletion doc/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ _site/
_freeze/
site_libs/
*_files/
*.html
*.html
6 changes: 3 additions & 3 deletions doc/development.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ npm install 'https://gitpkg.now.sh/juba/pyobsplot/packages/pyobsplot-js?main'
If you want to build `pyobsplot` from source, you'll have to follow these steps:

- Install [node.js](https://nodejs.org/en)
- Install [hatch](https://hatch.pypa.io/latest/) dependency management system
- Install [rye](https://rye.astral.sh/guide/installation/) dependency management system
- Clone the [pyobsplot](https://github.com/juba/pyobsplot) repository
- Install Python dependencies with : `hatch shell`
- Install Python dependencies with : `rye sync`
- Install `pyobsplot-js` JavaScript dependencies with : `npm install --workspaces`
- Install `pyobsplot` dependencies with : `npm install`

Expand Down Expand Up @@ -102,7 +102,7 @@ If using the `widget` renderer, debug output will be displayed in JavaScript con
- If necessary release the npm package with `npm publish` in `packages/pyobsplot-js`
- Check that the `min_npm_version` value in `.utils` is correct
- Change version in `NEWS.md` and `src/pyobsplot/__about__.py`
- Release the Python package with `hatch build` and `hatch publish` in `pyobsplot`
- Release the Python package with `rye build` and `rye publish` in `pyobsplot`
- Tag the version in git
- Create a release on Github
- Bump to dev version in `pyproject.toml` and `NEWS.md`
Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
"scripts": {
"bundle": "esbuild --format=esm --bundle --outdir=src/pyobsplot/static --entry-names=static-[name] src/js/widget.js src/js/styles.css",
"dev": "npm run bundle -- --watch",
"build": "npm run bundle && hatch build",
"test": "hatch run test",
"uistart": "hatch run jupyter lab --config tests/ui/jupyter_server_config.py",
"uitest": "hatch run playwright test --workers=1 --config tests/ui/playwright.config.cjs",
"build": "npm run bundle && rye build",
"test": "rye run test",
"uistart": "rye run jupyter lab --config tests/ui/jupyter_server_config.py",
"uitest": "rye run playwright test --workers=1 --config tests/ui/playwright.config.cjs",
"uitest:debug": "PWDEBUG=1 npm run uitest",
"uitest:report": "http-server ./tests/ui/playwright-report -a localhost -o",
"uitest:update": "npm run uitest -- --update-snapshots",
Expand Down
70 changes: 19 additions & 51 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

[project]
name = "pyobsplot"
dynamic = ["version"]
version = "0.4.3"
description = "Observable Plot in Jupyter notebooks and Quarto documents"
authors = [{ name = "Julien Barnier", email = "[email protected]" }]
license = {file = "LICENSE"}
Expand All @@ -19,12 +15,12 @@ classifiers = [
"Topic :: Scientific/Engineering :: Visualization",
]
dependencies = [
"anywidget[dev]==0.9.0",
"pandas>=1.2.0",
"polars>=0.20.0",
"pyarrow==15.0.0",
"anywidget[dev]>=0.9.11",
"pandas>=2.2.2",
"polars>=0.20.29",
"pyarrow>=16.1.0",
"requests",
"typst>=0.11.0",
"typst>=0.11.1",
]

[project.urls]
Expand All @@ -33,45 +29,30 @@ documentation = "https://juba.github.io/pyobsplot"
repository = "https://github.com/juba/pyobsplot"
changelog = "https://github.com/juba/pyobsplot/blob/main/NEWS.md"

[tool.hatch.version]
path = "src/pyobsplot/__about__.py"

[tool.hatch.envs.default]
dependencies = ["coverage[toml]>=6.5", "pytest", "geopandas>=0.12.2"]

[tool.hatch.envs.default.scripts]
test = "pytest {args:tests}"
test-cov = "coverage run -m pytest {args:tests}"
cov-report = ["- coverage combine", "coverage report"]
cov = ["test-cov", "cov-report"]
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

[tool.hatch.envs.docs]
dependencies = [
"jupyterlab",
"geopandas>=0.12.2"
[tool.rye]
managed = true
dev-dependencies = [
"pytest>=8.2.1",
"geopandas>=0.14.4",
"jupyterlab>=4.2.1",
"ipykernel>=6.29.4",
"playwright>=1.44.0",
]


[[tool.hatch.envs.tests.matrix]]
python = ["3.10", "3.11"]

[tool.hatch.envs.lint]
detached = true
dependencies = ["black>=23.9.1", "mypy>=1.0.0", "ruff>=0.0.291"]

[tool.hatch.envs.lint.scripts]
typing = "mypy --install-types --non-interactive {args:src/pyobsplot tests}"
style = ["ruff {args:.}", "black --check --diff {args:.}"]
fmt = ["black {args:.}", "ruff --fix {args:.}", "style"]
all = ["style", "typing"]
[tool.rye.scripts]
test = "pytest"

[tool.hatch.metadata]
allow-direct-references = true

[tool.hatch.build.targets.sdist]
exclude = [".github", "doc", ".vscode", "examples"]


[tool.hatch.build.targets.wheel]
packages = ["src/pyobsplot"]

Expand Down Expand Up @@ -150,16 +131,3 @@ ban-relative-imports = "all"
# Tests can use magic values, assertions, and relative imports
"tests/**/*" = ["PLR2004", "S101", "TID252"]


[tool.coverage.run]
source_pkgs = ["pyobsplot", "tests"]
branch = true
parallel = true
omit = ["src/pyobsplot/__about__.py"]

[tool.coverage.paths]
pyobsplot = ["src/pyobsplot"]
tests = ["tests"]

[tool.coverage.report]
exclude_lines = ["no cov", "if __name__ == .__main__.:", "if TYPE_CHECKING:"]
Loading

0 comments on commit 9596507

Please sign in to comment.