diff --git a/Makefile b/Makefile index e7fdb38..61bc10c 100644 --- a/Makefile +++ b/Makefile @@ -18,6 +18,12 @@ SED = sed -i '' -e endif +.PHONY: lint fix format test +lint: ## lint this repo +fix: ## fix formatting in this repo +format: fix +test: ## run tests for this repo + .PHONY: gen-python gen-cpp gen-js gen-jupyter gen-rust gen-rustjswasm gen-python: ## regenerate the python template from scratch mkdir -p ../python-template && cd ../python-template && rm -rf ./* && rm -rf .copier-answers.yaml .gitignore .github .gitattributes diff --git a/cpp/.gitignore.jinja b/cpp/.gitignore.jinja index 0cf743a..73811ea 100644 --- a/cpp/.gitignore.jinja +++ b/cpp/.gitignore.jinja @@ -133,9 +133,9 @@ js/*.tgz .ipynb_checkpoints .autoversion Untitled*.ipynb -{{module}}/extension -{{module}}/nbextension -{{module}}/labextension +{{ module }}/extension +{{ module }}/nbextension +{{ module }}/labextension # Mac .DS_Store diff --git a/cpp/LICENSE.jinja b/cpp/LICENSE.jinja index ee2a86d..3d7a96a 100644 --- a/cpp/LICENSE.jinja +++ b/cpp/LICENSE.jinja @@ -186,7 +186,7 @@ same "printed page" as the copyright notice for easier identification within third-party archives. - Copyright 2025 {{team}} + Copyright 2025 {{ team }} Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/cpp/Makefile.jinja b/cpp/Makefile.jinja index b6ff04a..9e7b8c4 100644 --- a/cpp/Makefile.jinja +++ b/cpp/Makefile.jinja @@ -23,8 +23,8 @@ install: ## install python library ######### .PHONY: lint-py lint-cpp lint-docs lint lints lint-py: ## run python linter with ruff - python -m ruff check {{module}} - python -m ruff format --check {{module}} + python -m ruff check {{ module }} + python -m ruff format --check {{ module }} lint-cpp: ## run cpp linter clang-format --dry-run -Werror -i -style=file `find ./cpp -name "*.*pp"` @@ -40,8 +40,8 @@ lints: lint .PHONY: fix-py fix-cpp fix format fix-py: ## fix python formatting with ruff - python -m ruff check --fix {{module}} - python -m ruff format {{module}} + python -m ruff check --fix {{ module }} + python -m ruff format {{ module }} fix-cpp: ## fix cpp formatting clang-format -i -style=file `find ./cpp -name "*.*pp"` @@ -76,13 +76,13 @@ check: checks ######### .PHONY: test-py tests-py coverage-py test-py: ## run python tests - python -m pytest -v {{module}}/tests + python -m pytest -v {{ module }}/tests # alias tests-py: test-py coverage-py: ## run python tests and collect test coverage - python -m pytest -v {{module}}/tests --cov={{module}} --cov-report term-missing --cov-report xml + python -m pytest -v {{ module }}/tests --cov={{ module }} --cov-report term-missing --cov-report xml .PHONY: test coverage tests test: test-py ## run all tests diff --git a/cpp/README.md.jinja b/cpp/README.md.jinja index d8ce83b..7e11b1c 100644 --- a/cpp/README.md.jinja +++ b/cpp/README.md.jinja @@ -1,11 +1,11 @@ -# {{project_name}} +# {{ project_name }} -{{project_description}} +{{ project_description }} -[![Build Status](https://github.com/{{github}}/{{project_name_formatted}}/actions/workflows/build.yaml/badge.svg?branch=main&event=push)](https://github.com/{{github}}/{{project_name_formatted}}/actions/workflows/build.yaml) -[![codecov](https://codecov.io/gh/{{github}}/{{project_name_formatted}}/branch/main/graph/badge.svg)](https://codecov.io/gh/{{github}}/{{project_name_formatted}}) -[![License](https://img.shields.io/github/license/{{github}}/{{project_name_formatted}})](https://github.com/{{github}}/{{project_name_formatted}}) -[![PyPI](https://img.shields.io/pypi/v/{{project_name_formatted}}.svg)](https://pypi.python.org/pypi/{{project_name_formatted}}) +[![Build Status](https://github.com/{{ github }}/{{ project_name_formatted }}/actions/workflows/build.yaml/badge.svg?branch=main&event=push)](https://github.com/{{ github }}/{{ project_name_formatted }}/actions/workflows/build.yaml) +[![codecov](https://codecov.io/gh/{{ github }}/{{ project_name_formatted }}/branch/main/graph/badge.svg)](https://codecov.io/gh/{{ github }}/{{ project_name_formatted }}) +[![License](https://img.shields.io/github/license/{{ github }}/{{ project_name_formatted }})](https://github.com/{{ github }}/{{ project_name_formatted }}) +[![PyPI](https://img.shields.io/pypi/v/{{ project_name_formatted }}.svg)](https://pypi.python.org/pypi/{{ project_name_formatted }}) ## Overview diff --git a/cpp/cpp/{{project_name_formatted}}/extension.cpp.jinja b/cpp/cpp/{{project_name_formatted}}/extension.cpp.jinja index 341dcab..010b478 100644 --- a/cpp/cpp/{{project_name_formatted}}/extension.cpp.jinja +++ b/cpp/cpp/{{project_name_formatted}}/extension.cpp.jinja @@ -1,3 +1,3 @@ -#include "{{project_name_formatted}}/extension.hpp" +#include "{{ project_name_formatted }}/extension.hpp" int add(int i, int j) { return i + j; } diff --git a/cpp/pyproject.toml.jinja b/cpp/pyproject.toml.jinja index f4efaac..74aaa79 100644 --- a/cpp/pyproject.toml.jinja +++ b/cpp/pyproject.toml.jinja @@ -7,11 +7,11 @@ requires = [ build-backend = "hatchling.build" [project] -name = "{{project_name_formatted}}" +name = "{{ project_name_formatted }}" authors = [ - {name = "{{team}}", email = "{{email}}"}, + {name = "{{ team }}", email = "{{ email }}"}, ] -description = "{{project_description}}" +description = "{{ project_description }}" readme = "README.md" license = { text = "Apache-2.0" } version = "0.1.0" @@ -57,8 +57,8 @@ develop = [ [project.scripts] [project.urls] -Repository = "https://github.com/{{github}}/{{project_name_formatted}}" -Homepage = "https://github.com/{{github}}/{{project_name_formatted}}" +Repository = "https://github.com/{{ github }}/{{ project_name_formatted }}" +Homepage = "https://github.com/{{ github }}/{{ project_name_formatted }}" [tool.bumpversion] current_version = "0.1.0" @@ -67,7 +67,7 @@ tag = true commit_args = "-s" [[tool.bumpversion.files]] -filename = "{{module}}/__init__.py" +filename = "{{ module }}/__init__.py" search = '__version__ = "{current_version}"' replace = '__version__ = "{new_version}"' @@ -96,7 +96,7 @@ skip = "*win32 *arm_64" [tool.coverage.run] branch = true omit = [ - "{{module}}/tests/integration/", + "{{ module }}/tests/integration/", ] [tool.coverage.report] @@ -110,9 +110,9 @@ fail_under = 50 [tool.hatch.build] artifacts = [ - "{{module}}/*.dll", - "{{module}}/*.dylib", - "{{module}}/*.so", + "{{ module }}/*.dll", + "{{ module }}/*.dylib", + "{{ module }}/*.so", ] [tool.hatch.build.sources] @@ -121,18 +121,18 @@ src = "/" [tool.hatch.build.hooks.hatch-cpp] verbose = true libraries = [ - {name = "{{module}}/extension", sources = ["cpp/{{project_name_formatted}}/extension.cpp"], include-dirs = ["cpp"], binding="pybind11"} + {name = "{{ module }}/extension", sources = ["cpp/{{ project_name_formatted }}/extension.cpp"], include-dirs = ["cpp"], binding="pybind11"} ] [tool.hatch.build.targets.sdist] packages = [ - "{{module}}", + "{{ module }}", "cpp", ] [tool.hatch.build.targets.wheel] packages = [ - "{{module}}", + "{{ module }}", ] [tool.pytest.ini_options] @@ -140,7 +140,7 @@ addopts = [ "-vvv", "--junitxml=junit.xml", ] -testpaths = "{{module}}/tests" +testpaths = "{{ module }}/tests" [tool.ruff] line-length = 150 @@ -154,7 +154,7 @@ extend-select = [ combine-as-imports = true default-section = "third-party" known-first-party = [ - "{{module}}", + "{{ module }}", ] section-order = [ "future", diff --git a/cpp/{% if add_wiki %}docs{% endif %}/wiki/Installation.md.jinja b/cpp/{% if add_wiki %}docs{% endif %}/wiki/Installation.md.jinja index 8dfc880..89b2612 100644 --- a/cpp/{% if add_wiki %}docs{% endif %}/wiki/Installation.md.jinja +++ b/cpp/{% if add_wiki %}docs{% endif %}/wiki/Installation.md.jinja @@ -1,19 +1,19 @@ ## Pre-requisites -You need Python >=3.10 on your machine to install `{{project_name_formatted}}`. +You need Python >=3.10 on your machine to install `{{ project_name_formatted }}`. ## Install with `pip` ```bash -pip install {{project_name_formatted}} +pip install {{ project_name_formatted }} ``` ## Install with `conda` ```bash -conda install {{project_name_formatted}} --channel conda-forge +conda install {{ project_name_formatted }} --channel conda-forge ``` ## Source installation -For other platforms and for development installations, [build `{{project_name_formatted}}` from source](Build-from-Source). +For other platforms and for development installations, [build `{{ project_name_formatted }}` from source](Build-from-Source). diff --git a/cpp/{% if add_wiki %}docs{% endif %}/wiki/_Footer.md.jinja b/cpp/{% if add_wiki %}docs{% endif %}/wiki/_Footer.md.jinja index 4a5fb4b..bd81a19 100644 --- a/cpp/{% if add_wiki %}docs{% endif %}/wiki/_Footer.md.jinja +++ b/cpp/{% if add_wiki %}docs{% endif %}/wiki/_Footer.md.jinja @@ -1 +1 @@ -_This wiki is autogenerated. To made updates, open a PR against the original source file in [`docs/wiki`](https://github.com/{{github}}/{{project_name_formatted}}/tree/main/docs/wiki)._ +_This wiki is autogenerated. To made updates, open a PR against the original source file in [`docs/wiki`](https://github.com/{{ github }}/{{ project_name_formatted }}/tree/main/docs/wiki)._ diff --git a/cpp/{% if add_wiki %}docs{% endif %}/wiki/contribute/Build-from-Source.md.jinja b/cpp/{% if add_wiki %}docs{% endif %}/wiki/contribute/Build-from-Source.md.jinja index ff2651e..d1afac6 100644 --- a/cpp/{% if add_wiki %}docs{% endif %}/wiki/contribute/Build-from-Source.md.jinja +++ b/cpp/{% if add_wiki %}docs{% endif %}/wiki/contribute/Build-from-Source.md.jinja @@ -1,4 +1,4 @@ -`{{project_name_formatted}}` is written in Python. While prebuilt wheels are provided for end users, it is also straightforward to build `{{project_name_formatted}}` from either the Python [source distribution](https://packaging.python.org/en/latest/specifications/source-distribution-format/) or the GitHub repository. +`{{ project_name_formatted }}` is written in Python. While prebuilt wheels are provided for end users, it is also straightforward to build `{{ project_name_formatted }}` from either the Python [source distribution](https://packaging.python.org/en/latest/specifications/source-distribution-format/) or the GitHub repository. - [Make commands](#make-commands) - [Prerequisites](#prerequisites) @@ -10,7 +10,7 @@ ## Make commands -As a convenience, `{{project_name_formatted}}` uses a `Makefile` for commonly used commands. You can print the main available commands by running `make` with no arguments +As a convenience, `{{ project_name_formatted }}` uses a `Makefile` for commonly used commands. You can print the main available commands by running `make` with no arguments ```bash > make @@ -25,15 +25,15 @@ test run the tests ## Prerequisites -`{{project_name_formatted}}` has a few system-level dependencies which you can install from your machine package manager. Other package managers like `conda`, `nix`, etc, should also work fine. +`{{ project_name_formatted }}` has a few system-level dependencies which you can install from your machine package manager. Other package managers like `conda`, `nix`, etc, should also work fine. ## Clone Clone the repo with: ```bash -git clone https://github.com/{{github}}/{{project_name_formatted}}.git -cd {{project_name_formatted}} +git clone https://github.com/{{ github }}/{{ project_name_formatted }}.git +cd {{ project_name_formatted }} ``` ## Install Python dependencies @@ -56,7 +56,7 @@ make build ## Lint and Autoformat -`{{project_name_formatted}}` has linting and auto formatting. +`{{ project_name_formatted }}` has linting and auto formatting. | Language | Linter | Autoformatter | Description | | :------- | :---------- | :------------ | :---------- | @@ -90,7 +90,7 @@ make fix-docs ## Testing -`{{project_name_formatted}}` has extensive Python tests. The tests can be run via `pytest`. First, install the Python development dependencies with +`{{ project_name_formatted }}` has extensive Python tests. The tests can be run via `pytest`. First, install the Python development dependencies with ```bash make develop diff --git a/cpp/{% if add_wiki %}docs{% endif %}/wiki/contribute/Contribute.md.jinja b/cpp/{% if add_wiki %}docs{% endif %}/wiki/contribute/Contribute.md.jinja index 7deea95..463b117 100644 --- a/cpp/{% if add_wiki %}docs{% endif %}/wiki/contribute/Contribute.md.jinja +++ b/cpp/{% if add_wiki %}docs{% endif %}/wiki/contribute/Contribute.md.jinja @@ -1,14 +1,14 @@ -Contributions are welcome on this project. We distribute under the terms of the [Apache 2.0 license](https://github.com/{{github}}/{{project_name_formatted}}/blob/main/LICENSE). +Contributions are welcome on this project. We distribute under the terms of the [Apache 2.0 license](https://github.com/{{ github }}/{{ project_name_formatted }}/blob/main/LICENSE). > [!NOTE] > -> `{{project_name_formatted}}` requires [Developer Certificate of Origin](https://en.wikipedia.org/wiki/Developer_Certificate_of_Origin) for all contributions. +> `{{ project_name_formatted }}` requires [Developer Certificate of Origin](https://en.wikipedia.org/wiki/Developer_Certificate_of_Origin) for all contributions. > This is enforced by a [Probot GitHub App](https://probot.github.io/apps/dco/), which checks that commits are "signed". > Read [instructions to configure commit signing](Local-Development-Setup#configure-commit-signing). -For **bug reports** or **small feature requests**, please open an issue on our [issues page](https://github.com/{{github}}/{{project_name_formatted}}/issues). +For **bug reports** or **small feature requests**, please open an issue on our [issues page](https://github.com/{{ github }}/{{ project_name_formatted }}/issues). -For **questions** or to discuss **larger changes or features**, please use our [discussions page](https://github.com/{{github}}/{{project_name_formatted}}/discussions). +For **questions** or to discuss **larger changes or features**, please use our [discussions page](https://github.com/{{ github }}/{{ project_name_formatted }}/discussions). For **contributions**, please see our [developer documentation](Local-Development-Setup). We have `help wanted` and `good first issue` tags on our issues page, so these are a great place to start. diff --git a/cpp/{% if add_wiki %}docs{% endif %}/wiki/contribute/Local-Development-Setup.md.jinja b/cpp/{% if add_wiki %}docs{% endif %}/wiki/contribute/Local-Development-Setup.md.jinja index 897872a..abf413b 100644 --- a/cpp/{% if add_wiki %}docs{% endif %}/wiki/contribute/Local-Development-Setup.md.jinja +++ b/cpp/{% if add_wiki %}docs{% endif %}/wiki/contribute/Local-Development-Setup.md.jinja @@ -10,27 +10,27 @@ ## Step 1: Build from Source -To work on `{{project_name_formatted}}`, you are going to need to build it from source. See +To work on `{{ project_name_formatted }}`, you are going to need to build it from source. See [Build from Source](Build-from-Source) for detailed build instructions. -Once you've built `{{project_name_formatted}}` from a `git` clone, you will also need to -configure `git` and your GitHub account for `{{project_name_formatted}}` development. +Once you've built `{{ project_name_formatted }}` from a `git` clone, you will also need to +configure `git` and your GitHub account for `{{ project_name_formatted }}` development. ## Step 2: Configuring Git and GitHub for Development ### Create your fork -The first step is to create a personal fork of `{{project_name_formatted}}`. To do so, click -the "fork" button at https://github.com/{{github}}/{{project_name_formatted}}, or just navigate -[here](https://github.com/{{github}}/{{project_name_formatted}}/fork) in your browser. Set the +The first step is to create a personal fork of `{{ project_name_formatted }}`. To do so, click +the "fork" button at https://github.com/{{ github }}/{{ project_name_formatted }}, or just navigate +[here](https://github.com/{{ github }}/{{ project_name_formatted }}/fork) in your browser. Set the owner of the repository to your personal GitHub account if it is not already set that way and click "Create fork". ### Configure remotes Next, you should set some names for the `git` remotes corresponding to -main {{github}} repository and your fork. See the [GitHub Docs](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/configuring-a-remote-repository-for-a-fork) for more information. +main {{ github }} repository and your fork. See the [GitHub Docs](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/configuring-a-remote-repository-for-a-fork) for more information. ### Authenticating with GitHub diff --git a/cpp/{{module}}/tests/test_all.py.jinja b/cpp/{{module}}/tests/test_all.py.jinja index 4097771..f3a6ba9 100644 --- a/cpp/{{module}}/tests/test_all.py.jinja +++ b/cpp/{{module}}/tests/test_all.py.jinja @@ -1,4 +1,4 @@ -from {{module}} import add +from {{ module }} import add class TestAll: diff --git a/cppjswasm/.github/CODE_OF_CONDUCT.md.jinja b/cppjswasm/.github/CODE_OF_CONDUCT.md.jinja index ebc86d7..9eab626 100644 --- a/cppjswasm/.github/CODE_OF_CONDUCT.md.jinja +++ b/cppjswasm/.github/CODE_OF_CONDUCT.md.jinja @@ -55,7 +55,7 @@ further defined and clarified by project maintainers. ## Enforcement Instances of abusive, harassing, or otherwise unacceptable behavior may be -reported by contacting the project team at {{email}}. All +reported by contacting the project team at {{ email }}. All complaints will be reviewed and investigated and will result in a response that is deemed necessary and appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. diff --git a/cppjswasm/.github/workflows/build.yaml.jinja b/cppjswasm/.github/workflows/build.yaml.jinja index ebb0b29..3519f86 100644 --- a/cppjswasm/.github/workflows/build.yaml.jinja +++ b/cppjswasm/.github/workflows/build.yaml.jinja @@ -30,7 +30,7 @@ jobs: strategy: matrix: os: [ubuntu-latest, macos-latest, windows-latest] - python-version: ["{{python_version_primary}}"] + python-version: ["{{ python_version_primary }}"] cibuildwheel: ["cp{{python_version_primary.replace('.', '')}}"] node-version: [20.x] @@ -45,7 +45,7 @@ jobs: with: version: 22.x - - uses: mymindstorm/setup-emsdk@v14 + - uses: mymindstorm/setup-emsdk@v16 - name: Install dependencies run: make develop diff --git a/cppjswasm/.github/workflows/{% if add_docs %}docs.yaml{% endif %}.jinja b/cppjswasm/.github/workflows/{% if add_docs %}docs.yaml{% endif %}.jinja index f9054a1..3b6770b 100644 --- a/cppjswasm/.github/workflows/{% if add_docs %}docs.yaml{% endif %}.jinja +++ b/cppjswasm/.github/workflows/{% if add_docs %}docs.yaml{% endif %}.jinja @@ -14,7 +14,7 @@ jobs: - uses: actions/checkout@v6 - uses: actions-ext/python/setup@main - uses: actions-ext/node/setup@main - - uses: mymindstorm/setup-emsdk@v14 + - uses: mymindstorm/setup-emsdk@v16 - run: make develop - run: uv pip install . - run: uv pip install yardang diff --git a/cppjswasm/.gitignore.jinja b/cppjswasm/.gitignore.jinja index c82a673..050b49e 100644 --- a/cppjswasm/.gitignore.jinja +++ b/cppjswasm/.gitignore.jinja @@ -133,9 +133,9 @@ js/*.tgz .ipynb_checkpoints .autoversion Untitled*.ipynb -{{module}}/extension -{{module}}/nbextension -{{module}}/labextension +{{ module }}/extension +{{ module }}/nbextension +{{ module }}/labextension # Mac .DS_Store diff --git a/cppjswasm/LICENSE.jinja b/cppjswasm/LICENSE.jinja index ee2a86d..3d7a96a 100644 --- a/cppjswasm/LICENSE.jinja +++ b/cppjswasm/LICENSE.jinja @@ -186,7 +186,7 @@ same "printed page" as the copyright notice for easier identification within third-party archives. - Copyright 2025 {{team}} + Copyright 2025 {{ team }} Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/cppjswasm/Makefile.jinja b/cppjswasm/Makefile.jinja index 32d819c..e6e05d9 100644 --- a/cppjswasm/Makefile.jinja +++ b/cppjswasm/Makefile.jinja @@ -50,8 +50,8 @@ install: ## install python library ######### .PHONY: lint-py lint-js lint-cpp lint-docs lint lints lint-py: ## run python linter with ruff - python -m ruff check {{module}} - python -m ruff format --check {{module}} + python -m ruff check {{ module }} + python -m ruff format --check {{ module }} lint-js: ## run js linter cd js; pnpm lint @@ -70,8 +70,8 @@ lints: lint .PHONY: fix-py fix-js fix-cpp fix-docs fix format fix-py: ## fix python formatting with ruff - python -m ruff check --fix {{module}} - python -m ruff format {{module}} + python -m ruff check --fix {{ module }} + python -m ruff format {{ module }} fix-js: ## fix js formatting cd js; pnpm fix @@ -109,13 +109,13 @@ check: checks ######### .PHONY: test-py tests-py coverage-py test-py: ## run python tests - python -m pytest -v {{module}}/tests + python -m pytest -v {{ module }}/tests # alias tests-py: test-py coverage-py: ## run python tests and collect test coverage - python -m pytest -v {{module}}/tests --cov={{module}} --cov-report term-missing --cov-report xml + python -m pytest -v {{ module }}/tests --cov={{ module }} --cov-report term-missing --cov-report xml .PHONY: test-js tests-js coverage-js test-js: ## run js tests diff --git a/cppjswasm/README.md.jinja b/cppjswasm/README.md.jinja index d8ce83b..7e11b1c 100644 --- a/cppjswasm/README.md.jinja +++ b/cppjswasm/README.md.jinja @@ -1,11 +1,11 @@ -# {{project_name}} +# {{ project_name }} -{{project_description}} +{{ project_description }} -[![Build Status](https://github.com/{{github}}/{{project_name_formatted}}/actions/workflows/build.yaml/badge.svg?branch=main&event=push)](https://github.com/{{github}}/{{project_name_formatted}}/actions/workflows/build.yaml) -[![codecov](https://codecov.io/gh/{{github}}/{{project_name_formatted}}/branch/main/graph/badge.svg)](https://codecov.io/gh/{{github}}/{{project_name_formatted}}) -[![License](https://img.shields.io/github/license/{{github}}/{{project_name_formatted}})](https://github.com/{{github}}/{{project_name_formatted}}) -[![PyPI](https://img.shields.io/pypi/v/{{project_name_formatted}}.svg)](https://pypi.python.org/pypi/{{project_name_formatted}}) +[![Build Status](https://github.com/{{ github }}/{{ project_name_formatted }}/actions/workflows/build.yaml/badge.svg?branch=main&event=push)](https://github.com/{{ github }}/{{ project_name_formatted }}/actions/workflows/build.yaml) +[![codecov](https://codecov.io/gh/{{ github }}/{{ project_name_formatted }}/branch/main/graph/badge.svg)](https://codecov.io/gh/{{ github }}/{{ project_name_formatted }}) +[![License](https://img.shields.io/github/license/{{ github }}/{{ project_name_formatted }})](https://github.com/{{ github }}/{{ project_name_formatted }}) +[![PyPI](https://img.shields.io/pypi/v/{{ project_name_formatted }}.svg)](https://pypi.python.org/pypi/{{ project_name_formatted }}) ## Overview diff --git a/cppjswasm/cpp/{{project_name_formatted}}/example.cpp.jinja b/cppjswasm/cpp/{{project_name_formatted}}/example.cpp.jinja index a79a14c..ea47de4 100644 --- a/cppjswasm/cpp/{{project_name_formatted}}/example.cpp.jinja +++ b/cppjswasm/cpp/{{project_name_formatted}}/example.cpp.jinja @@ -1,4 +1,4 @@ -#include "{{project_name_formatted}}/example.hpp" +#include "{{ project_name_formatted }}/example.hpp" Example::Example(const std::string& value) : stuff(value) {} diff --git a/cppjswasm/cpp/{{project_name_formatted}}/extension.cpp.jinja b/cppjswasm/cpp/{{project_name_formatted}}/extension.cpp.jinja index 6a7d50f..00a26be 100644 --- a/cppjswasm/cpp/{{project_name_formatted}}/extension.cpp.jinja +++ b/cppjswasm/cpp/{{project_name_formatted}}/extension.cpp.jinja @@ -1,7 +1,7 @@ #include #include -#include "{{project_name_formatted}}/example.hpp" +#include "{{ project_name_formatted }}/example.hpp" namespace py = pybind11; diff --git a/cppjswasm/js/build.mjs.jinja b/cppjswasm/js/build.mjs.jinja index ca1555b..ae6c2a3 100644 --- a/cppjswasm/js/build.mjs.jinja +++ b/cppjswasm/js/build.mjs.jinja @@ -1,92 +1,42 @@ -import { NodeModulesExternal } from "@finos/perspective-esbuild-plugin/external.js"; -import { build } from "@finos/perspective-esbuild-plugin/build.js"; -import { transform } from "lightningcss"; +import { bundle } from "./tools/bundle.mjs"; +import { bundle_css } from "./tools/css.mjs"; +import { node_modules_external } from "./tools/externals.mjs"; import { getarg } from "./tools/getarg.mjs"; + +import { transform } from "lightningcss"; import fs from "fs"; import cpy from "cpy"; -const DEBUG = getarg("--debug"); - -const COMMON_DEFINE = { - global: "window", - "process.env.DEBUG": `${DEBUG}`, -}; - -const BUILD = [ +const BUNDLES = [ { - define: COMMON_DEFINE, entryPoints: ["src/ts/index.ts"], - plugins: [NodeModulesExternal()], - format: "esm", - loader: { - ".css": "text", - ".html": "text", - }, + plugins: [node_modules_external()], outfile: "dist/esm/index.js", }, { - define: COMMON_DEFINE, entryPoints: ["src/ts/index.ts"], - plugins: [], - format: "esm", - loader: { - ".css": "text", - ".html": "text", - }, outfile: "dist/cdn/index.js", }, ]; -async function compile_css() { - const process_path = (path) => { - const outpath = path.replace("src/css", "dist/css"); - fs.mkdirSync(outpath, { recursive: true }); - - fs.readdirSync(path, { withFileTypes: true }).forEach((entry) => { - const input = `${path}/${entry.name}`; - const output = `${outpath}/${entry.name}`; +async function build() { + // Bundle css + await bundle_css(); - if (entry.isDirectory()) { - process_path(input); - } else if (entry.isFile() && entry.name.endsWith(".css")) { - const source = fs.readFileSync(input); - const { code } = transform({ - filename: entry.name, - code: source, - minify: !DEBUG, - sourceMap: false, - }); - fs.writeFileSync(output, code); - } - }); - }; - - process_path("src/css"); -} - -async function copy_html() { + // Copy HTML fs.mkdirSync("dist/html", { recursive: true }); cpy("src/html/*", "dist/html"); - // also copy to top level cpy("src/html/*", "dist/"); -} -async function copy_img() { + // Copy images fs.mkdirSync("dist/img", { recursive: true }); cpy("src/img/*", "dist/img"); -} -async function copy_to_python() { - fs.mkdirSync("../{{module}}/extension", { recursive: true }); - cpy("dist/**/*", "../{{module}}/extension"); -} + await Promise.all(BUNDLES.map(bundle)).catch(() => process.exit(1)); -async function build_all() { - await compile_css(); - await copy_html(); - await copy_img(); - await Promise.all(BUILD.map(build)).catch(() => process.exit(1)); - await copy_to_python(); + // Copy from dist to python + fs.mkdirSync("../{{ module }}/extension", { recursive: true }); + cpy("dist/**/*", "../{{ module }}/extension"); } -build_all(); +build(); diff --git a/cppjswasm/js/package.json.jinja b/cppjswasm/js/package.json.jinja index 16b7e03..0e377cc 100644 --- a/cppjswasm/js/package.json.jinja +++ b/cppjswasm/js/package.json.jinja @@ -1,9 +1,9 @@ { - "name": "{{project_name_formatted}}", + "name": "{{ project_name_formatted }}", "version": "0.1.0", - "description": "{{project_description}}", - "repository": "git@github.com:{{github}}/{{project_name_formatted}}.git", - "author": "{{team}} <{{email}}>", + "description": "{{ project_description }}", + "repository": "git@github.com:{{ github }}/{{ project_name_formatted }}.git", + "author": "{{ team }} <{{ email }}>", "license": "Apache-2.0", "private": true, "type": "module", @@ -26,11 +26,11 @@ "access": "public" }, "scripts": { - "build:cpp": "node -e \"require('fs').mkdirSync('dist/pkg',{recursive:true})\" && em++ -O2 -std=c++17 -s WASM=1 -s MODULARIZE=1 -s EXPORT_ES6=1 -s SINGLE_FILE=1 -s ALLOW_MEMORY_GROWTH=1 -s ENVIRONMENT=web,worker --bind -I ../cpp ../cpp/{{project_name_formatted}}/example.cpp src/cpp/bindings.cpp -o dist/pkg/{{module}}.js", + "build:cpp": "node -e \"require('fs').mkdirSync('dist/pkg',{recursive:true})\" && em++ -O2 -std=c++17 -s WASM=1 -s MODULARIZE=1 -s EXPORT_ES6=1 -s SINGLE_FILE=1 -s ALLOW_MEMORY_GROWTH=1 -s ENVIRONMENT=web,worker --bind -I ../cpp ../cpp/{{ project_name_formatted }}/example.cpp src/cpp/bindings.cpp -o dist/pkg/{{ module }}.js", "build:debug": "node build.mjs --debug", "build:prod": "node build.mjs", "build": "npm-run-all build:cpp build:prod", - "clean": "rm -rf dist lib playwright-report ../{{module}}/extension", + "clean": "rm -rf dist lib playwright-report ../{{ module }}/extension", "dev": "npm-run-all -p start watch", "lint:js": "prettier --check \"src/**/*.{js,ts,jsx,tsx,css}\" \"tests/**/*.{js,ts,jsx,tsx}\" \"*.mjs\" \"*.json\"", "lint:cpp": "clang-format --dry-run -Werror -style=file:../.clang-format src/cpp/*.cpp", @@ -48,7 +48,6 @@ }, "dependencies": {}, "devDependencies": { - "@finos/perspective-esbuild-plugin": "^3.2.1", "@playwright/test": "^1.59.1", "cpy": "^13.2.1", "esbuild": "^0.27.3", diff --git a/cppjswasm/js/src/cpp/bindings.cpp.jinja b/cppjswasm/js/src/cpp/bindings.cpp.jinja index 80c62b8..08e8827 100644 --- a/cppjswasm/js/src/cpp/bindings.cpp.jinja +++ b/cppjswasm/js/src/cpp/bindings.cpp.jinja @@ -1,10 +1,10 @@ #include -#include "{{project_name_formatted}}/example.hpp" +#include "{{ project_name_formatted }}/example.hpp" using namespace emscripten; -EMSCRIPTEN_BINDINGS({{module}}) { +EMSCRIPTEN_BINDINGS({{ module }}) { function("add", &add); class_("Example").constructor().property("stuff", &Example::stuff); diff --git a/cppjswasm/js/src/html/index.html.jinja b/cppjswasm/js/src/html/index.html.jinja index 5ecca1e..ecc91c7 100644 --- a/cppjswasm/js/src/html/index.html.jinja +++ b/cppjswasm/js/src/html/index.html.jinja @@ -1,9 +1,9 @@ - {{project_name}} - - + {{ project_name }} + + diff --git a/cppjswasm/js/src/ts/index.ts.jinja b/cppjswasm/js/src/ts/index.ts.jinja index d07a5e0..3851a90 100644 --- a/cppjswasm/js/src/ts/index.ts.jinja +++ b/cppjswasm/js/src/ts/index.ts.jinja @@ -1,5 +1,5 @@ // @ts-ignore - emscripten generated module -import createModule from "../../dist/pkg/{{module}}.js"; +import createModule from "../../dist/pkg/{{ module }}.js"; export { createModule }; diff --git a/cppjswasm/js/tools/bundle.mjs b/cppjswasm/js/tools/bundle.mjs new file mode 100644 index 0000000..b417871 --- /dev/null +++ b/cppjswasm/js/tools/bundle.mjs @@ -0,0 +1,59 @@ +import { getarg } from "./getarg.mjs"; +import esbuild from "esbuild"; + +const DEBUG = getarg("--debug"); + +const CUTOFF_PERCENT = 0.02; + +const COMMON_DEFINE = { + global: "window", + "process.env.DEBUG": `${DEBUG}`, +}; + +const COMMON_LOADER = { + ".css": "text", + ".html": "text", + ".jsx": "jsx", + ".png": "file", + ".ttf": "file", + ".wasm": "file", +}; + +const DEFAULT_BUILD = { + target: ["es2022"], + bundle: true, + format: "esm", + minify: DEBUG, + sourcemap: true, + metafile: true, + entryNames: "[name]", + chunkNames: "[name]", + assetNames: "[name]", + define: COMMON_DEFINE, + loader: COMMON_LOADER, + plugins: [], +}; + +export const bundle = async (config) => { + const result = await esbuild.build({ + ...DEFAULT_BUILD, + ...config, + }); + + if (result.metafile) { + for (const output of Object.keys(result.metafile.outputs)) { + const { inputs, bytes } = result.metafile.outputs[output]; + for (const input of Object.keys(inputs)) { + if (inputs[input].bytesInOutput / bytes < CUTOFF_PERCENT) { + delete inputs[input]; + } + } + } + + const text = await esbuild.analyzeMetafile(result.metafile, { + color: true, + }); + + console.log(text); + } +}; diff --git a/cppjswasm/js/tools/css.mjs b/cppjswasm/js/tools/css.mjs new file mode 100644 index 0000000..4ac3594 --- /dev/null +++ b/cppjswasm/js/tools/css.mjs @@ -0,0 +1,52 @@ +import { getarg } from "./getarg.mjs"; + +import { bundleAsync } from "lightningcss"; +import fs from "fs"; +import path from "path"; + +const DEBUG = getarg("--debug"); + +const DEFAULT_RESOLVER = { + resolve(specifier, originatingFile) { + if (/^https?:\/\//.test(specifier)) { + return specifier; + } + + if (specifier.startsWith("perspective-viewer-")) { + const viewerCssDir = path.resolve( + "node_modules/@perspective-dev/viewer/dist/css", + ); + const normalized = specifier.replace(/^perspective-viewer-/, ""); + const normalizedPath = path.join(viewerCssDir, normalized); + if (fs.existsSync(normalizedPath)) { + return normalizedPath; + } + return path.join(viewerCssDir, specifier); + } + return path.resolve(path.dirname(originatingFile), specifier); + }, +}; + +const bundle_one = async (file, resolver) => { + const { code } = await bundleAsync({ + filename: path.resolve(file), + minify: !DEBUG, + sourceMap: false, + resolver: resolver || DEFAULT_RESOLVER, + }); + const outName = path.basename(file); + fs.mkdirSync("./dist", { recursive: true }); + fs.writeFileSync(path.join("./dist", outName), code); +}; + +export const bundle_css = async (root = "src/css/index.css", resolver = null) => { + const resolved = path.resolve(root); + if (fs.statSync(resolved).isDirectory()) { + const files = fs.readdirSync(resolved).filter((f) => f.endsWith(".css")); + for (const file of files) { + await bundle_one(path.join(root, file), resolver); + } + } else { + await bundle_one(root, resolver); + } +} diff --git a/cppjswasm/js/tools/externals.mjs b/cppjswasm/js/tools/externals.mjs new file mode 100644 index 0000000..0ee4835 --- /dev/null +++ b/cppjswasm/js/tools/externals.mjs @@ -0,0 +1,18 @@ +export const node_modules_external = (whitelist) => { + function setup(build) { + build.onResolve({ filter: /^[A-Za-z0-9\@]/ }, (args) => { + if (!whitelist || !args.path.startsWith(whitelist)) { + return { + path: args.path, + external: true, + namespace: "skip-node-modules", + }; + } + }); + } + + return { + name: "node_modules_external", + setup, + }; +}; diff --git a/cppjswasm/js/tools/getarg.mjs b/cppjswasm/js/tools/getarg.mjs index 30793a7..9cfe88c 100644 --- a/cppjswasm/js/tools/getarg.mjs +++ b/cppjswasm/js/tools/getarg.mjs @@ -20,4 +20,4 @@ export const getarg = (flag, ...args) => { }) .join(" "); } - }; \ No newline at end of file + }; diff --git a/cppjswasm/js/tools/html.mjs b/cppjswasm/js/tools/html.mjs new file mode 100644 index 0000000..e69de29 diff --git a/cppjswasm/pyproject.toml.jinja b/cppjswasm/pyproject.toml.jinja index 84a4f73..9e86f6c 100644 --- a/cppjswasm/pyproject.toml.jinja +++ b/cppjswasm/pyproject.toml.jinja @@ -8,11 +8,11 @@ requires = [ build-backend = "hatchling.build" [project] -name = "{{project_name_formatted}}" +name = "{{ project_name_formatted }}" authors = [ - {name = "{{team}}", email = "{{email}}"}, + {name = "{{ team }}", email = "{{ email }}"}, ] -description = "{{project_description}}" +description = "{{ project_description }}" readme = "README.md" license = { text = "Apache-2.0" } version = "0.1.0" @@ -60,8 +60,8 @@ develop = [ [project.scripts] [project.urls] -Repository = "https://github.com/{{github}}/{{project_name_formatted}}" -Homepage = "https://github.com/{{github}}/{{project_name_formatted}}" +Repository = "https://github.com/{{ github }}/{{ project_name_formatted }}" +Homepage = "https://github.com/{{ github }}/{{ project_name_formatted }}" [tool.bumpversion] current_version = "0.1.0" @@ -70,7 +70,7 @@ tag = true commit_args = "-s" [[tool.bumpversion.files]] -filename = "{{module}}/__init__.py" +filename = "{{ module }}/__init__.py" search = '__version__ = "{current_version}"' replace = '__version__ = "{new_version}"' @@ -86,7 +86,7 @@ replace = '"version": "{new_version}"' [tool.cibuildwheel] build = "cp310-*" -test-command = "pytest -vvv {project}/{{module}}/tests" +test-command = "pytest -vvv {project}/{{ module }}/tests" test-extras = "develop" [tool.cibuildwheel.linux] @@ -104,7 +104,7 @@ skip = "*win32 *arm_64" [tool.coverage.run] branch = true omit = [ - "{{module}}/tests/integration/", + "{{ module }}/tests/integration/", ] [tool.coverage.report] @@ -118,10 +118,10 @@ fail_under = 50 [tool.hatch.build] artifacts = [ - "{{module}}/*.dll", - "{{module}}/*.dylib", - "{{module}}/*.so", - "{{module}}/extension", + "{{ module }}/*.dll", + "{{ module }}/*.dylib", + "{{ module }}/*.so", + "{{ module }}/extension", ] [tool.hatch.build.sources] @@ -132,25 +132,25 @@ path = "js" build_cmd = "build" tool = "pnpm" targets = [ - "{{module}}/extension/cdn/index.js", + "{{ module }}/extension/cdn/index.js", ] [tool.hatch.build.hooks.hatch-cpp] verbose = true libraries = [ - {name = "{{module}}/extension_cpp", sources = ["cpp/{{project_name_formatted}}/example.cpp", "cpp/{{project_name_formatted}}/extension.cpp"], include-dirs = ["cpp"], binding="pybind11"} + {name = "{{ module }}/extension_cpp", sources = ["cpp/{{ project_name_formatted }}/example.cpp", "cpp/{{ project_name_formatted }}/extension.cpp"], include-dirs = ["cpp"], binding="pybind11"} ] [tool.hatch.build.targets.sdist] packages = [ - "{{module}}", + "{{ module }}", "cpp", "js", ] [tool.hatch.build.targets.wheel] packages = [ - "{{module}}", + "{{ module }}", ] exclude = [ "js", @@ -162,7 +162,7 @@ addopts = [ "-vvv", "--junitxml=junit.xml", ] -testpaths = "{{module}}/tests" +testpaths = "{{ module }}/tests" [tool.ruff] line-length = 150 @@ -176,7 +176,7 @@ extend-select = [ combine-as-imports = true default-section = "third-party" known-first-party = [ - "{{module}}", + "{{ module }}", ] section-order = [ "future", diff --git a/cppjswasm/{% if add_wiki %}docs{% endif %}/wiki/Installation.md.jinja b/cppjswasm/{% if add_wiki %}docs{% endif %}/wiki/Installation.md.jinja index 8dfc880..89b2612 100644 --- a/cppjswasm/{% if add_wiki %}docs{% endif %}/wiki/Installation.md.jinja +++ b/cppjswasm/{% if add_wiki %}docs{% endif %}/wiki/Installation.md.jinja @@ -1,19 +1,19 @@ ## Pre-requisites -You need Python >=3.10 on your machine to install `{{project_name_formatted}}`. +You need Python >=3.10 on your machine to install `{{ project_name_formatted }}`. ## Install with `pip` ```bash -pip install {{project_name_formatted}} +pip install {{ project_name_formatted }} ``` ## Install with `conda` ```bash -conda install {{project_name_formatted}} --channel conda-forge +conda install {{ project_name_formatted }} --channel conda-forge ``` ## Source installation -For other platforms and for development installations, [build `{{project_name_formatted}}` from source](Build-from-Source). +For other platforms and for development installations, [build `{{ project_name_formatted }}` from source](Build-from-Source). diff --git a/cppjswasm/{% if add_wiki %}docs{% endif %}/wiki/_Footer.md.jinja b/cppjswasm/{% if add_wiki %}docs{% endif %}/wiki/_Footer.md.jinja index 4a5fb4b..bd81a19 100644 --- a/cppjswasm/{% if add_wiki %}docs{% endif %}/wiki/_Footer.md.jinja +++ b/cppjswasm/{% if add_wiki %}docs{% endif %}/wiki/_Footer.md.jinja @@ -1 +1 @@ -_This wiki is autogenerated. To made updates, open a PR against the original source file in [`docs/wiki`](https://github.com/{{github}}/{{project_name_formatted}}/tree/main/docs/wiki)._ +_This wiki is autogenerated. To made updates, open a PR against the original source file in [`docs/wiki`](https://github.com/{{ github }}/{{ project_name_formatted }}/tree/main/docs/wiki)._ diff --git a/cppjswasm/{% if add_wiki %}docs{% endif %}/wiki/contribute/Build-from-Source.md.jinja b/cppjswasm/{% if add_wiki %}docs{% endif %}/wiki/contribute/Build-from-Source.md.jinja index 509cbfa..4875eee 100644 --- a/cppjswasm/{% if add_wiki %}docs{% endif %}/wiki/contribute/Build-from-Source.md.jinja +++ b/cppjswasm/{% if add_wiki %}docs{% endif %}/wiki/contribute/Build-from-Source.md.jinja @@ -1,4 +1,4 @@ -`{{project_name_formatted}}` is written in Python, C++, and JavaScript. While prebuilt wheels are provided for end users, it is also straightforward to build `{{project_name_formatted}}` from either the Python [source distribution](https://packaging.python.org/en/latest/specifications/source-distribution-format/) or the GitHub repository. +`{{ project_name_formatted }}` is written in Python, C++, and JavaScript. While prebuilt wheels are provided for end users, it is also straightforward to build `{{ project_name_formatted }}` from either the Python [source distribution](https://packaging.python.org/en/latest/specifications/source-distribution-format/) or the GitHub repository. - [Make commands](#make-commands) - [Prerequisites](#prerequisites) @@ -10,7 +10,7 @@ ## Make commands -As a convenience, `{{project_name_formatted}}` uses a `Makefile` for commonly used commands. You can print the main available commands by running `make` with no arguments +As a convenience, `{{ project_name_formatted }}` uses a `Makefile` for commonly used commands. You can print the main available commands by running `make` with no arguments ```bash > make @@ -25,15 +25,15 @@ test run the tests ## Prerequisites -`{{project_name_formatted}}` has a few system-level dependencies which you can install from your machine package manager. Other package managers like `conda`, `nix`, etc, should also work fine. +`{{ project_name_formatted }}` has a few system-level dependencies which you can install from your machine package manager. Other package managers like `conda`, `nix`, etc, should also work fine. ## Clone Clone the repo with: ```bash -git clone https://github.com/{{github}}/{{project_name_formatted}}.git -cd {{project_name_formatted}} +git clone https://github.com/{{ github }}/{{ project_name_formatted }}.git +cd {{ project_name_formatted }} ``` ## Install C++ Compiler @@ -64,7 +64,7 @@ make build ## Lint and Autoformat -`{{project_name_formatted}}` has linting and auto formatting. +`{{ project_name_formatted }}` has linting and auto formatting. | Language | Linter | Autoformatter | Description | | :--------- | :------------- | :------------- | :---------- | @@ -125,7 +125,7 @@ make fix-docs ## Testing -`{{project_name_formatted}}` has both Python and JavaScript tests. The bulk of the functionality is tested in Python, which can be run via `pytest`. First, install the Python development dependencies with +`{{ project_name_formatted }}` has both Python and JavaScript tests. The bulk of the functionality is tested in Python, which can be run via `pytest`. First, install the Python development dependencies with ```bash make develop diff --git a/cppjswasm/{% if add_wiki %}docs{% endif %}/wiki/contribute/Contribute.md.jinja b/cppjswasm/{% if add_wiki %}docs{% endif %}/wiki/contribute/Contribute.md.jinja index 7deea95..463b117 100644 --- a/cppjswasm/{% if add_wiki %}docs{% endif %}/wiki/contribute/Contribute.md.jinja +++ b/cppjswasm/{% if add_wiki %}docs{% endif %}/wiki/contribute/Contribute.md.jinja @@ -1,14 +1,14 @@ -Contributions are welcome on this project. We distribute under the terms of the [Apache 2.0 license](https://github.com/{{github}}/{{project_name_formatted}}/blob/main/LICENSE). +Contributions are welcome on this project. We distribute under the terms of the [Apache 2.0 license](https://github.com/{{ github }}/{{ project_name_formatted }}/blob/main/LICENSE). > [!NOTE] > -> `{{project_name_formatted}}` requires [Developer Certificate of Origin](https://en.wikipedia.org/wiki/Developer_Certificate_of_Origin) for all contributions. +> `{{ project_name_formatted }}` requires [Developer Certificate of Origin](https://en.wikipedia.org/wiki/Developer_Certificate_of_Origin) for all contributions. > This is enforced by a [Probot GitHub App](https://probot.github.io/apps/dco/), which checks that commits are "signed". > Read [instructions to configure commit signing](Local-Development-Setup#configure-commit-signing). -For **bug reports** or **small feature requests**, please open an issue on our [issues page](https://github.com/{{github}}/{{project_name_formatted}}/issues). +For **bug reports** or **small feature requests**, please open an issue on our [issues page](https://github.com/{{ github }}/{{ project_name_formatted }}/issues). -For **questions** or to discuss **larger changes or features**, please use our [discussions page](https://github.com/{{github}}/{{project_name_formatted}}/discussions). +For **questions** or to discuss **larger changes or features**, please use our [discussions page](https://github.com/{{ github }}/{{ project_name_formatted }}/discussions). For **contributions**, please see our [developer documentation](Local-Development-Setup). We have `help wanted` and `good first issue` tags on our issues page, so these are a great place to start. diff --git a/cppjswasm/{% if add_wiki %}docs{% endif %}/wiki/contribute/Local-Development-Setup.md.jinja b/cppjswasm/{% if add_wiki %}docs{% endif %}/wiki/contribute/Local-Development-Setup.md.jinja index 897872a..abf413b 100644 --- a/cppjswasm/{% if add_wiki %}docs{% endif %}/wiki/contribute/Local-Development-Setup.md.jinja +++ b/cppjswasm/{% if add_wiki %}docs{% endif %}/wiki/contribute/Local-Development-Setup.md.jinja @@ -10,27 +10,27 @@ ## Step 1: Build from Source -To work on `{{project_name_formatted}}`, you are going to need to build it from source. See +To work on `{{ project_name_formatted }}`, you are going to need to build it from source. See [Build from Source](Build-from-Source) for detailed build instructions. -Once you've built `{{project_name_formatted}}` from a `git` clone, you will also need to -configure `git` and your GitHub account for `{{project_name_formatted}}` development. +Once you've built `{{ project_name_formatted }}` from a `git` clone, you will also need to +configure `git` and your GitHub account for `{{ project_name_formatted }}` development. ## Step 2: Configuring Git and GitHub for Development ### Create your fork -The first step is to create a personal fork of `{{project_name_formatted}}`. To do so, click -the "fork" button at https://github.com/{{github}}/{{project_name_formatted}}, or just navigate -[here](https://github.com/{{github}}/{{project_name_formatted}}/fork) in your browser. Set the +The first step is to create a personal fork of `{{ project_name_formatted }}`. To do so, click +the "fork" button at https://github.com/{{ github }}/{{ project_name_formatted }}, or just navigate +[here](https://github.com/{{ github }}/{{ project_name_formatted }}/fork) in your browser. Set the owner of the repository to your personal GitHub account if it is not already set that way and click "Create fork". ### Configure remotes Next, you should set some names for the `git` remotes corresponding to -main {{github}} repository and your fork. See the [GitHub Docs](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/configuring-a-remote-repository-for-a-fork) for more information. +main {{ github }} repository and your fork. See the [GitHub Docs](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/configuring-a-remote-repository-for-a-fork) for more information. ### Authenticating with GitHub diff --git a/cppjswasm/{{module}}/tests/test_all.py.jinja b/cppjswasm/{{module}}/tests/test_all.py.jinja index 4097771..f3a6ba9 100644 --- a/cppjswasm/{{module}}/tests/test_all.py.jinja +++ b/cppjswasm/{{module}}/tests/test_all.py.jinja @@ -1,4 +1,4 @@ -from {{module}} import add +from {{ module }} import add class TestAll: diff --git a/js/.github/CODE_OF_CONDUCT.md.jinja b/js/.github/CODE_OF_CONDUCT.md.jinja index ebc86d7..9eab626 100644 --- a/js/.github/CODE_OF_CONDUCT.md.jinja +++ b/js/.github/CODE_OF_CONDUCT.md.jinja @@ -55,7 +55,7 @@ further defined and clarified by project maintainers. ## Enforcement Instances of abusive, harassing, or otherwise unacceptable behavior may be -reported by contacting the project team at {{email}}. All +reported by contacting the project team at {{ email }}. All complaints will be reviewed and investigated and will result in a response that is deemed necessary and appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. diff --git a/js/.github/workflows/build.yaml.jinja b/js/.github/workflows/build.yaml.jinja index c26acaa..ddbcdea 100644 --- a/js/.github/workflows/build.yaml.jinja +++ b/js/.github/workflows/build.yaml.jinja @@ -30,7 +30,7 @@ jobs: strategy: matrix: os: [ubuntu-latest] - python-version: ["{{python_version_primary}}"] + python-version: ["{{ python_version_primary }}"] node-version: [20.x] steps: diff --git a/js/.gitignore.jinja b/js/.gitignore.jinja index 0cf743a..73811ea 100644 --- a/js/.gitignore.jinja +++ b/js/.gitignore.jinja @@ -133,9 +133,9 @@ js/*.tgz .ipynb_checkpoints .autoversion Untitled*.ipynb -{{module}}/extension -{{module}}/nbextension -{{module}}/labextension +{{ module }}/extension +{{ module }}/nbextension +{{ module }}/labextension # Mac .DS_Store diff --git a/js/LICENSE.jinja b/js/LICENSE.jinja index ee2a86d..3d7a96a 100644 --- a/js/LICENSE.jinja +++ b/js/LICENSE.jinja @@ -186,7 +186,7 @@ same "printed page" as the copyright notice for easier identification within third-party archives. - Copyright 2025 {{team}} + Copyright 2025 {{ team }} Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/js/Makefile.jinja b/js/Makefile.jinja index 5fb6177..d62b7f2 100644 --- a/js/Makefile.jinja +++ b/js/Makefile.jinja @@ -38,8 +38,8 @@ install: ## install python library ######### .PHONY: lint-py lint-js lint lints lint-py: ## run python linter with ruff - python -m ruff check {{module}} - python -m ruff format --check {{module}} + python -m ruff check {{ module }} + python -m ruff format --check {{ module }} lint-js: ## run js linter cd js; pnpm lint @@ -55,8 +55,8 @@ lints: lint .PHONY: fix-py fix-js fix-docs fix format fix-py: ## fix python formatting with ruff - python -m ruff check --fix {{module}} - python -m ruff format {{module}} + python -m ruff check --fix {{ module }} + python -m ruff format {{ module }} fix-js: ## fix js formatting cd js; pnpm fix @@ -91,13 +91,13 @@ check: checks ######### .PHONY: test-py tests-py coverage-py test-py: ## run python tests - python -m pytest -v {{module}}/tests + python -m pytest -v {{ module }}/tests # alias tests-py: test-py coverage-py: ## run python tests and collect test coverage - python -m pytest -v {{module}}/tests --cov={{module}} --cov-report term-missing --cov-report xml + python -m pytest -v {{ module }}/tests --cov={{ module }} --cov-report term-missing --cov-report xml .PHONY: test-js tests-js coverage-js test-js: ## run js tests diff --git a/js/README.md.jinja b/js/README.md.jinja index d8ce83b..7e11b1c 100644 --- a/js/README.md.jinja +++ b/js/README.md.jinja @@ -1,11 +1,11 @@ -# {{project_name}} +# {{ project_name }} -{{project_description}} +{{ project_description }} -[![Build Status](https://github.com/{{github}}/{{project_name_formatted}}/actions/workflows/build.yaml/badge.svg?branch=main&event=push)](https://github.com/{{github}}/{{project_name_formatted}}/actions/workflows/build.yaml) -[![codecov](https://codecov.io/gh/{{github}}/{{project_name_formatted}}/branch/main/graph/badge.svg)](https://codecov.io/gh/{{github}}/{{project_name_formatted}}) -[![License](https://img.shields.io/github/license/{{github}}/{{project_name_formatted}})](https://github.com/{{github}}/{{project_name_formatted}}) -[![PyPI](https://img.shields.io/pypi/v/{{project_name_formatted}}.svg)](https://pypi.python.org/pypi/{{project_name_formatted}}) +[![Build Status](https://github.com/{{ github }}/{{ project_name_formatted }}/actions/workflows/build.yaml/badge.svg?branch=main&event=push)](https://github.com/{{ github }}/{{ project_name_formatted }}/actions/workflows/build.yaml) +[![codecov](https://codecov.io/gh/{{ github }}/{{ project_name_formatted }}/branch/main/graph/badge.svg)](https://codecov.io/gh/{{ github }}/{{ project_name_formatted }}) +[![License](https://img.shields.io/github/license/{{ github }}/{{ project_name_formatted }})](https://github.com/{{ github }}/{{ project_name_formatted }}) +[![PyPI](https://img.shields.io/pypi/v/{{ project_name_formatted }}.svg)](https://pypi.python.org/pypi/{{ project_name_formatted }}) ## Overview diff --git a/js/js/build.mjs.jinja b/js/js/build.mjs.jinja index ca1555b..ae6c2a3 100644 --- a/js/js/build.mjs.jinja +++ b/js/js/build.mjs.jinja @@ -1,92 +1,42 @@ -import { NodeModulesExternal } from "@finos/perspective-esbuild-plugin/external.js"; -import { build } from "@finos/perspective-esbuild-plugin/build.js"; -import { transform } from "lightningcss"; +import { bundle } from "./tools/bundle.mjs"; +import { bundle_css } from "./tools/css.mjs"; +import { node_modules_external } from "./tools/externals.mjs"; import { getarg } from "./tools/getarg.mjs"; + +import { transform } from "lightningcss"; import fs from "fs"; import cpy from "cpy"; -const DEBUG = getarg("--debug"); - -const COMMON_DEFINE = { - global: "window", - "process.env.DEBUG": `${DEBUG}`, -}; - -const BUILD = [ +const BUNDLES = [ { - define: COMMON_DEFINE, entryPoints: ["src/ts/index.ts"], - plugins: [NodeModulesExternal()], - format: "esm", - loader: { - ".css": "text", - ".html": "text", - }, + plugins: [node_modules_external()], outfile: "dist/esm/index.js", }, { - define: COMMON_DEFINE, entryPoints: ["src/ts/index.ts"], - plugins: [], - format: "esm", - loader: { - ".css": "text", - ".html": "text", - }, outfile: "dist/cdn/index.js", }, ]; -async function compile_css() { - const process_path = (path) => { - const outpath = path.replace("src/css", "dist/css"); - fs.mkdirSync(outpath, { recursive: true }); - - fs.readdirSync(path, { withFileTypes: true }).forEach((entry) => { - const input = `${path}/${entry.name}`; - const output = `${outpath}/${entry.name}`; +async function build() { + // Bundle css + await bundle_css(); - if (entry.isDirectory()) { - process_path(input); - } else if (entry.isFile() && entry.name.endsWith(".css")) { - const source = fs.readFileSync(input); - const { code } = transform({ - filename: entry.name, - code: source, - minify: !DEBUG, - sourceMap: false, - }); - fs.writeFileSync(output, code); - } - }); - }; - - process_path("src/css"); -} - -async function copy_html() { + // Copy HTML fs.mkdirSync("dist/html", { recursive: true }); cpy("src/html/*", "dist/html"); - // also copy to top level cpy("src/html/*", "dist/"); -} -async function copy_img() { + // Copy images fs.mkdirSync("dist/img", { recursive: true }); cpy("src/img/*", "dist/img"); -} -async function copy_to_python() { - fs.mkdirSync("../{{module}}/extension", { recursive: true }); - cpy("dist/**/*", "../{{module}}/extension"); -} + await Promise.all(BUNDLES.map(bundle)).catch(() => process.exit(1)); -async function build_all() { - await compile_css(); - await copy_html(); - await copy_img(); - await Promise.all(BUILD.map(build)).catch(() => process.exit(1)); - await copy_to_python(); + // Copy from dist to python + fs.mkdirSync("../{{ module }}/extension", { recursive: true }); + cpy("dist/**/*", "../{{ module }}/extension"); } -build_all(); +build(); diff --git a/js/js/package.json.jinja b/js/js/package.json.jinja index 31ae736..8e54d52 100644 --- a/js/js/package.json.jinja +++ b/js/js/package.json.jinja @@ -1,9 +1,9 @@ { - "name": "{{project_name_formatted}}", + "name": "{{ project_name_formatted }}", "version": "0.1.0", - "description": "{{project_description}}", - "repository": "git@github.com:{{github}}/{{project_name_formatted}}.git", - "author": "{{team}} <{{email}}>", + "description": "{{ project_description }}", + "repository": "git@github.com:{{ github }}/{{ project_name_formatted }}.git", + "author": "{{ team }} <{{ email }}>", "license": "Apache-2.0", "private": true, "type": "module", @@ -28,7 +28,7 @@ "scripts": { "build:debug": "node build.mjs --debug", "build": "node build.mjs", - "clean": "rm -rf dist playwright-report ../{{module}}/extension", + "clean": "rm -rf dist playwright-report ../{{ module }}/extension", "dev": "npm-run-all -p start watch", "lint": "prettier --check \"src/**/*.{js,ts,jsx,tsx,css}\" \"tests/**/*.{js,ts,jsx,tsx}\" \"*.mjs\" \"*.json\"", "fix": "prettier --write \"src/**/*.{js,ts,jsx,tsx,css}\" \"tests/**/*.{js,ts,jsx,tsx}\" \"*.mjs\" \"*.json\"", @@ -41,7 +41,6 @@ }, "dependencies": {}, "devDependencies": { - "@finos/perspective-esbuild-plugin": "^3.2.1", "@playwright/test": "^1.59.1", "cpy": "^13.2.1", "esbuild": "^0.27.3", diff --git a/js/js/src/html/index.html.jinja b/js/js/src/html/index.html.jinja index 5ecca1e..ecc91c7 100644 --- a/js/js/src/html/index.html.jinja +++ b/js/js/src/html/index.html.jinja @@ -1,9 +1,9 @@ - {{project_name}} - - + {{ project_name }} + + diff --git a/js/js/tools/bundle.mjs b/js/js/tools/bundle.mjs new file mode 100644 index 0000000..b417871 --- /dev/null +++ b/js/js/tools/bundle.mjs @@ -0,0 +1,59 @@ +import { getarg } from "./getarg.mjs"; +import esbuild from "esbuild"; + +const DEBUG = getarg("--debug"); + +const CUTOFF_PERCENT = 0.02; + +const COMMON_DEFINE = { + global: "window", + "process.env.DEBUG": `${DEBUG}`, +}; + +const COMMON_LOADER = { + ".css": "text", + ".html": "text", + ".jsx": "jsx", + ".png": "file", + ".ttf": "file", + ".wasm": "file", +}; + +const DEFAULT_BUILD = { + target: ["es2022"], + bundle: true, + format: "esm", + minify: DEBUG, + sourcemap: true, + metafile: true, + entryNames: "[name]", + chunkNames: "[name]", + assetNames: "[name]", + define: COMMON_DEFINE, + loader: COMMON_LOADER, + plugins: [], +}; + +export const bundle = async (config) => { + const result = await esbuild.build({ + ...DEFAULT_BUILD, + ...config, + }); + + if (result.metafile) { + for (const output of Object.keys(result.metafile.outputs)) { + const { inputs, bytes } = result.metafile.outputs[output]; + for (const input of Object.keys(inputs)) { + if (inputs[input].bytesInOutput / bytes < CUTOFF_PERCENT) { + delete inputs[input]; + } + } + } + + const text = await esbuild.analyzeMetafile(result.metafile, { + color: true, + }); + + console.log(text); + } +}; diff --git a/js/js/tools/css.mjs b/js/js/tools/css.mjs new file mode 100644 index 0000000..4ac3594 --- /dev/null +++ b/js/js/tools/css.mjs @@ -0,0 +1,52 @@ +import { getarg } from "./getarg.mjs"; + +import { bundleAsync } from "lightningcss"; +import fs from "fs"; +import path from "path"; + +const DEBUG = getarg("--debug"); + +const DEFAULT_RESOLVER = { + resolve(specifier, originatingFile) { + if (/^https?:\/\//.test(specifier)) { + return specifier; + } + + if (specifier.startsWith("perspective-viewer-")) { + const viewerCssDir = path.resolve( + "node_modules/@perspective-dev/viewer/dist/css", + ); + const normalized = specifier.replace(/^perspective-viewer-/, ""); + const normalizedPath = path.join(viewerCssDir, normalized); + if (fs.existsSync(normalizedPath)) { + return normalizedPath; + } + return path.join(viewerCssDir, specifier); + } + return path.resolve(path.dirname(originatingFile), specifier); + }, +}; + +const bundle_one = async (file, resolver) => { + const { code } = await bundleAsync({ + filename: path.resolve(file), + minify: !DEBUG, + sourceMap: false, + resolver: resolver || DEFAULT_RESOLVER, + }); + const outName = path.basename(file); + fs.mkdirSync("./dist", { recursive: true }); + fs.writeFileSync(path.join("./dist", outName), code); +}; + +export const bundle_css = async (root = "src/css/index.css", resolver = null) => { + const resolved = path.resolve(root); + if (fs.statSync(resolved).isDirectory()) { + const files = fs.readdirSync(resolved).filter((f) => f.endsWith(".css")); + for (const file of files) { + await bundle_one(path.join(root, file), resolver); + } + } else { + await bundle_one(root, resolver); + } +} diff --git a/js/js/tools/externals.mjs b/js/js/tools/externals.mjs new file mode 100644 index 0000000..0ee4835 --- /dev/null +++ b/js/js/tools/externals.mjs @@ -0,0 +1,18 @@ +export const node_modules_external = (whitelist) => { + function setup(build) { + build.onResolve({ filter: /^[A-Za-z0-9\@]/ }, (args) => { + if (!whitelist || !args.path.startsWith(whitelist)) { + return { + path: args.path, + external: true, + namespace: "skip-node-modules", + }; + } + }); + } + + return { + name: "node_modules_external", + setup, + }; +}; diff --git a/js/js/tools/getarg.mjs b/js/js/tools/getarg.mjs index 30793a7..9cfe88c 100644 --- a/js/js/tools/getarg.mjs +++ b/js/js/tools/getarg.mjs @@ -20,4 +20,4 @@ export const getarg = (flag, ...args) => { }) .join(" "); } - }; \ No newline at end of file + }; diff --git a/js/js/tools/html.mjs b/js/js/tools/html.mjs new file mode 100644 index 0000000..e69de29 diff --git a/js/pyproject.toml.jinja b/js/pyproject.toml.jinja index ae2292b..6998505 100644 --- a/js/pyproject.toml.jinja +++ b/js/pyproject.toml.jinja @@ -6,11 +6,11 @@ requires = [ build-backend = "hatchling.build" [project] -name = "{{project_name_formatted}}" +name = "{{ project_name_formatted }}" authors = [ - {name = "{{team}}", email = "{{email}}"}, + {name = "{{ team }}", email = "{{ email }}"}, ] -description = "{{project_description}}" +description = "{{ project_description }}" readme = "README.md" license = { text = "Apache-2.0" } version = "0.1.0" @@ -54,8 +54,8 @@ develop = [ [project.scripts] [project.urls] -Repository = "https://github.com/{{github}}/{{project_name_formatted}}" -Homepage = "https://github.com/{{github}}/{{project_name_formatted}}" +Repository = "https://github.com/{{ github }}/{{ project_name_formatted }}" +Homepage = "https://github.com/{{ github }}/{{ project_name_formatted }}" [tool.bumpversion] current_version = "0.1.0" @@ -64,7 +64,7 @@ tag = true commit_args = "-s" [[tool.bumpversion.files]] -filename = "{{module}}/__init__.py" +filename = "{{ module }}/__init__.py" search = '__version__ = "{current_version}"' replace = '__version__ = "{new_version}"' @@ -81,7 +81,7 @@ replace = '"version": "{new_version}"' [tool.coverage.run] branch = true omit = [ - "{{module}}/tests/integration/", + "{{ module }}/tests/integration/", ] [tool.coverage.report] @@ -95,7 +95,7 @@ fail_under = 50 [tool.hatch.build] artifacts = [ - "{{module}}/extension", + "{{ module }}/extension", ] [tool.hatch.build.sources] @@ -103,7 +103,7 @@ src = "/" [tool.hatch.build.targets.sdist] packages = [ - "{{module}}", + "{{ module }}", "js", ] exclude = [ @@ -113,7 +113,7 @@ exclude = [ [tool.hatch.build.targets.wheel] packages = [ - "{{module}}", + "{{ module }}", ] exclude = [ "js", @@ -124,7 +124,7 @@ path = "js" build_cmd = "build" tool = "pnpm" targets = [ - "{{module}}/extension/cdn/index.js", + "{{ module }}/extension/cdn/index.js", ] [tool.pytest.ini_options] @@ -132,7 +132,7 @@ addopts = [ "-vvv", "--junitxml=junit.xml", ] -testpaths = "{{module}}/tests" +testpaths = "{{ module }}/tests" [tool.ruff] line-length = 150 @@ -146,7 +146,7 @@ extend-select = [ combine-as-imports = true default-section = "third-party" known-first-party = [ - "{{module}}", + "{{ module }}", ] section-order = [ "future", diff --git a/js/{% if add_wiki %}docs{% endif %}/wiki/Installation.md.jinja b/js/{% if add_wiki %}docs{% endif %}/wiki/Installation.md.jinja index 8dfc880..89b2612 100644 --- a/js/{% if add_wiki %}docs{% endif %}/wiki/Installation.md.jinja +++ b/js/{% if add_wiki %}docs{% endif %}/wiki/Installation.md.jinja @@ -1,19 +1,19 @@ ## Pre-requisites -You need Python >=3.10 on your machine to install `{{project_name_formatted}}`. +You need Python >=3.10 on your machine to install `{{ project_name_formatted }}`. ## Install with `pip` ```bash -pip install {{project_name_formatted}} +pip install {{ project_name_formatted }} ``` ## Install with `conda` ```bash -conda install {{project_name_formatted}} --channel conda-forge +conda install {{ project_name_formatted }} --channel conda-forge ``` ## Source installation -For other platforms and for development installations, [build `{{project_name_formatted}}` from source](Build-from-Source). +For other platforms and for development installations, [build `{{ project_name_formatted }}` from source](Build-from-Source). diff --git a/js/{% if add_wiki %}docs{% endif %}/wiki/_Footer.md.jinja b/js/{% if add_wiki %}docs{% endif %}/wiki/_Footer.md.jinja index 4a5fb4b..bd81a19 100644 --- a/js/{% if add_wiki %}docs{% endif %}/wiki/_Footer.md.jinja +++ b/js/{% if add_wiki %}docs{% endif %}/wiki/_Footer.md.jinja @@ -1 +1 @@ -_This wiki is autogenerated. To made updates, open a PR against the original source file in [`docs/wiki`](https://github.com/{{github}}/{{project_name_formatted}}/tree/main/docs/wiki)._ +_This wiki is autogenerated. To made updates, open a PR against the original source file in [`docs/wiki`](https://github.com/{{ github }}/{{ project_name_formatted }}/tree/main/docs/wiki)._ diff --git a/js/{% if add_wiki %}docs{% endif %}/wiki/contribute/Build-from-Source.md.jinja b/js/{% if add_wiki %}docs{% endif %}/wiki/contribute/Build-from-Source.md.jinja index 7431b53..eb55769 100644 --- a/js/{% if add_wiki %}docs{% endif %}/wiki/contribute/Build-from-Source.md.jinja +++ b/js/{% if add_wiki %}docs{% endif %}/wiki/contribute/Build-from-Source.md.jinja @@ -1,4 +1,4 @@ -`{{project_name_formatted}}` is written in Python and JavaScript. While prebuilt wheels are provided for end users, it is also straightforward to build `{{project_name_formatted}}` from either the Python [source distribution](https://packaging.python.org/en/latest/specifications/source-distribution-format/) or the GitHub repository. +`{{ project_name_formatted }}` is written in Python and JavaScript. While prebuilt wheels are provided for end users, it is also straightforward to build `{{ project_name_formatted }}` from either the Python [source distribution](https://packaging.python.org/en/latest/specifications/source-distribution-format/) or the GitHub repository. - [Make commands](#make-commands) - [Prerequisites](#prerequisites) @@ -10,7 +10,7 @@ ## Make commands -As a convenience, `{{project_name_formatted}}` uses a `Makefile` for commonly used commands. You can print the main available commands by running `make` with no arguments +As a convenience, `{{ project_name_formatted }}` uses a `Makefile` for commonly used commands. You can print the main available commands by running `make` with no arguments ```bash > make @@ -25,15 +25,15 @@ test run the tests ## Prerequisites -`{{project_name_formatted}}` has a few system-level dependencies which you can install from your machine package manager. Other package managers like `conda`, `nix`, etc, should also work fine. +`{{ project_name_formatted }}` has a few system-level dependencies which you can install from your machine package manager. Other package managers like `conda`, `nix`, etc, should also work fine. ## Clone Clone the repo with: ```bash -git clone https://github.com/{{github}}/{{project_name_formatted}}.git -cd {{project_name_formatted}} +git clone https://github.com/{{ github }}/{{ project_name_formatted }}.git +cd {{ project_name_formatted }} ``` ## Install NodeJS @@ -64,7 +64,7 @@ make build ## Lint and Autoformat -`{{project_name_formatted}}` has linting and auto formatting. +`{{ project_name_formatted }}` has linting and auto formatting. | Language | Linter | Autoformatter | Description | | :--------- | :---------- | :------------ | :---------- | @@ -112,7 +112,7 @@ make fix-docs ## Testing -`{{project_name_formatted}}` has both Python and JavaScript tests. The bulk of the functionality is tested in Python, which can be run via `pytest`. First, install the Python development dependencies with +`{{ project_name_formatted }}` has both Python and JavaScript tests. The bulk of the functionality is tested in Python, which can be run via `pytest`. First, install the Python development dependencies with ```bash make develop diff --git a/js/{% if add_wiki %}docs{% endif %}/wiki/contribute/Contribute.md.jinja b/js/{% if add_wiki %}docs{% endif %}/wiki/contribute/Contribute.md.jinja index 7deea95..463b117 100644 --- a/js/{% if add_wiki %}docs{% endif %}/wiki/contribute/Contribute.md.jinja +++ b/js/{% if add_wiki %}docs{% endif %}/wiki/contribute/Contribute.md.jinja @@ -1,14 +1,14 @@ -Contributions are welcome on this project. We distribute under the terms of the [Apache 2.0 license](https://github.com/{{github}}/{{project_name_formatted}}/blob/main/LICENSE). +Contributions are welcome on this project. We distribute under the terms of the [Apache 2.0 license](https://github.com/{{ github }}/{{ project_name_formatted }}/blob/main/LICENSE). > [!NOTE] > -> `{{project_name_formatted}}` requires [Developer Certificate of Origin](https://en.wikipedia.org/wiki/Developer_Certificate_of_Origin) for all contributions. +> `{{ project_name_formatted }}` requires [Developer Certificate of Origin](https://en.wikipedia.org/wiki/Developer_Certificate_of_Origin) for all contributions. > This is enforced by a [Probot GitHub App](https://probot.github.io/apps/dco/), which checks that commits are "signed". > Read [instructions to configure commit signing](Local-Development-Setup#configure-commit-signing). -For **bug reports** or **small feature requests**, please open an issue on our [issues page](https://github.com/{{github}}/{{project_name_formatted}}/issues). +For **bug reports** or **small feature requests**, please open an issue on our [issues page](https://github.com/{{ github }}/{{ project_name_formatted }}/issues). -For **questions** or to discuss **larger changes or features**, please use our [discussions page](https://github.com/{{github}}/{{project_name_formatted}}/discussions). +For **questions** or to discuss **larger changes or features**, please use our [discussions page](https://github.com/{{ github }}/{{ project_name_formatted }}/discussions). For **contributions**, please see our [developer documentation](Local-Development-Setup). We have `help wanted` and `good first issue` tags on our issues page, so these are a great place to start. diff --git a/js/{% if add_wiki %}docs{% endif %}/wiki/contribute/Local-Development-Setup.md.jinja b/js/{% if add_wiki %}docs{% endif %}/wiki/contribute/Local-Development-Setup.md.jinja index 897872a..abf413b 100644 --- a/js/{% if add_wiki %}docs{% endif %}/wiki/contribute/Local-Development-Setup.md.jinja +++ b/js/{% if add_wiki %}docs{% endif %}/wiki/contribute/Local-Development-Setup.md.jinja @@ -10,27 +10,27 @@ ## Step 1: Build from Source -To work on `{{project_name_formatted}}`, you are going to need to build it from source. See +To work on `{{ project_name_formatted }}`, you are going to need to build it from source. See [Build from Source](Build-from-Source) for detailed build instructions. -Once you've built `{{project_name_formatted}}` from a `git` clone, you will also need to -configure `git` and your GitHub account for `{{project_name_formatted}}` development. +Once you've built `{{ project_name_formatted }}` from a `git` clone, you will also need to +configure `git` and your GitHub account for `{{ project_name_formatted }}` development. ## Step 2: Configuring Git and GitHub for Development ### Create your fork -The first step is to create a personal fork of `{{project_name_formatted}}`. To do so, click -the "fork" button at https://github.com/{{github}}/{{project_name_formatted}}, or just navigate -[here](https://github.com/{{github}}/{{project_name_formatted}}/fork) in your browser. Set the +The first step is to create a personal fork of `{{ project_name_formatted }}`. To do so, click +the "fork" button at https://github.com/{{ github }}/{{ project_name_formatted }}, or just navigate +[here](https://github.com/{{ github }}/{{ project_name_formatted }}/fork) in your browser. Set the owner of the repository to your personal GitHub account if it is not already set that way and click "Create fork". ### Configure remotes Next, you should set some names for the `git` remotes corresponding to -main {{github}} repository and your fork. See the [GitHub Docs](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/configuring-a-remote-repository-for-a-fork) for more information. +main {{ github }} repository and your fork. See the [GitHub Docs](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/configuring-a-remote-repository-for-a-fork) for more information. ### Authenticating with GitHub diff --git a/js/{{module}}/tests/test_all.py.jinja b/js/{{module}}/tests/test_all.py.jinja index cd7454a..1ae629a 100644 --- a/js/{{module}}/tests/test_all.py.jinja +++ b/js/{{module}}/tests/test_all.py.jinja @@ -1,4 +1,4 @@ -from {{module}} import * # noqa +from {{ module }} import * # noqa def test_all(): diff --git a/jupyter/.github/CODE_OF_CONDUCT.md.jinja b/jupyter/.github/CODE_OF_CONDUCT.md.jinja index ebc86d7..9eab626 100644 --- a/jupyter/.github/CODE_OF_CONDUCT.md.jinja +++ b/jupyter/.github/CODE_OF_CONDUCT.md.jinja @@ -55,7 +55,7 @@ further defined and clarified by project maintainers. ## Enforcement Instances of abusive, harassing, or otherwise unacceptable behavior may be -reported by contacting the project team at {{email}}. All +reported by contacting the project team at {{ email }}. All complaints will be reviewed and investigated and will result in a response that is deemed necessary and appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. diff --git a/jupyter/.github/workflows/build.yaml.jinja b/jupyter/.github/workflows/build.yaml.jinja index 71fff6c..92c788e 100644 --- a/jupyter/.github/workflows/build.yaml.jinja +++ b/jupyter/.github/workflows/build.yaml.jinja @@ -30,7 +30,7 @@ jobs: strategy: matrix: os: [ubuntu-latest] - python-version: ["{{python_version_primary}}"] + python-version: ["{{ python_version_primary }}"] node-version: [20.x] steps: diff --git a/jupyter/.gitignore.jinja b/jupyter/.gitignore.jinja index 0cf743a..73811ea 100644 --- a/jupyter/.gitignore.jinja +++ b/jupyter/.gitignore.jinja @@ -133,9 +133,9 @@ js/*.tgz .ipynb_checkpoints .autoversion Untitled*.ipynb -{{module}}/extension -{{module}}/nbextension -{{module}}/labextension +{{ module }}/extension +{{ module }}/nbextension +{{ module }}/labextension # Mac .DS_Store diff --git a/jupyter/LICENSE.jinja b/jupyter/LICENSE.jinja index ee2a86d..3d7a96a 100644 --- a/jupyter/LICENSE.jinja +++ b/jupyter/LICENSE.jinja @@ -186,7 +186,7 @@ same "printed page" as the copyright notice for easier identification within third-party archives. - Copyright 2025 {{team}} + Copyright 2025 {{ team }} Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/jupyter/Makefile.jinja b/jupyter/Makefile.jinja index ec0beb0..6e6ff7a 100644 --- a/jupyter/Makefile.jinja +++ b/jupyter/Makefile.jinja @@ -38,8 +38,8 @@ install: ## install python library ######### .PHONY: lint-py lint-js lint-docs lint lints lint-py: ## run python linter with ruff - python -m ruff check {{module}} - python -m ruff format --check {{module}} + python -m ruff check {{ module }} + python -m ruff format --check {{ module }} lint-js: ## run js linter cd js; pnpm lint @@ -55,8 +55,8 @@ lints: lint .PHONY: fix-py fix-js fix-docs fix format fix-py: ## fix python formatting with ruff - python -m ruff check --fix {{module}} - python -m ruff format {{module}} + python -m ruff check --fix {{ module }} + python -m ruff format {{ module }} fix-js: ## fix js formatting cd js; pnpm fix @@ -91,13 +91,13 @@ check: checks ######### .PHONY: test-py tests-py coverage-py test-py: ## run python tests - python -m pytest -v {{module}}/tests + python -m pytest -v {{ module }}/tests # alias tests-py: test-py coverage-py: ## run python tests and collect test coverage - python -m pytest -v {{module}}/tests --cov={{module}} --cov-report term-missing --cov-report xml + python -m pytest -v {{ module }}/tests --cov={{ module }} --cov-report term-missing --cov-report xml .PHONY: test-js tests-js coverage-js test-js: ## run js tests diff --git a/jupyter/README.md.jinja b/jupyter/README.md.jinja index 1fe56c1..156148e 100644 --- a/jupyter/README.md.jinja +++ b/jupyter/README.md.jinja @@ -1,12 +1,12 @@ -# {{project_name}} +# {{ project_name }} -{{project_description}} +{{ project_description }} -[![Build Status](https://github.com/{{github}}/{{project_name_formatted}}/actions/workflows/build.yaml/badge.svg?branch=main&event=push)](https://github.com/{{github}}/{{project_name_formatted}}/actions/workflows/build.yaml) -[![codecov](https://codecov.io/gh/{{github}}/{{project_name_formatted}}/branch/main/graph/badge.svg)](https://codecov.io/gh/{{github}}/{{project_name_formatted}}) -[![License](https://img.shields.io/github/license/{{github}}/{{project_name_formatted}})](https://github.com/{{github}}/{{project_name_formatted}}) -[![PyPI](https://img.shields.io/pypi/v/{{project_name_formatted}}.svg)](https://pypi.python.org/pypi/{{project_name_formatted}}) -[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/{{github}}/{{project_name_formatted}}/main?urlpath=lab) +[![Build Status](https://github.com/{{ github }}/{{ project_name_formatted }}/actions/workflows/build.yaml/badge.svg?branch=main&event=push)](https://github.com/{{ github }}/{{ project_name_formatted }}/actions/workflows/build.yaml) +[![codecov](https://codecov.io/gh/{{ github }}/{{ project_name_formatted }}/branch/main/graph/badge.svg)](https://codecov.io/gh/{{ github }}/{{ project_name_formatted }}) +[![License](https://img.shields.io/github/license/{{ github }}/{{ project_name_formatted }})](https://github.com/{{ github }}/{{ project_name_formatted }}) +[![PyPI](https://img.shields.io/pypi/v/{{ project_name_formatted }}.svg)](https://pypi.python.org/pypi/{{ project_name_formatted }}) +[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/{{ github }}/{{ project_name_formatted }}/main?urlpath=lab) ## Overview diff --git a/jupyter/js/package.json.jinja b/jupyter/js/package.json.jinja index d3f944f..d2683f4 100644 --- a/jupyter/js/package.json.jinja +++ b/jupyter/js/package.json.jinja @@ -1,9 +1,9 @@ { - "name": "{{project_name_formatted}}", + "name": "{{ project_name_formatted }}", "version": "0.1.0", - "description": "{{project_description}}", - "repository": "git@github.com:{{github}}/{{project_name_formatted}}.git", - "author": "{{team}} <{{email}}>", + "description": "{{ project_description }}", + "repository": "git@github.com:{{ github }}/{{ project_name_formatted }}.git", + "author": "{{ team }} <{{ email }}>", "license": "Apache-2.0", "keywords": [ "jupyter", @@ -17,11 +17,11 @@ ], "jupyterlab": { "extension": "lib/index.js", - "outputDir": "../{{module}}/labextension", + "outputDir": "../{{ module }}/labextension", "discovery": { "server": { "base": { - "name": "{{module}}" + "name": "{{ module }}" }, "managers": [ "pip" @@ -31,9 +31,9 @@ }, "scripts": { "build:babel": "babel src/ --source-maps --out-dir lib/", - "build:extension": "mkdirp ../{{module}}/extension/ && cpy --flat 'src/extension/*' '../{{module}}/extension/'", - "build:nbextension": "mkdirp ../{{module}}/nbextension/static/ && cpy --flat 'src/notebook.js' '../{{module}}/nbextension/static/'", - "build:labextension": "rimraf ../{{module}}/labextension && jupyter labextension build .", + "build:extension": "mkdirp ../{{ module }}/extension/ && cpy --flat 'src/extension/*' '../{{ module }}/extension/'", + "build:nbextension": "mkdirp ../{{ module }}/nbextension/static/ && cpy --flat 'src/notebook.js' '../{{ module }}/nbextension/static/'", + "build:labextension": "rimraf ../{{ module }}/labextension && jupyter labextension build .", "build": "pnpm clean && pnpm build:babel && pnpm build:extension && pnpm build:labextension && pnpm build:nbextension", "clean": "rimraf lib", "fix": "pnpm lint --fix", diff --git a/jupyter/js/src/extension/install.json.jinja b/jupyter/js/src/extension/install.json.jinja index 99f0462..5fdbce4 100644 --- a/jupyter/js/src/extension/install.json.jinja +++ b/jupyter/js/src/extension/install.json.jinja @@ -1,5 +1,5 @@ { "packageManager": "python", - "packageName": "{{project_name_formatted}}", - "uninstallInstructions": "Use your Python package manager (pip, conda, etc.) to uninstall the package {{project_name_formatted}}" + "packageName": "{{ project_name_formatted }}", + "uninstallInstructions": "Use your Python package manager (pip, conda, etc.) to uninstall the package {{ project_name_formatted }}" } \ No newline at end of file diff --git a/jupyter/js/src/extension/{{module}}.json.jinja b/jupyter/js/src/extension/{{module}}.json.jinja index 2286256..a5dc761 100644 --- a/jupyter/js/src/extension/{{module}}.json.jinja +++ b/jupyter/js/src/extension/{{module}}.json.jinja @@ -1,7 +1,7 @@ { "ServerApp": { "jpserver_extensions": { - "{{module}}": true + "{{ module }}": true } } } diff --git a/jupyter/js/src/index.js.jinja b/jupyter/js/src/index.js.jinja index 44b4e24..ac18b55 100644 --- a/jupyter/js/src/index.js.jinja +++ b/jupyter/js/src/index.js.jinja @@ -2,13 +2,13 @@ import "../style/index.css"; async function activate(app) { // eslint-disable-next-line no-console - console.log("JupyterLab extension {{project_name_formatted}} is activated!"); + console.log("JupyterLab extension {{ project_name_formatted }} is activated!"); } const extension = { activate, autoStart: true, - id: "{{project_name_formatted}}", + id: "{{ project_name_formatted }}", optional: [], requires: [], }; diff --git a/jupyter/pyproject.toml.jinja b/jupyter/pyproject.toml.jinja index 503f153..a4dfe75 100644 --- a/jupyter/pyproject.toml.jinja +++ b/jupyter/pyproject.toml.jinja @@ -7,11 +7,11 @@ requires = [ build-backend = "hatchling.build" [project] -name = "{{project_name_formatted}}" +name = "{{ project_name_formatted }}" authors = [ - {name = "{{team}}", email = "{{email}}"}, + {name = "{{ team }}", email = "{{ email }}"}, ] -description = "{{project_description}}" +description = "{{ project_description }}" readme = "README.md" license = { text = "Apache-2.0" } version = "0.1.0" @@ -61,8 +61,8 @@ develop = [ [project.scripts] [project.urls] -Repository = "https://github.com/{{github}}/{{project_name_formatted}}" -Homepage = "https://github.com/{{github}}/{{project_name_formatted}}" +Repository = "https://github.com/{{ github }}/{{ project_name_formatted }}" +Homepage = "https://github.com/{{ github }}/{{ project_name_formatted }}" [tool.bumpversion] current_version = "0.1.0" @@ -71,7 +71,7 @@ tag = true commit_args = "-s" [[tool.bumpversion.files]] -filename = "{{module}}/__init__.py" +filename = "{{ module }}/__init__.py" search = '__version__ = "{current_version}"' replace = '__version__ = "{new_version}"' @@ -88,7 +88,7 @@ replace = '"version": "{new_version}"' [tool.coverage.run] branch = true omit = [ - "{{module}}/tests/integration/", + "{{ module }}/tests/integration/", ] [tool.coverage.report] @@ -102,8 +102,8 @@ fail_under = 50 [tool.hatch.build] artifacts = [ - "{{module}}/nbextension", - "{{module}}/labextension", + "{{ module }}/nbextension", + "{{ module }}/labextension", ] [tool.hatch.build.sources] @@ -111,7 +111,7 @@ src = "/" [tool.hatch.build.targets.sdist] packages = [ - "{{module}}", + "{{ module }}", "js", ] exclude = [ @@ -121,24 +121,24 @@ exclude = [ [tool.hatch.build.targets.wheel] packages = [ - "{{module}}", + "{{ module }}", ] exclude = [ "js" ] [tool.hatch.build.targets.wheel.shared-data] -"{{module}}/labextension" = "share/jupyter/labextensions/{{project_name_formatted}}" -"{{module}}/extension/install.json" = "share/jupyter/labextensions/{{project_name_formatted}}/install.json" -"{{module}}/extension/{{module}}.json" = "etc/jupyter/jupyter_server_config.d/{{module}}.json" +"{{ module }}/labextension" = "share/jupyter/labextensions/{{ project_name_formatted }}" +"{{ module }}/extension/install.json" = "share/jupyter/labextensions/{{ project_name_formatted }}/install.json" +"{{ module }}/extension/{{ module }}.json" = "etc/jupyter/jupyter_server_config.d/{{ module }}.json" [tool.hatch.build.hooks.hatch-js] path = "js" build_cmd = "build" tool = "pnpm" targets = [ - "{{module}}/nbextension/static/notebook.js", - "{{module}}/labextension/package.json", + "{{ module }}/nbextension/static/notebook.js", + "{{ module }}/labextension/package.json", ] [tool.pytest.ini_options] @@ -146,7 +146,7 @@ addopts = [ "-vvv", "--junitxml=junit.xml", ] -testpaths = "{{module}}/tests" +testpaths = "{{ module }}/tests" [tool.ruff] line-length = 150 @@ -160,7 +160,7 @@ extend-select = [ combine-as-imports = true default-section = "third-party" known-first-party = [ - "{{module}}", + "{{ module }}", ] section-order = [ "future", diff --git a/jupyter/{% if add_wiki %}docs{% endif %}/wiki/Installation.md.jinja b/jupyter/{% if add_wiki %}docs{% endif %}/wiki/Installation.md.jinja index 8dfc880..89b2612 100644 --- a/jupyter/{% if add_wiki %}docs{% endif %}/wiki/Installation.md.jinja +++ b/jupyter/{% if add_wiki %}docs{% endif %}/wiki/Installation.md.jinja @@ -1,19 +1,19 @@ ## Pre-requisites -You need Python >=3.10 on your machine to install `{{project_name_formatted}}`. +You need Python >=3.10 on your machine to install `{{ project_name_formatted }}`. ## Install with `pip` ```bash -pip install {{project_name_formatted}} +pip install {{ project_name_formatted }} ``` ## Install with `conda` ```bash -conda install {{project_name_formatted}} --channel conda-forge +conda install {{ project_name_formatted }} --channel conda-forge ``` ## Source installation -For other platforms and for development installations, [build `{{project_name_formatted}}` from source](Build-from-Source). +For other platforms and for development installations, [build `{{ project_name_formatted }}` from source](Build-from-Source). diff --git a/jupyter/{% if add_wiki %}docs{% endif %}/wiki/_Footer.md.jinja b/jupyter/{% if add_wiki %}docs{% endif %}/wiki/_Footer.md.jinja index 4a5fb4b..bd81a19 100644 --- a/jupyter/{% if add_wiki %}docs{% endif %}/wiki/_Footer.md.jinja +++ b/jupyter/{% if add_wiki %}docs{% endif %}/wiki/_Footer.md.jinja @@ -1 +1 @@ -_This wiki is autogenerated. To made updates, open a PR against the original source file in [`docs/wiki`](https://github.com/{{github}}/{{project_name_formatted}}/tree/main/docs/wiki)._ +_This wiki is autogenerated. To made updates, open a PR against the original source file in [`docs/wiki`](https://github.com/{{ github }}/{{ project_name_formatted }}/tree/main/docs/wiki)._ diff --git a/jupyter/{% if add_wiki %}docs{% endif %}/wiki/contribute/Build-from-Source.md.jinja b/jupyter/{% if add_wiki %}docs{% endif %}/wiki/contribute/Build-from-Source.md.jinja index 7431b53..eb55769 100644 --- a/jupyter/{% if add_wiki %}docs{% endif %}/wiki/contribute/Build-from-Source.md.jinja +++ b/jupyter/{% if add_wiki %}docs{% endif %}/wiki/contribute/Build-from-Source.md.jinja @@ -1,4 +1,4 @@ -`{{project_name_formatted}}` is written in Python and JavaScript. While prebuilt wheels are provided for end users, it is also straightforward to build `{{project_name_formatted}}` from either the Python [source distribution](https://packaging.python.org/en/latest/specifications/source-distribution-format/) or the GitHub repository. +`{{ project_name_formatted }}` is written in Python and JavaScript. While prebuilt wheels are provided for end users, it is also straightforward to build `{{ project_name_formatted }}` from either the Python [source distribution](https://packaging.python.org/en/latest/specifications/source-distribution-format/) or the GitHub repository. - [Make commands](#make-commands) - [Prerequisites](#prerequisites) @@ -10,7 +10,7 @@ ## Make commands -As a convenience, `{{project_name_formatted}}` uses a `Makefile` for commonly used commands. You can print the main available commands by running `make` with no arguments +As a convenience, `{{ project_name_formatted }}` uses a `Makefile` for commonly used commands. You can print the main available commands by running `make` with no arguments ```bash > make @@ -25,15 +25,15 @@ test run the tests ## Prerequisites -`{{project_name_formatted}}` has a few system-level dependencies which you can install from your machine package manager. Other package managers like `conda`, `nix`, etc, should also work fine. +`{{ project_name_formatted }}` has a few system-level dependencies which you can install from your machine package manager. Other package managers like `conda`, `nix`, etc, should also work fine. ## Clone Clone the repo with: ```bash -git clone https://github.com/{{github}}/{{project_name_formatted}}.git -cd {{project_name_formatted}} +git clone https://github.com/{{ github }}/{{ project_name_formatted }}.git +cd {{ project_name_formatted }} ``` ## Install NodeJS @@ -64,7 +64,7 @@ make build ## Lint and Autoformat -`{{project_name_formatted}}` has linting and auto formatting. +`{{ project_name_formatted }}` has linting and auto formatting. | Language | Linter | Autoformatter | Description | | :--------- | :---------- | :------------ | :---------- | @@ -112,7 +112,7 @@ make fix-docs ## Testing -`{{project_name_formatted}}` has both Python and JavaScript tests. The bulk of the functionality is tested in Python, which can be run via `pytest`. First, install the Python development dependencies with +`{{ project_name_formatted }}` has both Python and JavaScript tests. The bulk of the functionality is tested in Python, which can be run via `pytest`. First, install the Python development dependencies with ```bash make develop diff --git a/jupyter/{% if add_wiki %}docs{% endif %}/wiki/contribute/Contribute.md.jinja b/jupyter/{% if add_wiki %}docs{% endif %}/wiki/contribute/Contribute.md.jinja index 7deea95..463b117 100644 --- a/jupyter/{% if add_wiki %}docs{% endif %}/wiki/contribute/Contribute.md.jinja +++ b/jupyter/{% if add_wiki %}docs{% endif %}/wiki/contribute/Contribute.md.jinja @@ -1,14 +1,14 @@ -Contributions are welcome on this project. We distribute under the terms of the [Apache 2.0 license](https://github.com/{{github}}/{{project_name_formatted}}/blob/main/LICENSE). +Contributions are welcome on this project. We distribute under the terms of the [Apache 2.0 license](https://github.com/{{ github }}/{{ project_name_formatted }}/blob/main/LICENSE). > [!NOTE] > -> `{{project_name_formatted}}` requires [Developer Certificate of Origin](https://en.wikipedia.org/wiki/Developer_Certificate_of_Origin) for all contributions. +> `{{ project_name_formatted }}` requires [Developer Certificate of Origin](https://en.wikipedia.org/wiki/Developer_Certificate_of_Origin) for all contributions. > This is enforced by a [Probot GitHub App](https://probot.github.io/apps/dco/), which checks that commits are "signed". > Read [instructions to configure commit signing](Local-Development-Setup#configure-commit-signing). -For **bug reports** or **small feature requests**, please open an issue on our [issues page](https://github.com/{{github}}/{{project_name_formatted}}/issues). +For **bug reports** or **small feature requests**, please open an issue on our [issues page](https://github.com/{{ github }}/{{ project_name_formatted }}/issues). -For **questions** or to discuss **larger changes or features**, please use our [discussions page](https://github.com/{{github}}/{{project_name_formatted}}/discussions). +For **questions** or to discuss **larger changes or features**, please use our [discussions page](https://github.com/{{ github }}/{{ project_name_formatted }}/discussions). For **contributions**, please see our [developer documentation](Local-Development-Setup). We have `help wanted` and `good first issue` tags on our issues page, so these are a great place to start. diff --git a/jupyter/{% if add_wiki %}docs{% endif %}/wiki/contribute/Local-Development-Setup.md.jinja b/jupyter/{% if add_wiki %}docs{% endif %}/wiki/contribute/Local-Development-Setup.md.jinja index 897872a..abf413b 100644 --- a/jupyter/{% if add_wiki %}docs{% endif %}/wiki/contribute/Local-Development-Setup.md.jinja +++ b/jupyter/{% if add_wiki %}docs{% endif %}/wiki/contribute/Local-Development-Setup.md.jinja @@ -10,27 +10,27 @@ ## Step 1: Build from Source -To work on `{{project_name_formatted}}`, you are going to need to build it from source. See +To work on `{{ project_name_formatted }}`, you are going to need to build it from source. See [Build from Source](Build-from-Source) for detailed build instructions. -Once you've built `{{project_name_formatted}}` from a `git` clone, you will also need to -configure `git` and your GitHub account for `{{project_name_formatted}}` development. +Once you've built `{{ project_name_formatted }}` from a `git` clone, you will also need to +configure `git` and your GitHub account for `{{ project_name_formatted }}` development. ## Step 2: Configuring Git and GitHub for Development ### Create your fork -The first step is to create a personal fork of `{{project_name_formatted}}`. To do so, click -the "fork" button at https://github.com/{{github}}/{{project_name_formatted}}, or just navigate -[here](https://github.com/{{github}}/{{project_name_formatted}}/fork) in your browser. Set the +The first step is to create a personal fork of `{{ project_name_formatted }}`. To do so, click +the "fork" button at https://github.com/{{ github }}/{{ project_name_formatted }}, or just navigate +[here](https://github.com/{{ github }}/{{ project_name_formatted }}/fork) in your browser. Set the owner of the repository to your personal GitHub account if it is not already set that way and click "Create fork". ### Configure remotes Next, you should set some names for the `git` remotes corresponding to -main {{github}} repository and your fork. See the [GitHub Docs](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/configuring-a-remote-repository-for-a-fork) for more information. +main {{ github }} repository and your fork. See the [GitHub Docs](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/configuring-a-remote-repository-for-a-fork) for more information. ### Authenticating with GitHub diff --git a/jupyter/{{module}}/__init__.py.jinja b/jupyter/{{module}}/__init__.py.jinja index a8ad75c..2588bea 100644 --- a/jupyter/{{module}}/__init__.py.jinja +++ b/jupyter/{{module}}/__init__.py.jinja @@ -2,11 +2,11 @@ __version__ = "0.1.0" def _jupyter_server_extension_paths(): - return [{"module": "{{module}}"}] + return [{"module": "{{ module }}"}] def _jupyter_server_extension_points(): - return [{"module": "{{module}}"}] + return [{"module": "{{ module }}"}] def _load_jupyter_server_extension(nb_server_app, nb6_entrypoint=False): @@ -24,7 +24,7 @@ def _jupyter_nbextension_paths(): { "section": "tree", "src": "nbextension/static", - "dest": "{{module}}", - "require": "{{module}}/notebook", + "dest": "{{ module }}", + "require": "{{ module }}/notebook", } ] diff --git a/jupyter/{{module}}/tests/test_all.py.jinja b/jupyter/{{module}}/tests/test_all.py.jinja index cd7454a..1ae629a 100644 --- a/jupyter/{{module}}/tests/test_all.py.jinja +++ b/jupyter/{{module}}/tests/test_all.py.jinja @@ -1,4 +1,4 @@ -from {{module}} import * # noqa +from {{ module }} import * # noqa def test_all(): diff --git a/python/.github/CODE_OF_CONDUCT.md.jinja b/python/.github/CODE_OF_CONDUCT.md.jinja index ebc86d7..9eab626 100644 --- a/python/.github/CODE_OF_CONDUCT.md.jinja +++ b/python/.github/CODE_OF_CONDUCT.md.jinja @@ -55,7 +55,7 @@ further defined and clarified by project maintainers. ## Enforcement Instances of abusive, harassing, or otherwise unacceptable behavior may be -reported by contacting the project team at {{email}}. All +reported by contacting the project team at {{ email }}. All complaints will be reviewed and investigated and will result in a response that is deemed necessary and appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. diff --git a/python/.github/workflows/build.yaml.jinja b/python/.github/workflows/build.yaml.jinja index 80cd46f..13fca42 100644 --- a/python/.github/workflows/build.yaml.jinja +++ b/python/.github/workflows/build.yaml.jinja @@ -30,7 +30,7 @@ jobs: strategy: matrix: os: [ubuntu-latest] - python-version: ["{{python_version_primary}}"] + python-version: ["{{ python_version_primary }}"] steps: - uses: actions/checkout@v6 diff --git a/python/.gitignore.jinja b/python/.gitignore.jinja index 0cf743a..73811ea 100644 --- a/python/.gitignore.jinja +++ b/python/.gitignore.jinja @@ -133,9 +133,9 @@ js/*.tgz .ipynb_checkpoints .autoversion Untitled*.ipynb -{{module}}/extension -{{module}}/nbextension -{{module}}/labextension +{{ module }}/extension +{{ module }}/nbextension +{{ module }}/labextension # Mac .DS_Store diff --git a/python/LICENSE.jinja b/python/LICENSE.jinja index ee2a86d..3d7a96a 100644 --- a/python/LICENSE.jinja +++ b/python/LICENSE.jinja @@ -186,7 +186,7 @@ same "printed page" as the copyright notice for easier identification within third-party archives. - Copyright 2025 {{team}} + Copyright 2025 {{ team }} Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/python/Makefile.jinja b/python/Makefile.jinja index 7e0860b..699682c 100644 --- a/python/Makefile.jinja +++ b/python/Makefile.jinja @@ -23,16 +23,16 @@ install: ## install library .PHONY: lint-py lint-docs fix-py fix-docs lint lints fix format lint-py: ## lint python with ruff - python -m ruff check {{module}} - python -m ruff format --check {{module}} + python -m ruff check {{ module }} + python -m ruff format --check {{ module }} lint-docs: ## lint docs with mdformat and codespell python -m mdformat --check README.md {% if add_wiki %}docs/wiki/{% endif %} python -m codespell_lib README.md {% if add_wiki %}docs/wiki/{% endif %} fix-py: ## autoformat python code with ruff - python -m ruff check --fix {{module}} - python -m ruff format {{module}} + python -m ruff check --fix {{ module }} + python -m ruff format {{ module }} fix-docs: ## autoformat docs with mdformat and codespell python -m mdformat README.md {% if add_wiki %}docs/wiki/{% endif %} @@ -65,10 +65,10 @@ check: checks .PHONY: test coverage tests test: ## run python tests - python -m pytest -v {{module}}/tests + python -m pytest -v {{ module }}/tests coverage: ## run tests and collect test coverage - python -m pytest -v {{module}}/tests --cov={{module}} --cov-report term-missing --cov-report xml + python -m pytest -v {{ module }}/tests --cov={{ module }} --cov-report term-missing --cov-report xml # Alias tests: test diff --git a/python/README.md.jinja b/python/README.md.jinja index d8ce83b..7e11b1c 100644 --- a/python/README.md.jinja +++ b/python/README.md.jinja @@ -1,11 +1,11 @@ -# {{project_name}} +# {{ project_name }} -{{project_description}} +{{ project_description }} -[![Build Status](https://github.com/{{github}}/{{project_name_formatted}}/actions/workflows/build.yaml/badge.svg?branch=main&event=push)](https://github.com/{{github}}/{{project_name_formatted}}/actions/workflows/build.yaml) -[![codecov](https://codecov.io/gh/{{github}}/{{project_name_formatted}}/branch/main/graph/badge.svg)](https://codecov.io/gh/{{github}}/{{project_name_formatted}}) -[![License](https://img.shields.io/github/license/{{github}}/{{project_name_formatted}})](https://github.com/{{github}}/{{project_name_formatted}}) -[![PyPI](https://img.shields.io/pypi/v/{{project_name_formatted}}.svg)](https://pypi.python.org/pypi/{{project_name_formatted}}) +[![Build Status](https://github.com/{{ github }}/{{ project_name_formatted }}/actions/workflows/build.yaml/badge.svg?branch=main&event=push)](https://github.com/{{ github }}/{{ project_name_formatted }}/actions/workflows/build.yaml) +[![codecov](https://codecov.io/gh/{{ github }}/{{ project_name_formatted }}/branch/main/graph/badge.svg)](https://codecov.io/gh/{{ github }}/{{ project_name_formatted }}) +[![License](https://img.shields.io/github/license/{{ github }}/{{ project_name_formatted }})](https://github.com/{{ github }}/{{ project_name_formatted }}) +[![PyPI](https://img.shields.io/pypi/v/{{ project_name_formatted }}.svg)](https://pypi.python.org/pypi/{{ project_name_formatted }}) ## Overview diff --git a/python/pyproject.toml.jinja b/python/pyproject.toml.jinja index 6332fb2..e114d4d 100644 --- a/python/pyproject.toml.jinja +++ b/python/pyproject.toml.jinja @@ -5,11 +5,11 @@ requires = [ build-backend = "hatchling.build" [project] -name = "{{project_name_formatted}}" +name = "{{ project_name_formatted }}" authors = [ - {name = "{{team}}", email = "{{email}}"}, + {name = "{{ team }}", email = "{{ email }}"}, ] -description = "{{project_description}}" +description = "{{ project_description }}" readme = "README.md" license = { text = "Apache-2.0" } version = "0.1.0" @@ -52,8 +52,8 @@ develop = [ [project.scripts] [project.urls] -Repository = "https://github.com/{{github}}/{{project_name_formatted}}" -Homepage = "https://github.com/{{github}}/{{project_name_formatted}}" +Repository = "https://github.com/{{ github }}/{{ project_name_formatted }}" +Homepage = "https://github.com/{{ github }}/{{ project_name_formatted }}" [tool.bumpversion] current_version = "0.1.0" @@ -62,7 +62,7 @@ tag = true commit_args = "-s" [[tool.bumpversion.files]] -filename = "{{module}}/__init__.py" +filename = "{{ module }}/__init__.py" search = '__version__ = "{current_version}"' replace = '__version__ = "{new_version}"' @@ -74,7 +74,7 @@ replace = 'version = "{new_version}"' [tool.coverage.run] branch = true omit = [ - "{{module}}/tests/integration/", + "{{ module }}/tests/integration/", ] [tool.coverage.report] @@ -94,12 +94,12 @@ src = "/" [tool.hatch.build.targets.sdist] packages = [ - "{{module}}", + "{{ module }}", ] [tool.hatch.build.targets.wheel] packages = [ - "{{module}}", + "{{ module }}", ] [tool.hatch.build.targets.wheel.shared-data] @@ -109,7 +109,7 @@ addopts = [ "-vvv", "--junitxml=junit.xml", ] -testpaths = "{{module}}/tests" +testpaths = "{{ module }}/tests" [tool.ruff] line-length = 150 @@ -123,7 +123,7 @@ extend-select = [ combine-as-imports = true default-section = "third-party" known-first-party = [ - "{{module}}", + "{{ module }}", ] section-order = [ "future", diff --git a/python/{% if add_wiki %}docs{% endif %}/wiki/Installation.md.jinja b/python/{% if add_wiki %}docs{% endif %}/wiki/Installation.md.jinja index 8dfc880..89b2612 100644 --- a/python/{% if add_wiki %}docs{% endif %}/wiki/Installation.md.jinja +++ b/python/{% if add_wiki %}docs{% endif %}/wiki/Installation.md.jinja @@ -1,19 +1,19 @@ ## Pre-requisites -You need Python >=3.10 on your machine to install `{{project_name_formatted}}`. +You need Python >=3.10 on your machine to install `{{ project_name_formatted }}`. ## Install with `pip` ```bash -pip install {{project_name_formatted}} +pip install {{ project_name_formatted }} ``` ## Install with `conda` ```bash -conda install {{project_name_formatted}} --channel conda-forge +conda install {{ project_name_formatted }} --channel conda-forge ``` ## Source installation -For other platforms and for development installations, [build `{{project_name_formatted}}` from source](Build-from-Source). +For other platforms and for development installations, [build `{{ project_name_formatted }}` from source](Build-from-Source). diff --git a/python/{% if add_wiki %}docs{% endif %}/wiki/_Footer.md.jinja b/python/{% if add_wiki %}docs{% endif %}/wiki/_Footer.md.jinja index 4a5fb4b..bd81a19 100644 --- a/python/{% if add_wiki %}docs{% endif %}/wiki/_Footer.md.jinja +++ b/python/{% if add_wiki %}docs{% endif %}/wiki/_Footer.md.jinja @@ -1 +1 @@ -_This wiki is autogenerated. To made updates, open a PR against the original source file in [`docs/wiki`](https://github.com/{{github}}/{{project_name_formatted}}/tree/main/docs/wiki)._ +_This wiki is autogenerated. To made updates, open a PR against the original source file in [`docs/wiki`](https://github.com/{{ github }}/{{ project_name_formatted }}/tree/main/docs/wiki)._ diff --git a/python/{% if add_wiki %}docs{% endif %}/wiki/contribute/Build-from-Source.md.jinja b/python/{% if add_wiki %}docs{% endif %}/wiki/contribute/Build-from-Source.md.jinja index ff2651e..d1afac6 100644 --- a/python/{% if add_wiki %}docs{% endif %}/wiki/contribute/Build-from-Source.md.jinja +++ b/python/{% if add_wiki %}docs{% endif %}/wiki/contribute/Build-from-Source.md.jinja @@ -1,4 +1,4 @@ -`{{project_name_formatted}}` is written in Python. While prebuilt wheels are provided for end users, it is also straightforward to build `{{project_name_formatted}}` from either the Python [source distribution](https://packaging.python.org/en/latest/specifications/source-distribution-format/) or the GitHub repository. +`{{ project_name_formatted }}` is written in Python. While prebuilt wheels are provided for end users, it is also straightforward to build `{{ project_name_formatted }}` from either the Python [source distribution](https://packaging.python.org/en/latest/specifications/source-distribution-format/) or the GitHub repository. - [Make commands](#make-commands) - [Prerequisites](#prerequisites) @@ -10,7 +10,7 @@ ## Make commands -As a convenience, `{{project_name_formatted}}` uses a `Makefile` for commonly used commands. You can print the main available commands by running `make` with no arguments +As a convenience, `{{ project_name_formatted }}` uses a `Makefile` for commonly used commands. You can print the main available commands by running `make` with no arguments ```bash > make @@ -25,15 +25,15 @@ test run the tests ## Prerequisites -`{{project_name_formatted}}` has a few system-level dependencies which you can install from your machine package manager. Other package managers like `conda`, `nix`, etc, should also work fine. +`{{ project_name_formatted }}` has a few system-level dependencies which you can install from your machine package manager. Other package managers like `conda`, `nix`, etc, should also work fine. ## Clone Clone the repo with: ```bash -git clone https://github.com/{{github}}/{{project_name_formatted}}.git -cd {{project_name_formatted}} +git clone https://github.com/{{ github }}/{{ project_name_formatted }}.git +cd {{ project_name_formatted }} ``` ## Install Python dependencies @@ -56,7 +56,7 @@ make build ## Lint and Autoformat -`{{project_name_formatted}}` has linting and auto formatting. +`{{ project_name_formatted }}` has linting and auto formatting. | Language | Linter | Autoformatter | Description | | :------- | :---------- | :------------ | :---------- | @@ -90,7 +90,7 @@ make fix-docs ## Testing -`{{project_name_formatted}}` has extensive Python tests. The tests can be run via `pytest`. First, install the Python development dependencies with +`{{ project_name_formatted }}` has extensive Python tests. The tests can be run via `pytest`. First, install the Python development dependencies with ```bash make develop diff --git a/python/{% if add_wiki %}docs{% endif %}/wiki/contribute/Contribute.md.jinja b/python/{% if add_wiki %}docs{% endif %}/wiki/contribute/Contribute.md.jinja index 7deea95..463b117 100644 --- a/python/{% if add_wiki %}docs{% endif %}/wiki/contribute/Contribute.md.jinja +++ b/python/{% if add_wiki %}docs{% endif %}/wiki/contribute/Contribute.md.jinja @@ -1,14 +1,14 @@ -Contributions are welcome on this project. We distribute under the terms of the [Apache 2.0 license](https://github.com/{{github}}/{{project_name_formatted}}/blob/main/LICENSE). +Contributions are welcome on this project. We distribute under the terms of the [Apache 2.0 license](https://github.com/{{ github }}/{{ project_name_formatted }}/blob/main/LICENSE). > [!NOTE] > -> `{{project_name_formatted}}` requires [Developer Certificate of Origin](https://en.wikipedia.org/wiki/Developer_Certificate_of_Origin) for all contributions. +> `{{ project_name_formatted }}` requires [Developer Certificate of Origin](https://en.wikipedia.org/wiki/Developer_Certificate_of_Origin) for all contributions. > This is enforced by a [Probot GitHub App](https://probot.github.io/apps/dco/), which checks that commits are "signed". > Read [instructions to configure commit signing](Local-Development-Setup#configure-commit-signing). -For **bug reports** or **small feature requests**, please open an issue on our [issues page](https://github.com/{{github}}/{{project_name_formatted}}/issues). +For **bug reports** or **small feature requests**, please open an issue on our [issues page](https://github.com/{{ github }}/{{ project_name_formatted }}/issues). -For **questions** or to discuss **larger changes or features**, please use our [discussions page](https://github.com/{{github}}/{{project_name_formatted}}/discussions). +For **questions** or to discuss **larger changes or features**, please use our [discussions page](https://github.com/{{ github }}/{{ project_name_formatted }}/discussions). For **contributions**, please see our [developer documentation](Local-Development-Setup). We have `help wanted` and `good first issue` tags on our issues page, so these are a great place to start. diff --git a/python/{% if add_wiki %}docs{% endif %}/wiki/contribute/Local-Development-Setup.md.jinja b/python/{% if add_wiki %}docs{% endif %}/wiki/contribute/Local-Development-Setup.md.jinja index 897872a..abf413b 100644 --- a/python/{% if add_wiki %}docs{% endif %}/wiki/contribute/Local-Development-Setup.md.jinja +++ b/python/{% if add_wiki %}docs{% endif %}/wiki/contribute/Local-Development-Setup.md.jinja @@ -10,27 +10,27 @@ ## Step 1: Build from Source -To work on `{{project_name_formatted}}`, you are going to need to build it from source. See +To work on `{{ project_name_formatted }}`, you are going to need to build it from source. See [Build from Source](Build-from-Source) for detailed build instructions. -Once you've built `{{project_name_formatted}}` from a `git` clone, you will also need to -configure `git` and your GitHub account for `{{project_name_formatted}}` development. +Once you've built `{{ project_name_formatted }}` from a `git` clone, you will also need to +configure `git` and your GitHub account for `{{ project_name_formatted }}` development. ## Step 2: Configuring Git and GitHub for Development ### Create your fork -The first step is to create a personal fork of `{{project_name_formatted}}`. To do so, click -the "fork" button at https://github.com/{{github}}/{{project_name_formatted}}, or just navigate -[here](https://github.com/{{github}}/{{project_name_formatted}}/fork) in your browser. Set the +The first step is to create a personal fork of `{{ project_name_formatted }}`. To do so, click +the "fork" button at https://github.com/{{ github }}/{{ project_name_formatted }}, or just navigate +[here](https://github.com/{{ github }}/{{ project_name_formatted }}/fork) in your browser. Set the owner of the repository to your personal GitHub account if it is not already set that way and click "Create fork". ### Configure remotes Next, you should set some names for the `git` remotes corresponding to -main {{github}} repository and your fork. See the [GitHub Docs](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/configuring-a-remote-repository-for-a-fork) for more information. +main {{ github }} repository and your fork. See the [GitHub Docs](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/configuring-a-remote-repository-for-a-fork) for more information. ### Authenticating with GitHub diff --git a/python/{{module}}/tests/test_all.py.jinja b/python/{{module}}/tests/test_all.py.jinja index cd7454a..1ae629a 100644 --- a/python/{{module}}/tests/test_all.py.jinja +++ b/python/{{module}}/tests/test_all.py.jinja @@ -1,4 +1,4 @@ -from {{module}} import * # noqa +from {{ module }} import * # noqa def test_all(): diff --git a/rust/.github/CODE_OF_CONDUCT.md.jinja b/rust/.github/CODE_OF_CONDUCT.md.jinja index ebc86d7..9eab626 100644 --- a/rust/.github/CODE_OF_CONDUCT.md.jinja +++ b/rust/.github/CODE_OF_CONDUCT.md.jinja @@ -55,7 +55,7 @@ further defined and clarified by project maintainers. ## Enforcement Instances of abusive, harassing, or otherwise unacceptable behavior may be -reported by contacting the project team at {{email}}. All +reported by contacting the project team at {{ email }}. All complaints will be reviewed and investigated and will result in a response that is deemed necessary and appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. diff --git a/rust/.github/workflows/build.yaml.jinja b/rust/.github/workflows/build.yaml.jinja index f26b18a..fddb7ce 100644 --- a/rust/.github/workflows/build.yaml.jinja +++ b/rust/.github/workflows/build.yaml.jinja @@ -30,7 +30,7 @@ jobs: strategy: matrix: os: [ubuntu-latest, macos-latest, windows-latest] - python-version: ["{{python_version_primary}}"] + python-version: ["{{ python_version_primary }}"] steps: - uses: actions/checkout@v6 diff --git a/rust/.gitignore.jinja b/rust/.gitignore.jinja index 0cf743a..73811ea 100644 --- a/rust/.gitignore.jinja +++ b/rust/.gitignore.jinja @@ -133,9 +133,9 @@ js/*.tgz .ipynb_checkpoints .autoversion Untitled*.ipynb -{{module}}/extension -{{module}}/nbextension -{{module}}/labextension +{{ module }}/extension +{{ module }}/nbextension +{{ module }}/labextension # Mac .DS_Store diff --git a/rust/Cargo.toml.jinja b/rust/Cargo.toml.jinja index 67886e8..780d5cd 100644 --- a/rust/Cargo.toml.jinja +++ b/rust/Cargo.toml.jinja @@ -1,16 +1,16 @@ [package] -name = "{{module}}_py" +name = "{{ module }}_py" version = "0.1.0" edition = "2021" publish = false [lib] -name = "{{module}}" +name = "{{ module }}" path = "rust/python/lib.rs" crate-type = ["cdylib"] [dependencies] -{{module}} = { path = "./rust", version = "*" } +{{ module }} = { path = "./rust", version = "*" } pyo3 = { version = "0.28.2", features = ["abi3", "extension-module", "multiple-pymethods"] } [profile.release] diff --git a/rust/LICENSE.jinja b/rust/LICENSE.jinja index ee2a86d..3d7a96a 100644 --- a/rust/LICENSE.jinja +++ b/rust/LICENSE.jinja @@ -186,7 +186,7 @@ same "printed page" as the copyright notice for easier identification within third-party archives. - Copyright 2025 {{team}} + Copyright 2025 {{ team }} Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/rust/Makefile.jinja b/rust/Makefile.jinja index f577583..9d658da 100644 --- a/rust/Makefile.jinja +++ b/rust/Makefile.jinja @@ -39,8 +39,8 @@ install: ## install python library ######### .PHONY: lint-py lint-rs lint-docs lint lints lint-py: ## run python linter with ruff - python -m ruff check {{module}} - python -m ruff format --check {{module}} + python -m ruff check {{ module }} + python -m ruff format --check {{ module }} lint-rs: ## run rust linter make -C rust lint @@ -56,8 +56,8 @@ lints: lint .PHONY: fix-py fix-rs fix-docs fix format fix-py: ## fix python formatting with ruff - python -m ruff check --fix {{module}} - python -m ruff format {{module}} + python -m ruff check --fix {{ module }} + python -m ruff format {{ module }} fix-rs: ## fix rust formatting make -C rust fix @@ -92,13 +92,13 @@ check: checks ######### .PHONY: test-py tests-py coverage-py test-py: ## run python tests - python -m pytest -v {{module}}/tests + python -m pytest -v {{ module }}/tests # alias tests-py: test-py coverage-py: ## run python tests and collect test coverage - python -m pytest -v {{module}}/tests --cov={{module}} --cov-report term-missing --cov-report xml + python -m pytest -v {{ module }}/tests --cov={{ module }} --cov-report term-missing --cov-report xml .PHONY: test-rs tests-rs coverage-rs test-rs: ## run rust tests diff --git a/rust/README.md.jinja b/rust/README.md.jinja index d8ce83b..7e11b1c 100644 --- a/rust/README.md.jinja +++ b/rust/README.md.jinja @@ -1,11 +1,11 @@ -# {{project_name}} +# {{ project_name }} -{{project_description}} +{{ project_description }} -[![Build Status](https://github.com/{{github}}/{{project_name_formatted}}/actions/workflows/build.yaml/badge.svg?branch=main&event=push)](https://github.com/{{github}}/{{project_name_formatted}}/actions/workflows/build.yaml) -[![codecov](https://codecov.io/gh/{{github}}/{{project_name_formatted}}/branch/main/graph/badge.svg)](https://codecov.io/gh/{{github}}/{{project_name_formatted}}) -[![License](https://img.shields.io/github/license/{{github}}/{{project_name_formatted}})](https://github.com/{{github}}/{{project_name_formatted}}) -[![PyPI](https://img.shields.io/pypi/v/{{project_name_formatted}}.svg)](https://pypi.python.org/pypi/{{project_name_formatted}}) +[![Build Status](https://github.com/{{ github }}/{{ project_name_formatted }}/actions/workflows/build.yaml/badge.svg?branch=main&event=push)](https://github.com/{{ github }}/{{ project_name_formatted }}/actions/workflows/build.yaml) +[![codecov](https://codecov.io/gh/{{ github }}/{{ project_name_formatted }}/branch/main/graph/badge.svg)](https://codecov.io/gh/{{ github }}/{{ project_name_formatted }}) +[![License](https://img.shields.io/github/license/{{ github }}/{{ project_name_formatted }})](https://github.com/{{ github }}/{{ project_name_formatted }}) +[![PyPI](https://img.shields.io/pypi/v/{{ project_name_formatted }}.svg)](https://pypi.python.org/pypi/{{ project_name_formatted }}) ## Overview diff --git a/rust/pyproject.toml.jinja b/rust/pyproject.toml.jinja index 95823b1..5b4305d 100644 --- a/rust/pyproject.toml.jinja +++ b/rust/pyproject.toml.jinja @@ -6,11 +6,11 @@ requires = [ build-backend = "hatchling.build" [project] -name = "{{project_name_formatted}}" +name = "{{ project_name_formatted }}" authors = [ - {name = "{{team}}", email = "{{email}}"}, + {name = "{{ team }}", email = "{{ email }}"}, ] -description = "{{project_description}}" +description = "{{ project_description }}" readme = "README.md" license = { text = "Apache-2.0" } version = "0.1.0" @@ -56,8 +56,8 @@ develop = [ [project.scripts] [project.urls] -Repository = "https://github.com/{{github}}/{{project_name_formatted}}" -Homepage = "https://github.com/{{github}}/{{project_name_formatted}}" +Repository = "https://github.com/{{ github }}/{{ project_name_formatted }}" +Homepage = "https://github.com/{{ github }}/{{ project_name_formatted }}" [tool.bumpversion] current_version = "0.1.0" @@ -66,7 +66,7 @@ tag = true commit_args = "-s" [[tool.bumpversion.files]] -filename = "{{module}}/__init__.py" +filename = "{{ module }}/__init__.py" search = '__version__ = "{current_version}"' replace = '__version__ = "{new_version}"' @@ -87,7 +87,7 @@ replace = 'version = "{new_version}"' [tool.cibuildwheel] build = "cp310-*" -test-command = "pytest -vvv {project}/{{module}}/tests" +test-command = "pytest -vvv {project}/{{ module }}/tests" test-extras = "develop" [tool.cibuildwheel.linux] @@ -111,7 +111,7 @@ skip = "*win32 *arm_64" [tool.coverage.run] branch = true omit = [ - "{{module}}/tests/integration/", + "{{ module }}/tests/integration/", ] [tool.coverage.report] @@ -136,12 +136,12 @@ src = "/" [tool.hatch.build.hooks.hatch-rs] verbose = true abi3 = true -module = "{{module}}" +module = "{{ module }}" path = "." [tool.hatch.build.targets.sdist] packages = [ - "{{module}}", + "{{ module }}", "rust", "Cargo.toml", "Cargo.lock", @@ -153,7 +153,7 @@ exclude = [ [tool.hatch.build.targets.wheel] packages = [ - "{{module}}", + "{{ module }}", ] exclude = [ "rust", @@ -164,7 +164,7 @@ addopts = [ "-vvv", "--junitxml=junit.xml", ] -testpaths = "{{module}}/tests" +testpaths = "{{ module }}/tests" [tool.ruff] line-length = 150 @@ -178,7 +178,7 @@ extend-select = [ combine-as-imports = true default-section = "third-party" known-first-party = [ - "{{module}}", + "{{ module }}", ] section-order = [ "future", diff --git a/rust/rust/Cargo.toml.jinja b/rust/rust/Cargo.toml.jinja index d7db932..3732245 100644 --- a/rust/rust/Cargo.toml.jinja +++ b/rust/rust/Cargo.toml.jinja @@ -1,15 +1,15 @@ [package] -name = "{{module}}" +name = "{{ module }}" version = "0.1.0" -authors = ["{{team}} <{{email}}>"] +authors = ["{{ team }} <{{ email }}>"] edition = "2021" license = "Apache-2.0" readme = "../README.md" -repository = "https://github.com/{{github}}/{{project_name}}" -description = "{{project_description}}" +repository = "https://github.com/{{ github }}/{{ project_name }}" +description = "{{ project_description }}" [lib] -name = "{{module}}" +name = "{{ module }}" path = "src/lib.rs" crate-type = ["rlib"] diff --git a/rust/rust/python/example/mod.rs.jinja b/rust/rust/python/example/mod.rs.jinja index c9df21c..7c1e7f9 100644 --- a/rust/rust/python/example/mod.rs.jinja +++ b/rust/rust/python/example/mod.rs.jinja @@ -1,6 +1,6 @@ use pyo3::prelude::*; -use {{module}}::Example as BaseExample; +use {{ module }}::Example as BaseExample; #[pyclass] diff --git a/rust/rust/python/lib.rs.jinja b/rust/rust/python/lib.rs.jinja index 9dae75b..168dfeb 100644 --- a/rust/rust/python/lib.rs.jinja +++ b/rust/rust/python/lib.rs.jinja @@ -6,7 +6,7 @@ pub use example::Example; #[pymodule] -fn {{module}}(_py: Python, m: &Bound) -> PyResult<()> { +fn {{ module }}(_py: Python, m: &Bound) -> PyResult<()> { // Example m.add_class::().unwrap(); Ok(()) diff --git a/rust/{% if add_wiki %}docs{% endif %}/wiki/Installation.md.jinja b/rust/{% if add_wiki %}docs{% endif %}/wiki/Installation.md.jinja index 8dfc880..89b2612 100644 --- a/rust/{% if add_wiki %}docs{% endif %}/wiki/Installation.md.jinja +++ b/rust/{% if add_wiki %}docs{% endif %}/wiki/Installation.md.jinja @@ -1,19 +1,19 @@ ## Pre-requisites -You need Python >=3.10 on your machine to install `{{project_name_formatted}}`. +You need Python >=3.10 on your machine to install `{{ project_name_formatted }}`. ## Install with `pip` ```bash -pip install {{project_name_formatted}} +pip install {{ project_name_formatted }} ``` ## Install with `conda` ```bash -conda install {{project_name_formatted}} --channel conda-forge +conda install {{ project_name_formatted }} --channel conda-forge ``` ## Source installation -For other platforms and for development installations, [build `{{project_name_formatted}}` from source](Build-from-Source). +For other platforms and for development installations, [build `{{ project_name_formatted }}` from source](Build-from-Source). diff --git a/rust/{% if add_wiki %}docs{% endif %}/wiki/_Footer.md.jinja b/rust/{% if add_wiki %}docs{% endif %}/wiki/_Footer.md.jinja index 4a5fb4b..bd81a19 100644 --- a/rust/{% if add_wiki %}docs{% endif %}/wiki/_Footer.md.jinja +++ b/rust/{% if add_wiki %}docs{% endif %}/wiki/_Footer.md.jinja @@ -1 +1 @@ -_This wiki is autogenerated. To made updates, open a PR against the original source file in [`docs/wiki`](https://github.com/{{github}}/{{project_name_formatted}}/tree/main/docs/wiki)._ +_This wiki is autogenerated. To made updates, open a PR against the original source file in [`docs/wiki`](https://github.com/{{ github }}/{{ project_name_formatted }}/tree/main/docs/wiki)._ diff --git a/rust/{% if add_wiki %}docs{% endif %}/wiki/contribute/Build-from-Source.md.jinja b/rust/{% if add_wiki %}docs{% endif %}/wiki/contribute/Build-from-Source.md.jinja index 78ceceb..2d332da 100644 --- a/rust/{% if add_wiki %}docs{% endif %}/wiki/contribute/Build-from-Source.md.jinja +++ b/rust/{% if add_wiki %}docs{% endif %}/wiki/contribute/Build-from-Source.md.jinja @@ -1,4 +1,4 @@ -`{{project_name_formatted}}` is written in Python and Rust. While prebuilt wheels are provided for end users, it is also straightforward to build `{{project_name_formatted}}` from either the Python [source distribution](https://packaging.python.org/en/latest/specifications/source-distribution-format/) or the GitHub repository. +`{{ project_name_formatted }}` is written in Python and Rust. While prebuilt wheels are provided for end users, it is also straightforward to build `{{ project_name_formatted }}` from either the Python [source distribution](https://packaging.python.org/en/latest/specifications/source-distribution-format/) or the GitHub repository. - [Make commands](#make-commands) - [Prerequisites](#prerequisites) @@ -10,7 +10,7 @@ ## Make commands -As a convenience, `{{project_name_formatted}}` uses a `Makefile` for commonly used commands. You can print the main available commands by running `make` with no arguments +As a convenience, `{{ project_name_formatted }}` uses a `Makefile` for commonly used commands. You can print the main available commands by running `make` with no arguments ```bash > make @@ -25,15 +25,15 @@ test run the tests ## Prerequisites -`{{project_name_formatted}}` has a few system-level dependencies which you can install from your machine package manager. Other package managers like `conda`, `nix`, etc, should also work fine. +`{{ project_name_formatted }}` has a few system-level dependencies which you can install from your machine package manager. Other package managers like `conda`, `nix`, etc, should also work fine. ## Clone Clone the repo with: ```bash -git clone https://github.com/{{github}}/{{project_name_formatted}}.git -cd {{project_name_formatted}} +git clone https://github.com/{{ github }}/{{ project_name_formatted }}.git +cd {{ project_name_formatted }} ``` ## Install Rust @@ -60,7 +60,7 @@ make build ## Lint and Autoformat -`{{project_name_formatted}}` has linting and auto formatting. +`{{ project_name_formatted }}` has linting and auto formatting. | Language | Linter | Autoformatter | Description | | :------- | :---------- | :------------ | :---------- | @@ -108,7 +108,7 @@ make fix-docs ## Testing -`{{project_name_formatted}}` has both Python and JavaScript tests. The bulk of the functionality is tested in Python, which can be run via `pytest`. First, install the Python development dependencies with +`{{ project_name_formatted }}` has both Python and JavaScript tests. The bulk of the functionality is tested in Python, which can be run via `pytest`. First, install the Python development dependencies with ```bash make develop diff --git a/rust/{% if add_wiki %}docs{% endif %}/wiki/contribute/Contribute.md.jinja b/rust/{% if add_wiki %}docs{% endif %}/wiki/contribute/Contribute.md.jinja index 7deea95..463b117 100644 --- a/rust/{% if add_wiki %}docs{% endif %}/wiki/contribute/Contribute.md.jinja +++ b/rust/{% if add_wiki %}docs{% endif %}/wiki/contribute/Contribute.md.jinja @@ -1,14 +1,14 @@ -Contributions are welcome on this project. We distribute under the terms of the [Apache 2.0 license](https://github.com/{{github}}/{{project_name_formatted}}/blob/main/LICENSE). +Contributions are welcome on this project. We distribute under the terms of the [Apache 2.0 license](https://github.com/{{ github }}/{{ project_name_formatted }}/blob/main/LICENSE). > [!NOTE] > -> `{{project_name_formatted}}` requires [Developer Certificate of Origin](https://en.wikipedia.org/wiki/Developer_Certificate_of_Origin) for all contributions. +> `{{ project_name_formatted }}` requires [Developer Certificate of Origin](https://en.wikipedia.org/wiki/Developer_Certificate_of_Origin) for all contributions. > This is enforced by a [Probot GitHub App](https://probot.github.io/apps/dco/), which checks that commits are "signed". > Read [instructions to configure commit signing](Local-Development-Setup#configure-commit-signing). -For **bug reports** or **small feature requests**, please open an issue on our [issues page](https://github.com/{{github}}/{{project_name_formatted}}/issues). +For **bug reports** or **small feature requests**, please open an issue on our [issues page](https://github.com/{{ github }}/{{ project_name_formatted }}/issues). -For **questions** or to discuss **larger changes or features**, please use our [discussions page](https://github.com/{{github}}/{{project_name_formatted}}/discussions). +For **questions** or to discuss **larger changes or features**, please use our [discussions page](https://github.com/{{ github }}/{{ project_name_formatted }}/discussions). For **contributions**, please see our [developer documentation](Local-Development-Setup). We have `help wanted` and `good first issue` tags on our issues page, so these are a great place to start. diff --git a/rust/{% if add_wiki %}docs{% endif %}/wiki/contribute/Local-Development-Setup.md.jinja b/rust/{% if add_wiki %}docs{% endif %}/wiki/contribute/Local-Development-Setup.md.jinja index 897872a..abf413b 100644 --- a/rust/{% if add_wiki %}docs{% endif %}/wiki/contribute/Local-Development-Setup.md.jinja +++ b/rust/{% if add_wiki %}docs{% endif %}/wiki/contribute/Local-Development-Setup.md.jinja @@ -10,27 +10,27 @@ ## Step 1: Build from Source -To work on `{{project_name_formatted}}`, you are going to need to build it from source. See +To work on `{{ project_name_formatted }}`, you are going to need to build it from source. See [Build from Source](Build-from-Source) for detailed build instructions. -Once you've built `{{project_name_formatted}}` from a `git` clone, you will also need to -configure `git` and your GitHub account for `{{project_name_formatted}}` development. +Once you've built `{{ project_name_formatted }}` from a `git` clone, you will also need to +configure `git` and your GitHub account for `{{ project_name_formatted }}` development. ## Step 2: Configuring Git and GitHub for Development ### Create your fork -The first step is to create a personal fork of `{{project_name_formatted}}`. To do so, click -the "fork" button at https://github.com/{{github}}/{{project_name_formatted}}, or just navigate -[here](https://github.com/{{github}}/{{project_name_formatted}}/fork) in your browser. Set the +The first step is to create a personal fork of `{{ project_name_formatted }}`. To do so, click +the "fork" button at https://github.com/{{ github }}/{{ project_name_formatted }}, or just navigate +[here](https://github.com/{{ github }}/{{ project_name_formatted }}/fork) in your browser. Set the owner of the repository to your personal GitHub account if it is not already set that way and click "Create fork". ### Configure remotes Next, you should set some names for the `git` remotes corresponding to -main {{github}} repository and your fork. See the [GitHub Docs](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/configuring-a-remote-repository-for-a-fork) for more information. +main {{ github }} repository and your fork. See the [GitHub Docs](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/configuring-a-remote-repository-for-a-fork) for more information. ### Authenticating with GitHub diff --git a/rust/{{module}}/tests/test_all.py.jinja b/rust/{{module}}/tests/test_all.py.jinja index cd7454a..1ae629a 100644 --- a/rust/{{module}}/tests/test_all.py.jinja +++ b/rust/{{module}}/tests/test_all.py.jinja @@ -1,4 +1,4 @@ -from {{module}} import * # noqa +from {{ module }} import * # noqa def test_all(): diff --git a/rustjswasm/.github/CODE_OF_CONDUCT.md.jinja b/rustjswasm/.github/CODE_OF_CONDUCT.md.jinja index ebc86d7..9eab626 100644 --- a/rustjswasm/.github/CODE_OF_CONDUCT.md.jinja +++ b/rustjswasm/.github/CODE_OF_CONDUCT.md.jinja @@ -55,7 +55,7 @@ further defined and clarified by project maintainers. ## Enforcement Instances of abusive, harassing, or otherwise unacceptable behavior may be -reported by contacting the project team at {{email}}. All +reported by contacting the project team at {{ email }}. All complaints will be reviewed and investigated and will result in a response that is deemed necessary and appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. diff --git a/rustjswasm/.github/workflows/build.yaml.jinja b/rustjswasm/.github/workflows/build.yaml.jinja index 931565d..1c95b21 100644 --- a/rustjswasm/.github/workflows/build.yaml.jinja +++ b/rustjswasm/.github/workflows/build.yaml.jinja @@ -30,7 +30,7 @@ jobs: strategy: matrix: os: [ubuntu-latest, macos-latest, windows-latest] - python-version: ["{{python_version_primary}}"] + python-version: ["{{ python_version_primary }}"] cibuildwheel: ["cp{{python_version_primary.replace('.', '')}}"] node-version: [20.x] diff --git a/rustjswasm/.gitignore.jinja b/rustjswasm/.gitignore.jinja index 0cf743a..73811ea 100644 --- a/rustjswasm/.gitignore.jinja +++ b/rustjswasm/.gitignore.jinja @@ -133,9 +133,9 @@ js/*.tgz .ipynb_checkpoints .autoversion Untitled*.ipynb -{{module}}/extension -{{module}}/nbextension -{{module}}/labextension +{{ module }}/extension +{{ module }}/nbextension +{{ module }}/labextension # Mac .DS_Store diff --git a/rustjswasm/Cargo.toml.jinja b/rustjswasm/Cargo.toml.jinja index c83d866..8c5d01d 100644 --- a/rustjswasm/Cargo.toml.jinja +++ b/rustjswasm/Cargo.toml.jinja @@ -1,16 +1,16 @@ [package] -name = "{{module}}_py" +name = "{{ module }}_py" version = "0.1.0" edition = "2021" publish = false [lib] -name = "{{module}}" +name = "{{ module }}" path = "rust/python/lib.rs" crate-type = ["cdylib"] [dependencies] -{{module}} = { path = "./rust", version = "*" } +{{ module }} = { path = "./rust", version = "*" } pyo3 = { version = "0.28.2", features = ["abi3", "extension-module", "multiple-pymethods"] } [profile.release] diff --git a/rustjswasm/LICENSE.jinja b/rustjswasm/LICENSE.jinja index ee2a86d..3d7a96a 100644 --- a/rustjswasm/LICENSE.jinja +++ b/rustjswasm/LICENSE.jinja @@ -186,7 +186,7 @@ same "printed page" as the copyright notice for easier identification within third-party archives. - Copyright 2025 {{team}} + Copyright 2025 {{ team }} Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/rustjswasm/Makefile.jinja b/rustjswasm/Makefile.jinja index f245a33..03caa89 100644 --- a/rustjswasm/Makefile.jinja +++ b/rustjswasm/Makefile.jinja @@ -47,8 +47,8 @@ install: ## install python library ######### .PHONY: lint-py lint-js lint-rs lint-docs lint lints lint-py: ## run python linter with ruff - python -m ruff check {{module}} - python -m ruff format --check {{module}} + python -m ruff check {{ module }} + python -m ruff format --check {{ module }} lint-js: ## run js linter cd js; pnpm lint @@ -67,8 +67,8 @@ lints: lint .PHONY: fix-py fix-js fix-rs fix-docs fix format fix-py: ## fix python formatting with ruff - python -m ruff check --fix {{module}} - python -m ruff format {{module}} + python -m ruff check --fix {{ module }} + python -m ruff format {{ module }} fix-js: ## fix js formatting cd js; pnpm fix @@ -106,13 +106,13 @@ check: checks ######### .PHONY: test-py tests-py coverage-py test-py: ## run python tests - python -m pytest -v {{module}}/tests + python -m pytest -v {{ module }}/tests # alias tests-py: test-py coverage-py: ## run python tests and collect test coverage - python -m pytest -v {{module}}/tests --cov={{module}} --cov-report term-missing --cov-report xml + python -m pytest -v {{ module }}/tests --cov={{ module }} --cov-report term-missing --cov-report xml .PHONY: test-js tests-js coverage-js test-js: ## run js tests diff --git a/rustjswasm/README.md.jinja b/rustjswasm/README.md.jinja index d8ce83b..7e11b1c 100644 --- a/rustjswasm/README.md.jinja +++ b/rustjswasm/README.md.jinja @@ -1,11 +1,11 @@ -# {{project_name}} +# {{ project_name }} -{{project_description}} +{{ project_description }} -[![Build Status](https://github.com/{{github}}/{{project_name_formatted}}/actions/workflows/build.yaml/badge.svg?branch=main&event=push)](https://github.com/{{github}}/{{project_name_formatted}}/actions/workflows/build.yaml) -[![codecov](https://codecov.io/gh/{{github}}/{{project_name_formatted}}/branch/main/graph/badge.svg)](https://codecov.io/gh/{{github}}/{{project_name_formatted}}) -[![License](https://img.shields.io/github/license/{{github}}/{{project_name_formatted}})](https://github.com/{{github}}/{{project_name_formatted}}) -[![PyPI](https://img.shields.io/pypi/v/{{project_name_formatted}}.svg)](https://pypi.python.org/pypi/{{project_name_formatted}}) +[![Build Status](https://github.com/{{ github }}/{{ project_name_formatted }}/actions/workflows/build.yaml/badge.svg?branch=main&event=push)](https://github.com/{{ github }}/{{ project_name_formatted }}/actions/workflows/build.yaml) +[![codecov](https://codecov.io/gh/{{ github }}/{{ project_name_formatted }}/branch/main/graph/badge.svg)](https://codecov.io/gh/{{ github }}/{{ project_name_formatted }}) +[![License](https://img.shields.io/github/license/{{ github }}/{{ project_name_formatted }})](https://github.com/{{ github }}/{{ project_name_formatted }}) +[![PyPI](https://img.shields.io/pypi/v/{{ project_name_formatted }}.svg)](https://pypi.python.org/pypi/{{ project_name_formatted }}) ## Overview diff --git a/rustjswasm/js/Cargo.toml.jinja b/rustjswasm/js/Cargo.toml.jinja index 586d28d..2cf11ae 100644 --- a/rustjswasm/js/Cargo.toml.jinja +++ b/rustjswasm/js/Cargo.toml.jinja @@ -1,5 +1,5 @@ [package] -name = "{{module}}_js" +name = "{{ module }}_js" version = "0.1.0" edition = "2021" publish = false @@ -7,10 +7,10 @@ keywords = ["experimental"] include = ["src/**/*", "Cargo.toml", "package.json"] [lib] -name = "{{module}}" +name = "{{ module }}" path = "src/rust/lib.rs" crate-type = ["cdylib"] [dependencies] -{{module}} = { path = "../rust", version = "*" } +{{ module }} = { path = "../rust", version = "*" } wasm-bindgen = "=0.2.115" diff --git a/rustjswasm/js/build.mjs.jinja b/rustjswasm/js/build.mjs.jinja index ca1555b..ae6c2a3 100644 --- a/rustjswasm/js/build.mjs.jinja +++ b/rustjswasm/js/build.mjs.jinja @@ -1,92 +1,42 @@ -import { NodeModulesExternal } from "@finos/perspective-esbuild-plugin/external.js"; -import { build } from "@finos/perspective-esbuild-plugin/build.js"; -import { transform } from "lightningcss"; +import { bundle } from "./tools/bundle.mjs"; +import { bundle_css } from "./tools/css.mjs"; +import { node_modules_external } from "./tools/externals.mjs"; import { getarg } from "./tools/getarg.mjs"; + +import { transform } from "lightningcss"; import fs from "fs"; import cpy from "cpy"; -const DEBUG = getarg("--debug"); - -const COMMON_DEFINE = { - global: "window", - "process.env.DEBUG": `${DEBUG}`, -}; - -const BUILD = [ +const BUNDLES = [ { - define: COMMON_DEFINE, entryPoints: ["src/ts/index.ts"], - plugins: [NodeModulesExternal()], - format: "esm", - loader: { - ".css": "text", - ".html": "text", - }, + plugins: [node_modules_external()], outfile: "dist/esm/index.js", }, { - define: COMMON_DEFINE, entryPoints: ["src/ts/index.ts"], - plugins: [], - format: "esm", - loader: { - ".css": "text", - ".html": "text", - }, outfile: "dist/cdn/index.js", }, ]; -async function compile_css() { - const process_path = (path) => { - const outpath = path.replace("src/css", "dist/css"); - fs.mkdirSync(outpath, { recursive: true }); - - fs.readdirSync(path, { withFileTypes: true }).forEach((entry) => { - const input = `${path}/${entry.name}`; - const output = `${outpath}/${entry.name}`; +async function build() { + // Bundle css + await bundle_css(); - if (entry.isDirectory()) { - process_path(input); - } else if (entry.isFile() && entry.name.endsWith(".css")) { - const source = fs.readFileSync(input); - const { code } = transform({ - filename: entry.name, - code: source, - minify: !DEBUG, - sourceMap: false, - }); - fs.writeFileSync(output, code); - } - }); - }; - - process_path("src/css"); -} - -async function copy_html() { + // Copy HTML fs.mkdirSync("dist/html", { recursive: true }); cpy("src/html/*", "dist/html"); - // also copy to top level cpy("src/html/*", "dist/"); -} -async function copy_img() { + // Copy images fs.mkdirSync("dist/img", { recursive: true }); cpy("src/img/*", "dist/img"); -} -async function copy_to_python() { - fs.mkdirSync("../{{module}}/extension", { recursive: true }); - cpy("dist/**/*", "../{{module}}/extension"); -} + await Promise.all(BUNDLES.map(bundle)).catch(() => process.exit(1)); -async function build_all() { - await compile_css(); - await copy_html(); - await copy_img(); - await Promise.all(BUILD.map(build)).catch(() => process.exit(1)); - await copy_to_python(); + // Copy from dist to python + fs.mkdirSync("../{{ module }}/extension", { recursive: true }); + cpy("dist/**/*", "../{{ module }}/extension"); } -build_all(); +build(); diff --git a/rustjswasm/js/package.json.jinja b/rustjswasm/js/package.json.jinja index 60d352e..d98e3ad 100644 --- a/rustjswasm/js/package.json.jinja +++ b/rustjswasm/js/package.json.jinja @@ -1,9 +1,9 @@ { - "name": "{{project_name_formatted}}", + "name": "{{ project_name_formatted }}", "version": "0.1.0", - "description": "{{project_description}}", - "repository": "git@github.com:{{github}}/{{project_name_formatted}}.git", - "author": "{{team}} <{{email}}>", + "description": "{{ project_description }}", + "repository": "git@github.com:{{ github }}/{{ project_name_formatted }}.git", + "author": "{{ team }} <{{ email }}>", "license": "Apache-2.0", "private": true, "type": "module", @@ -29,10 +29,10 @@ "setup": "cargo install -f wasm-bindgen-cli --version 0.2.115 --locked", "build:debug": "node build.mjs --debug", "build:rust": "cargo build --release --all-features --target wasm32-unknown-unknown", - "build:wasm-bindgen": "wasm-bindgen ../target/wasm32-unknown-unknown/release/{{module}}.wasm --out-dir ./dist/pkg --target web", + "build:wasm-bindgen": "wasm-bindgen ../target/wasm32-unknown-unknown/release/{{ module }}.wasm --out-dir ./dist/pkg --target web", "build:prod": "node build.mjs", "build": "npm-run-all build:rust build:wasm-bindgen build:prod", - "clean": "rm -rf dist lib playwright-report ../{{module}}/extension", + "clean": "rm -rf dist lib playwright-report ../{{ module }}/extension", "dev": "npm-run-all -p start watch", "lint:js": "prettier --check \"src/**/*.{js,ts,jsx,tsx,css}\" \"tests/**/*.{js,ts,jsx,tsx}\" \"*.mjs\" \"*.json\"", "lint:rust": "cargo clippy --all-features && cargo fmt --all -- --check", @@ -51,7 +51,6 @@ }, "dependencies": {}, "devDependencies": { - "@finos/perspective-esbuild-plugin": "^3.2.1", "@playwright/test": "^1.59.1", "cpy": "^13.2.1", "esbuild": "^0.27.3", diff --git a/rustjswasm/js/src/html/index.html.jinja b/rustjswasm/js/src/html/index.html.jinja index 5ecca1e..ecc91c7 100644 --- a/rustjswasm/js/src/html/index.html.jinja +++ b/rustjswasm/js/src/html/index.html.jinja @@ -1,9 +1,9 @@ - {{project_name}} - - + {{ project_name }} + + diff --git a/rustjswasm/js/src/ts/index.ts.jinja b/rustjswasm/js/src/ts/index.ts.jinja index 4c904a0..63e015c 100644 --- a/rustjswasm/js/src/ts/index.ts.jinja +++ b/rustjswasm/js/src/ts/index.ts.jinja @@ -1,6 +1,6 @@ -import * as wasm from "../../dist/pkg/{{module}}"; +import * as wasm from "../../dist/pkg/{{ module }}"; -export * as wasm from "../../dist/pkg/{{module}}"; +export * as wasm from "../../dist/pkg/{{ module }}"; export const placeholder = ""; diff --git a/rustjswasm/js/tools/bundle.mjs b/rustjswasm/js/tools/bundle.mjs new file mode 100644 index 0000000..b417871 --- /dev/null +++ b/rustjswasm/js/tools/bundle.mjs @@ -0,0 +1,59 @@ +import { getarg } from "./getarg.mjs"; +import esbuild from "esbuild"; + +const DEBUG = getarg("--debug"); + +const CUTOFF_PERCENT = 0.02; + +const COMMON_DEFINE = { + global: "window", + "process.env.DEBUG": `${DEBUG}`, +}; + +const COMMON_LOADER = { + ".css": "text", + ".html": "text", + ".jsx": "jsx", + ".png": "file", + ".ttf": "file", + ".wasm": "file", +}; + +const DEFAULT_BUILD = { + target: ["es2022"], + bundle: true, + format: "esm", + minify: DEBUG, + sourcemap: true, + metafile: true, + entryNames: "[name]", + chunkNames: "[name]", + assetNames: "[name]", + define: COMMON_DEFINE, + loader: COMMON_LOADER, + plugins: [], +}; + +export const bundle = async (config) => { + const result = await esbuild.build({ + ...DEFAULT_BUILD, + ...config, + }); + + if (result.metafile) { + for (const output of Object.keys(result.metafile.outputs)) { + const { inputs, bytes } = result.metafile.outputs[output]; + for (const input of Object.keys(inputs)) { + if (inputs[input].bytesInOutput / bytes < CUTOFF_PERCENT) { + delete inputs[input]; + } + } + } + + const text = await esbuild.analyzeMetafile(result.metafile, { + color: true, + }); + + console.log(text); + } +}; diff --git a/rustjswasm/js/tools/css.mjs b/rustjswasm/js/tools/css.mjs new file mode 100644 index 0000000..4ac3594 --- /dev/null +++ b/rustjswasm/js/tools/css.mjs @@ -0,0 +1,52 @@ +import { getarg } from "./getarg.mjs"; + +import { bundleAsync } from "lightningcss"; +import fs from "fs"; +import path from "path"; + +const DEBUG = getarg("--debug"); + +const DEFAULT_RESOLVER = { + resolve(specifier, originatingFile) { + if (/^https?:\/\//.test(specifier)) { + return specifier; + } + + if (specifier.startsWith("perspective-viewer-")) { + const viewerCssDir = path.resolve( + "node_modules/@perspective-dev/viewer/dist/css", + ); + const normalized = specifier.replace(/^perspective-viewer-/, ""); + const normalizedPath = path.join(viewerCssDir, normalized); + if (fs.existsSync(normalizedPath)) { + return normalizedPath; + } + return path.join(viewerCssDir, specifier); + } + return path.resolve(path.dirname(originatingFile), specifier); + }, +}; + +const bundle_one = async (file, resolver) => { + const { code } = await bundleAsync({ + filename: path.resolve(file), + minify: !DEBUG, + sourceMap: false, + resolver: resolver || DEFAULT_RESOLVER, + }); + const outName = path.basename(file); + fs.mkdirSync("./dist", { recursive: true }); + fs.writeFileSync(path.join("./dist", outName), code); +}; + +export const bundle_css = async (root = "src/css/index.css", resolver = null) => { + const resolved = path.resolve(root); + if (fs.statSync(resolved).isDirectory()) { + const files = fs.readdirSync(resolved).filter((f) => f.endsWith(".css")); + for (const file of files) { + await bundle_one(path.join(root, file), resolver); + } + } else { + await bundle_one(root, resolver); + } +} diff --git a/rustjswasm/js/tools/externals.mjs b/rustjswasm/js/tools/externals.mjs new file mode 100644 index 0000000..0ee4835 --- /dev/null +++ b/rustjswasm/js/tools/externals.mjs @@ -0,0 +1,18 @@ +export const node_modules_external = (whitelist) => { + function setup(build) { + build.onResolve({ filter: /^[A-Za-z0-9\@]/ }, (args) => { + if (!whitelist || !args.path.startsWith(whitelist)) { + return { + path: args.path, + external: true, + namespace: "skip-node-modules", + }; + } + }); + } + + return { + name: "node_modules_external", + setup, + }; +}; diff --git a/rustjswasm/js/tools/getarg.mjs b/rustjswasm/js/tools/getarg.mjs index 30793a7..9cfe88c 100644 --- a/rustjswasm/js/tools/getarg.mjs +++ b/rustjswasm/js/tools/getarg.mjs @@ -20,4 +20,4 @@ export const getarg = (flag, ...args) => { }) .join(" "); } - }; \ No newline at end of file + }; diff --git a/rustjswasm/js/tools/html.mjs b/rustjswasm/js/tools/html.mjs new file mode 100644 index 0000000..e69de29 diff --git a/rustjswasm/pyproject.toml.jinja b/rustjswasm/pyproject.toml.jinja index 23171f1..9a2a587 100644 --- a/rustjswasm/pyproject.toml.jinja +++ b/rustjswasm/pyproject.toml.jinja @@ -7,11 +7,11 @@ requires = [ build-backend = "hatchling.build" [project] -name = "{{project_name_formatted}}" +name = "{{ project_name_formatted }}" authors = [ - {name = "{{team}}", email = "{{email}}"}, + {name = "{{ team }}", email = "{{ email }}"}, ] -description = "{{project_description}}" +description = "{{ project_description }}" readme = "README.md" license = { text = "Apache-2.0" } version = "0.1.0" @@ -58,8 +58,8 @@ develop = [ [project.scripts] [project.urls] -Repository = "https://github.com/{{github}}/{{project_name_formatted}}" -Homepage = "https://github.com/{{github}}/{{project_name_formatted}}" +Repository = "https://github.com/{{ github }}/{{ project_name_formatted }}" +Homepage = "https://github.com/{{ github }}/{{ project_name_formatted }}" [tool.bumpversion] current_version = "0.1.0" @@ -68,7 +68,7 @@ tag = true commit_args = "-s" [[tool.bumpversion.files]] -filename = "{{module}}/__init__.py" +filename = "{{ module }}/__init__.py" search = '__version__ = "{current_version}"' replace = '__version__ = "{new_version}"' @@ -99,7 +99,7 @@ replace = 'version = "{new_version}"' [tool.cibuildwheel] build = "cp310-*" -test-command = "pytest -vvv {project}/{{module}}/tests" +test-command = "pytest -vvv {project}/{{ module }}/tests" test-extras = "develop" [tool.cibuildwheel.linux] @@ -122,7 +122,7 @@ skip = "*win32 *arm_64" [tool.coverage.run] branch = true omit = [ - "{{module}}/tests/integration/", + "{{ module }}/tests/integration/", ] [tool.coverage.report] @@ -139,18 +139,18 @@ path = "js" build_cmd = "build" tool = "pnpm" targets = [ - "{{module}}/extension/cdn/index.js", + "{{ module }}/extension/cdn/index.js", ] [tool.hatch.build.hooks.hatch-rs] verbose = true abi3 = true -module = "{{module}}" +module = "{{ module }}" path = "." [tool.hatch.build.targets.sdist] packages = [ - "{{module}}", + "{{ module }}", "js", "rust", "Cargo.toml", @@ -164,7 +164,7 @@ exclude = [ [tool.hatch.build.targets.wheel] packages = [ - "{{module}}", + "{{ module }}", ] exclude = [ "js", @@ -176,7 +176,7 @@ addopts = [ "-vvv", "--junitxml=junit.xml", ] -testpaths = "{{module}}/tests" +testpaths = "{{ module }}/tests" [tool.ruff] line-length = 150 @@ -190,7 +190,7 @@ extend-select = [ combine-as-imports = true default-section = "third-party" known-first-party = [ - "{{module}}", + "{{ module }}", ] section-order = [ "future", diff --git a/rustjswasm/rust/Cargo.toml.jinja b/rustjswasm/rust/Cargo.toml.jinja index e588830..3cd3b05 100644 --- a/rustjswasm/rust/Cargo.toml.jinja +++ b/rustjswasm/rust/Cargo.toml.jinja @@ -1,15 +1,15 @@ [package] -name = "{{module}}" +name = "{{ module }}" version = "0.1.0" -authors = ["{{team}} <{{email}}>"] +authors = ["{{ team }} <{{ email }}>"] edition = "2021" license = "Apache-2.0" readme = "../README.md" -repository = "https://github.com/{{github}}/{{project_name}}" -description = "{{project_description}}" +repository = "https://github.com/{{ github }}/{{ project_name }}" +description = "{{ project_description }}" [lib] -name = "{{module}}" +name = "{{ module }}" path = "src/lib.rs" crate-type = ["rlib"] diff --git a/rustjswasm/rust/python/example/mod.rs.jinja b/rustjswasm/rust/python/example/mod.rs.jinja index 3d96ef5..217516a 100644 --- a/rustjswasm/rust/python/example/mod.rs.jinja +++ b/rustjswasm/rust/python/example/mod.rs.jinja @@ -1,6 +1,6 @@ use pyo3::prelude::*; -use {{module}}::Example as BaseExample; +use {{ module }}::Example as BaseExample; #[pyclass] pub struct Example { diff --git a/rustjswasm/rust/python/lib.rs.jinja b/rustjswasm/rust/python/lib.rs.jinja index 19d9814..5875074 100644 --- a/rustjswasm/rust/python/lib.rs.jinja +++ b/rustjswasm/rust/python/lib.rs.jinja @@ -5,7 +5,7 @@ mod example; pub use example::Example; #[pymodule] -fn {{module}}(_py: Python, m: &Bound) -> PyResult<()> { +fn {{ module }}(_py: Python, m: &Bound) -> PyResult<()> { // Example m.add_class::().unwrap(); Ok(()) diff --git a/rustjswasm/{% if add_wiki %}docs{% endif %}/wiki/Installation.md.jinja b/rustjswasm/{% if add_wiki %}docs{% endif %}/wiki/Installation.md.jinja index 8dfc880..89b2612 100644 --- a/rustjswasm/{% if add_wiki %}docs{% endif %}/wiki/Installation.md.jinja +++ b/rustjswasm/{% if add_wiki %}docs{% endif %}/wiki/Installation.md.jinja @@ -1,19 +1,19 @@ ## Pre-requisites -You need Python >=3.10 on your machine to install `{{project_name_formatted}}`. +You need Python >=3.10 on your machine to install `{{ project_name_formatted }}`. ## Install with `pip` ```bash -pip install {{project_name_formatted}} +pip install {{ project_name_formatted }} ``` ## Install with `conda` ```bash -conda install {{project_name_formatted}} --channel conda-forge +conda install {{ project_name_formatted }} --channel conda-forge ``` ## Source installation -For other platforms and for development installations, [build `{{project_name_formatted}}` from source](Build-from-Source). +For other platforms and for development installations, [build `{{ project_name_formatted }}` from source](Build-from-Source). diff --git a/rustjswasm/{% if add_wiki %}docs{% endif %}/wiki/_Footer.md.jinja b/rustjswasm/{% if add_wiki %}docs{% endif %}/wiki/_Footer.md.jinja index 4a5fb4b..bd81a19 100644 --- a/rustjswasm/{% if add_wiki %}docs{% endif %}/wiki/_Footer.md.jinja +++ b/rustjswasm/{% if add_wiki %}docs{% endif %}/wiki/_Footer.md.jinja @@ -1 +1 @@ -_This wiki is autogenerated. To made updates, open a PR against the original source file in [`docs/wiki`](https://github.com/{{github}}/{{project_name_formatted}}/tree/main/docs/wiki)._ +_This wiki is autogenerated. To made updates, open a PR against the original source file in [`docs/wiki`](https://github.com/{{ github }}/{{ project_name_formatted }}/tree/main/docs/wiki)._ diff --git a/rustjswasm/{% if add_wiki %}docs{% endif %}/wiki/contribute/Build-from-Source.md.jinja b/rustjswasm/{% if add_wiki %}docs{% endif %}/wiki/contribute/Build-from-Source.md.jinja index 78ceceb..2d332da 100644 --- a/rustjswasm/{% if add_wiki %}docs{% endif %}/wiki/contribute/Build-from-Source.md.jinja +++ b/rustjswasm/{% if add_wiki %}docs{% endif %}/wiki/contribute/Build-from-Source.md.jinja @@ -1,4 +1,4 @@ -`{{project_name_formatted}}` is written in Python and Rust. While prebuilt wheels are provided for end users, it is also straightforward to build `{{project_name_formatted}}` from either the Python [source distribution](https://packaging.python.org/en/latest/specifications/source-distribution-format/) or the GitHub repository. +`{{ project_name_formatted }}` is written in Python and Rust. While prebuilt wheels are provided for end users, it is also straightforward to build `{{ project_name_formatted }}` from either the Python [source distribution](https://packaging.python.org/en/latest/specifications/source-distribution-format/) or the GitHub repository. - [Make commands](#make-commands) - [Prerequisites](#prerequisites) @@ -10,7 +10,7 @@ ## Make commands -As a convenience, `{{project_name_formatted}}` uses a `Makefile` for commonly used commands. You can print the main available commands by running `make` with no arguments +As a convenience, `{{ project_name_formatted }}` uses a `Makefile` for commonly used commands. You can print the main available commands by running `make` with no arguments ```bash > make @@ -25,15 +25,15 @@ test run the tests ## Prerequisites -`{{project_name_formatted}}` has a few system-level dependencies which you can install from your machine package manager. Other package managers like `conda`, `nix`, etc, should also work fine. +`{{ project_name_formatted }}` has a few system-level dependencies which you can install from your machine package manager. Other package managers like `conda`, `nix`, etc, should also work fine. ## Clone Clone the repo with: ```bash -git clone https://github.com/{{github}}/{{project_name_formatted}}.git -cd {{project_name_formatted}} +git clone https://github.com/{{ github }}/{{ project_name_formatted }}.git +cd {{ project_name_formatted }} ``` ## Install Rust @@ -60,7 +60,7 @@ make build ## Lint and Autoformat -`{{project_name_formatted}}` has linting and auto formatting. +`{{ project_name_formatted }}` has linting and auto formatting. | Language | Linter | Autoformatter | Description | | :------- | :---------- | :------------ | :---------- | @@ -108,7 +108,7 @@ make fix-docs ## Testing -`{{project_name_formatted}}` has both Python and JavaScript tests. The bulk of the functionality is tested in Python, which can be run via `pytest`. First, install the Python development dependencies with +`{{ project_name_formatted }}` has both Python and JavaScript tests. The bulk of the functionality is tested in Python, which can be run via `pytest`. First, install the Python development dependencies with ```bash make develop diff --git a/rustjswasm/{% if add_wiki %}docs{% endif %}/wiki/contribute/Contribute.md.jinja b/rustjswasm/{% if add_wiki %}docs{% endif %}/wiki/contribute/Contribute.md.jinja index 7deea95..463b117 100644 --- a/rustjswasm/{% if add_wiki %}docs{% endif %}/wiki/contribute/Contribute.md.jinja +++ b/rustjswasm/{% if add_wiki %}docs{% endif %}/wiki/contribute/Contribute.md.jinja @@ -1,14 +1,14 @@ -Contributions are welcome on this project. We distribute under the terms of the [Apache 2.0 license](https://github.com/{{github}}/{{project_name_formatted}}/blob/main/LICENSE). +Contributions are welcome on this project. We distribute under the terms of the [Apache 2.0 license](https://github.com/{{ github }}/{{ project_name_formatted }}/blob/main/LICENSE). > [!NOTE] > -> `{{project_name_formatted}}` requires [Developer Certificate of Origin](https://en.wikipedia.org/wiki/Developer_Certificate_of_Origin) for all contributions. +> `{{ project_name_formatted }}` requires [Developer Certificate of Origin](https://en.wikipedia.org/wiki/Developer_Certificate_of_Origin) for all contributions. > This is enforced by a [Probot GitHub App](https://probot.github.io/apps/dco/), which checks that commits are "signed". > Read [instructions to configure commit signing](Local-Development-Setup#configure-commit-signing). -For **bug reports** or **small feature requests**, please open an issue on our [issues page](https://github.com/{{github}}/{{project_name_formatted}}/issues). +For **bug reports** or **small feature requests**, please open an issue on our [issues page](https://github.com/{{ github }}/{{ project_name_formatted }}/issues). -For **questions** or to discuss **larger changes or features**, please use our [discussions page](https://github.com/{{github}}/{{project_name_formatted}}/discussions). +For **questions** or to discuss **larger changes or features**, please use our [discussions page](https://github.com/{{ github }}/{{ project_name_formatted }}/discussions). For **contributions**, please see our [developer documentation](Local-Development-Setup). We have `help wanted` and `good first issue` tags on our issues page, so these are a great place to start. diff --git a/rustjswasm/{% if add_wiki %}docs{% endif %}/wiki/contribute/Local-Development-Setup.md.jinja b/rustjswasm/{% if add_wiki %}docs{% endif %}/wiki/contribute/Local-Development-Setup.md.jinja index 897872a..abf413b 100644 --- a/rustjswasm/{% if add_wiki %}docs{% endif %}/wiki/contribute/Local-Development-Setup.md.jinja +++ b/rustjswasm/{% if add_wiki %}docs{% endif %}/wiki/contribute/Local-Development-Setup.md.jinja @@ -10,27 +10,27 @@ ## Step 1: Build from Source -To work on `{{project_name_formatted}}`, you are going to need to build it from source. See +To work on `{{ project_name_formatted }}`, you are going to need to build it from source. See [Build from Source](Build-from-Source) for detailed build instructions. -Once you've built `{{project_name_formatted}}` from a `git` clone, you will also need to -configure `git` and your GitHub account for `{{project_name_formatted}}` development. +Once you've built `{{ project_name_formatted }}` from a `git` clone, you will also need to +configure `git` and your GitHub account for `{{ project_name_formatted }}` development. ## Step 2: Configuring Git and GitHub for Development ### Create your fork -The first step is to create a personal fork of `{{project_name_formatted}}`. To do so, click -the "fork" button at https://github.com/{{github}}/{{project_name_formatted}}, or just navigate -[here](https://github.com/{{github}}/{{project_name_formatted}}/fork) in your browser. Set the +The first step is to create a personal fork of `{{ project_name_formatted }}`. To do so, click +the "fork" button at https://github.com/{{ github }}/{{ project_name_formatted }}, or just navigate +[here](https://github.com/{{ github }}/{{ project_name_formatted }}/fork) in your browser. Set the owner of the repository to your personal GitHub account if it is not already set that way and click "Create fork". ### Configure remotes Next, you should set some names for the `git` remotes corresponding to -main {{github}} repository and your fork. See the [GitHub Docs](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/configuring-a-remote-repository-for-a-fork) for more information. +main {{ github }} repository and your fork. See the [GitHub Docs](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/configuring-a-remote-repository-for-a-fork) for more information. ### Authenticating with GitHub diff --git a/rustjswasm/{{module}}/tests/test_all.py.jinja b/rustjswasm/{{module}}/tests/test_all.py.jinja index cd7454a..1ae629a 100644 --- a/rustjswasm/{{module}}/tests/test_all.py.jinja +++ b/rustjswasm/{{module}}/tests/test_all.py.jinja @@ -1,4 +1,4 @@ -from {{module}} import * # noqa +from {{ module }} import * # noqa def test_all():