From 13a45151cbd18126ecc516fa5b33fa04f06d016f Mon Sep 17 00:00:00 2001 From: Tim Paine <3105306+timkpaine@users.noreply.github.com> Date: Fri, 13 Feb 2026 18:33:43 -0500 Subject: [PATCH 1/2] Add c++/js/wasm --- .github/workflows/build.yaml | 10 + Makefile | 12 +- copier.yaml | 2 + cppjswasm/.clang-format | 71 ++++++ cppjswasm/.gitattributes | 17 ++ cppjswasm/.github/CODE_OF_CONDUCT.md.jinja | 76 ++++++ .../.github/ISSUE_TEMPLATE/bug_report.md | 38 +++ .../.github/ISSUE_TEMPLATE/feature_request.md | 20 ++ cppjswasm/.github/dependabot.yaml | 24 ++ cppjswasm/.github/workflows/build.yaml.jinja | 119 ++++++++++ cppjswasm/.github/workflows/copier.yaml | 17 ++ ...% if add_docs %}docs.yaml{% endif %}.jinja | 26 +++ ...% if add_wiki %}wiki.yaml{% endif %}.jinja | 27 +++ cppjswasm/.gitignore.jinja | 163 +++++++++++++ cppjswasm/.vscode/settings.json | 3 + cppjswasm/LICENSE.jinja | 201 ++++++++++++++++ cppjswasm/Makefile.jinja | 202 ++++++++++++++++ cppjswasm/README.md.jinja | 13 ++ cppjswasm/cpp/Makefile.jinja | 53 +++++ .../example.cpp.jinja | 6 + .../{{project_name_formatted}}/example.hpp | 11 + .../extension.cpp.jinja | 18 ++ cppjswasm/js/build.mjs.jinja | 95 ++++++++ cppjswasm/js/package.json.jinja | 63 +++++ cppjswasm/js/playwright.config.js | 30 +++ cppjswasm/js/src/cpp/bindings.cpp.jinja | 11 + cppjswasm/js/src/html/index.html.jinja | 13 ++ cppjswasm/js/src/less/index.less | 0 cppjswasm/js/src/ts/css.d.ts | 4 + cppjswasm/js/src/ts/index.ts.jinja | 11 + cppjswasm/js/tests/index.spec.js | 7 + cppjswasm/js/tools/getarg.mjs | 23 ++ cppjswasm/js/tsconfig.json | 24 ++ cppjswasm/pyproject.toml.jinja | 218 ++++++++++++++++++ .../wiki/Installation.md.jinja | 19 ++ .../wiki/_Footer.md.jinja | 1 + .../wiki/_Sidebar.md.jinja | 16 ++ .../contribute/Build-from-Source.md.jinja | 144 ++++++++++++ .../wiki/contribute/Contribute.md.jinja | 15 ++ .../Local-Development-Setup.md.jinja | 55 +++++ cppjswasm/{{_copier_conf.answers_file}}.jinja | 2 + cppjswasm/{{module}}/__init__.py | 18 ++ cppjswasm/{{module}}/tests/test_all.py.jinja | 6 + examples/cppjswasm.yaml | 10 + python-template-cppjswasm | 1 + 45 files changed, 1914 insertions(+), 1 deletion(-) create mode 100644 cppjswasm/.clang-format create mode 100644 cppjswasm/.gitattributes create mode 100644 cppjswasm/.github/CODE_OF_CONDUCT.md.jinja create mode 100644 cppjswasm/.github/ISSUE_TEMPLATE/bug_report.md create mode 100644 cppjswasm/.github/ISSUE_TEMPLATE/feature_request.md create mode 100644 cppjswasm/.github/dependabot.yaml create mode 100644 cppjswasm/.github/workflows/build.yaml.jinja create mode 100644 cppjswasm/.github/workflows/copier.yaml create mode 100644 cppjswasm/.github/workflows/{% if add_docs %}docs.yaml{% endif %}.jinja create mode 100644 cppjswasm/.github/workflows/{% if add_wiki %}wiki.yaml{% endif %}.jinja create mode 100644 cppjswasm/.gitignore.jinja create mode 100644 cppjswasm/.vscode/settings.json create mode 100644 cppjswasm/LICENSE.jinja create mode 100644 cppjswasm/Makefile.jinja create mode 100644 cppjswasm/README.md.jinja create mode 100644 cppjswasm/cpp/Makefile.jinja create mode 100644 cppjswasm/cpp/{{project_name_formatted}}/example.cpp.jinja create mode 100644 cppjswasm/cpp/{{project_name_formatted}}/example.hpp create mode 100644 cppjswasm/cpp/{{project_name_formatted}}/extension.cpp.jinja create mode 100644 cppjswasm/js/build.mjs.jinja create mode 100644 cppjswasm/js/package.json.jinja create mode 100644 cppjswasm/js/playwright.config.js create mode 100644 cppjswasm/js/src/cpp/bindings.cpp.jinja create mode 100644 cppjswasm/js/src/html/index.html.jinja create mode 100644 cppjswasm/js/src/less/index.less create mode 100644 cppjswasm/js/src/ts/css.d.ts create mode 100644 cppjswasm/js/src/ts/index.ts.jinja create mode 100644 cppjswasm/js/tests/index.spec.js create mode 100644 cppjswasm/js/tools/getarg.mjs create mode 100644 cppjswasm/js/tsconfig.json create mode 100644 cppjswasm/pyproject.toml.jinja create mode 100644 cppjswasm/{% if add_wiki %}docs{% endif %}/wiki/Installation.md.jinja create mode 100644 cppjswasm/{% if add_wiki %}docs{% endif %}/wiki/_Footer.md.jinja create mode 100644 cppjswasm/{% if add_wiki %}docs{% endif %}/wiki/_Sidebar.md.jinja create mode 100644 cppjswasm/{% if add_wiki %}docs{% endif %}/wiki/contribute/Build-from-Source.md.jinja create mode 100644 cppjswasm/{% if add_wiki %}docs{% endif %}/wiki/contribute/Contribute.md.jinja create mode 100644 cppjswasm/{% if add_wiki %}docs{% endif %}/wiki/contribute/Local-Development-Setup.md.jinja create mode 100644 cppjswasm/{{_copier_conf.answers_file}}.jinja create mode 100644 cppjswasm/{{module}}/__init__.py create mode 100644 cppjswasm/{{module}}/tests/test_all.py.jinja create mode 100644 examples/cppjswasm.yaml create mode 120000 python-template-cppjswasm diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index cdb7323..f16329a 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -29,6 +29,8 @@ jobs: - jupyter - rust - rustjswasm + - cpp + - cppjswasm os: - ubuntu-latest - macos-latest @@ -56,6 +58,14 @@ jobs: - run: uv pip install copier + - name: Install clang-format + run: | + if [[ "$RUNNER_OS" == "Linux" ]]; then + sudo apt-get install -y clang-format-14 + elif [[ "$RUNNER_OS" == "macOS" ]]; then + brew install clang-format + fi + - uses: actions-ext/node/setup@main with: version: 22.x diff --git a/Makefile b/Makefile index 35132f4..7e1ae53 100644 --- a/Makefile +++ b/Makefile @@ -49,6 +49,11 @@ gen-rustjswasm: ## regenerate the rustjswasm template from scratch copier copy -w . ../python-template-rustjswasm --data-file examples/rustjswasm.yaml cd ../python-template-rustjswasm && $(SED) 's#_src_path: .#_src_path: https://github.com/python-project-templates/base.git#g' ./.copier-answers.yaml +gen-cppjswasm: ## regenerate the cppjswasm template from scratch + mkdir -p ../python-template-cppjswasm && cd ../python-template-cppjswasm && rm -rf ./* && rm -rf .copier-answers.yaml .gitignore .github .gitattributes + copier copy -w . ../python-template-cppjswasm --data-file examples/cppjswasm.yaml + cd ../python-template-cppjswasm && $(SED) 's#_src_path: .#_src_path: https://github.com/python-project-templates/base.git#g' ./.copier-answers.yaml + .PHONY: test-python test-cpp test-js test-jupyter test-rust test-rustjswasm test-python: cd ../python-template && git config --global user.name "github-actions" && git config --global user.email "41898282+github-actions[bot]@users.noreply.github.c@example.com" && git init && git add . && git commit -m "initial commit" @@ -95,4 +100,9 @@ test-rustjswasm: cd ../python-template-rustjswasm && make checks cd ../python-template-rustjswasm && make test - +test-cppjswasm: + cd ../python-template-cppjswasm && git config --global user.name "github-actions" && git config --global user.email "41898282+github-actions[bot]@users.noreply.github.c@example.com" && git init && git add . && git commit -m "initial commit" + cd ../python-template-cppjswasm && make develop + cd ../python-template-cppjswasm && make lint + cd ../python-template-cppjswasm && make checks + cd ../python-template-cppjswasm && make test diff --git a/copier.yaml b/copier.yaml index ad33c5e..5b7b096 100644 --- a/copier.yaml +++ b/copier.yaml @@ -49,6 +49,8 @@ add_extension: value: jupyter Rust JavaScript WebAssembly: value: rustjswasm + "C++ JavaScript WebAssembly": + value: cppjswasm _subdirectory: "{{ add_extension }}" diff --git a/cppjswasm/.clang-format b/cppjswasm/.clang-format new file mode 100644 index 0000000..a56fd44 --- /dev/null +++ b/cppjswasm/.clang-format @@ -0,0 +1,71 @@ +--- +Language: Cpp +# BasedOnStyle: WebKit +AccessModifierOffset: -2 +AlignAfterOpenBracket: BlockIndent +AlignArrayOfStructures: Left +AlignConsecutiveAssignments: true +AlignEscapedNewlinesLeft: false +AlignOperands: false +AlignTrailingComments: true +AllowAllParametersOfDeclarationOnNextLine: true +AllowShortBlocksOnASingleLine: false +AllowShortCaseLabelsOnASingleLine: false +AllowShortFunctionsOnASingleLine: All +AllowShortIfStatementsOnASingleLine: false +AllowShortLoopsOnASingleLine: false +AlwaysBreakAfterDefinitionReturnType: false +AlwaysBreakBeforeMultilineStrings: false +AlwaysBreakTemplateDeclarations: true +BinPackArguments: true +BinPackParameters: true +BreakBeforeBinaryOperators: All +BreakBeforeBraces: Attach +BreakBeforeTernaryOperators: true +BreakConstructorInitializersBeforeComma: true +BreakStringLiterals: false +ColumnLimit: 120 +ConstructorInitializerAllOnOneLineOrOnePerLine: false +ConstructorInitializerIndentWidth: 2 +ContinuationIndentWidth: 2 +Cpp11BracedListStyle: true +DerivePointerAlignment: false +DisableFormat: false +ExperimentalAutoDetectBinPacking: false +FixNamespaceComments: false +ForEachMacros: [ foreach ] +IndentCaseLabels: true +IndentWidth: 2 +IndentWrappedFunctionNames: false +KeepEmptyLinesAtTheStartOfBlocks: true +MacroBlockBegin: '' +MacroBlockEnd: '' +MaxEmptyLinesToKeep: 1 +NamespaceIndentation: Inner +ObjCBlockIndentWidth: 2 +ObjCSpaceAfterProperty: true +ObjCSpaceBeforeProtocolList: true +PenaltyBreakBeforeFirstCallParameter: 19 +PenaltyBreakAssignment: 200 +PenaltyBreakComment: 300 +PenaltyBreakFirstLessLess: 200 +PenaltyBreakString: 10000 +PenaltyExcessCharacter: 300 +PenaltyBreakOpenParenthesis: 1 +PenaltyReturnTypeOnItsOwnLine: 60 +PointerAlignment: Left +SpaceAfterCStyleCast: false +SpaceBeforeAssignmentOperators: true +# SpaceBeforeParens: ControlStatements +SpaceBeforeParens: false +SpaceInEmptyParentheses: false +SpacesBeforeTrailingComments: 1 +SpacesInAngles: false +SpacesInContainerLiterals: true +SpacesInCStyleCastParentheses: false +SpacesInParentheses: false +SpacesInSquareBrackets: false +Standard: Cpp11 +TabWidth: 2 +UseTab: Never +SortIncludes: false diff --git a/cppjswasm/.gitattributes b/cppjswasm/.gitattributes new file mode 100644 index 0000000..df3e022 --- /dev/null +++ b/cppjswasm/.gitattributes @@ -0,0 +1,17 @@ +examples/* linguist-documentation +docs/* linguist-documentation +*.ipynb linguist-documentation +Makefile linguist-documentation + +*.cpp text=auto eol=lf +*.css text=auto eol=lf +*.hpp text=auto eol=lf +*.html text=auto eol=lf +*.js text=auto eol=lf +*.json text=auto eol=lf +*.less text=auto eol=lf +*.md text=auto eol=lf +*.py text=auto eol=lf +*.toml text=auto eol=lf +*.ts text=auto eol=lf +*.yaml text=auto eol=lf diff --git a/cppjswasm/.github/CODE_OF_CONDUCT.md.jinja b/cppjswasm/.github/CODE_OF_CONDUCT.md.jinja new file mode 100644 index 0000000..ebc86d7 --- /dev/null +++ b/cppjswasm/.github/CODE_OF_CONDUCT.md.jinja @@ -0,0 +1,76 @@ +# Contributor Covenant Code of Conduct + +## Our Pledge + +In the interest of fostering an open and welcoming environment, we as +contributors and maintainers pledge to making participation in our project and +our community a harassment-free experience for everyone, regardless of age, body +size, disability, ethnicity, sex characteristics, gender identity and expression, +level of experience, education, socio-economic status, nationality, personal +appearance, race, religion, or sexual identity and orientation. + +## Our Standards + +Examples of behavior that contributes to creating a positive environment +include: + +* Using welcoming and inclusive language +* Being respectful of differing viewpoints and experiences +* Gracefully accepting constructive criticism +* Focusing on what is best for the community +* Showing empathy towards other community members + +Examples of unacceptable behavior by participants include: + +* The use of sexualized language or imagery and unwelcome sexual attention or + advances +* Trolling, insulting/derogatory comments, and personal or political attacks +* Public or private harassment +* Publishing others' private information, such as a physical or electronic + address, without explicit permission +* Other conduct which could reasonably be considered inappropriate in a + professional setting + +## Our Responsibilities + +Project maintainers are responsible for clarifying the standards of acceptable +behavior and are expected to take appropriate and fair corrective action in +response to any instances of unacceptable behavior. + +Project maintainers have the right and responsibility to remove, edit, or +reject comments, commits, code, wiki edits, issues, and other contributions +that are not aligned to this Code of Conduct, or to ban temporarily or +permanently any contributor for other behaviors that they deem inappropriate, +threatening, offensive, or harmful. + +## Scope + +This Code of Conduct applies both within project spaces and in public spaces +when an individual is representing the project or its community. Examples of +representing a project or community include using an official project e-mail +address, posting via an official social media account, or acting as an appointed +representative at an online or offline event. Representation of a project may be +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 +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. +Further details of specific enforcement policies may be posted separately. + +Project maintainers who do not follow or enforce the Code of Conduct in good +faith may face temporary or permanent repercussions as determined by other +members of the project's leadership. + +## Attribution + +This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, +available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html + +[homepage]: https://www.contributor-covenant.org + +For answers to common questions about this code of conduct, see +https://www.contributor-covenant.org/faq diff --git a/cppjswasm/.github/ISSUE_TEMPLATE/bug_report.md b/cppjswasm/.github/ISSUE_TEMPLATE/bug_report.md new file mode 100644 index 0000000..dd84ea7 --- /dev/null +++ b/cppjswasm/.github/ISSUE_TEMPLATE/bug_report.md @@ -0,0 +1,38 @@ +--- +name: Bug report +about: Create a report to help us improve +title: '' +labels: '' +assignees: '' + +--- + +**Describe the bug** +A clear and concise description of what the bug is. + +**To Reproduce** +Steps to reproduce the behavior: +1. Go to '...' +2. Click on '....' +3. Scroll down to '....' +4. See error + +**Expected behavior** +A clear and concise description of what you expected to happen. + +**Screenshots** +If applicable, add screenshots to help explain your problem. + +**Desktop (please complete the following information):** + - OS: [e.g. iOS] + - Browser [e.g. chrome, safari] + - Version [e.g. 22] + +**Smartphone (please complete the following information):** + - Device: [e.g. iPhone6] + - OS: [e.g. iOS8.1] + - Browser [e.g. stock browser, safari] + - Version [e.g. 22] + +**Additional context** +Add any other context about the problem here. diff --git a/cppjswasm/.github/ISSUE_TEMPLATE/feature_request.md b/cppjswasm/.github/ISSUE_TEMPLATE/feature_request.md new file mode 100644 index 0000000..bbcbbe7 --- /dev/null +++ b/cppjswasm/.github/ISSUE_TEMPLATE/feature_request.md @@ -0,0 +1,20 @@ +--- +name: Feature request +about: Suggest an idea for this project +title: '' +labels: '' +assignees: '' + +--- + +**Is your feature request related to a problem? Please describe.** +A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] + +**Describe the solution you'd like** +A clear and concise description of what you want to happen. + +**Describe alternatives you've considered** +A clear and concise description of any alternative solutions or features you've considered. + +**Additional context** +Add any other context or screenshots about the feature request here. diff --git a/cppjswasm/.github/dependabot.yaml b/cppjswasm/.github/dependabot.yaml new file mode 100644 index 0000000..b032cb3 --- /dev/null +++ b/cppjswasm/.github/dependabot.yaml @@ -0,0 +1,24 @@ +version: 2 +updates: + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "weekly" + labels: + - "part: github_actions" + + - package-ecosystem: "pip" + directory: "/" + schedule: + interval: "monthly" + labels: + - "lang: python" + - "part: dependencies" + + - package-ecosystem: "npm" + directory: "/js" + schedule: + interval: "monthly" + labels: + - "lang: javascript" + - "part: dependencies" diff --git a/cppjswasm/.github/workflows/build.yaml.jinja b/cppjswasm/.github/workflows/build.yaml.jinja new file mode 100644 index 0000000..50c676d --- /dev/null +++ b/cppjswasm/.github/workflows/build.yaml.jinja @@ -0,0 +1,119 @@ +name: Build Status + +on: + push: + branches: + - main + tags: + - v* + paths-ignore: + - LICENSE + - README.md + pull_request: + branches: + - main + workflow_dispatch: + +concurrency: + group: {% raw %}${{ github.workflow }}-${{ github.head_ref || github.run_id }}{% endraw %} + cancel-in-progress: true + +permissions: + contents: read + checks: write + pull-requests: write + +jobs: + build: + runs-on: {% raw %}${{ matrix.os }}{% endraw %} + + strategy: + matrix: + os: [ubuntu-latest, macos-latest, windows-latest] + python-version: ["{{python_version_primary}}"] + cibuildwheel: ["cp{{python_version_primary.replace('.', '')}}"] + node-version: [20.x] + + steps: + - uses: actions/checkout@v6 + + - uses: actions-ext/python/setup@main + with: + version: {% raw %}${{ matrix.python-version }}{% endraw %} + + - uses: actions-ext/node/setup@main + with: + version: 22.x + + - uses: mymindstorm/setup-emsdk@v14 + + - name: Install dependencies + run: make develop + if: matrix.os != 'windows-latest' + + - name: Install dependencies + run: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat" + make develop + shell: cmd + if: matrix.os == 'windows-latest' + + - name: Lint + run: make lint + if: matrix.os == 'ubuntu-latest' + + - name: Checks + run: make checks + if: matrix.os == 'ubuntu-latest' + + - name: Build + run: make build + + - name: Test + run: make coverage + + - name: Upload test results (Python) + uses: actions/upload-artifact@v6 + with: + name: {% raw %}test-results-${{ matrix.os }}-${{ matrix.python-version }}{% endraw %} + path: '**/junit.xml' + if: matrix.os == 'ubuntu-latest' + + - name: Publish Unit Test Results + uses: EnricoMi/publish-unit-test-result-action@v2 + with: + files: '**/junit.xml' + if: matrix.os == 'ubuntu-latest' + + - name: Upload coverage + uses: codecov/codecov-action@v5 + with: + token: {% raw %}${{ secrets.CODECOV_TOKEN }}{% endraw %} + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + with: + platforms: all + if: runner.os == 'Linux' && runner.arch == 'X64' + + - name: Make dist + run: | + make dist-py-sdist + make dist-py-wheel + make dist-check + env: + CIBW_BUILD: {% raw %}"${{ matrix.cibuildwheel }}-manylinux*"{% endraw %} + if: matrix.os == 'ubuntu-latest' + + - name: Make dist + run: | + make dist-py-wheel + make dist-check + env: + CIBW_ENVIRONMENT_MACOS: MACOSX_DEPLOYMENT_TARGET=11.0 + if: matrix.os != 'ubuntu-latest' + + - uses: actions/upload-artifact@v6 + with: + name: {% raw %}dist-${{matrix.os}}{% endraw %} + path: dist diff --git a/cppjswasm/.github/workflows/copier.yaml b/cppjswasm/.github/workflows/copier.yaml new file mode 100644 index 0000000..871b414 --- /dev/null +++ b/cppjswasm/.github/workflows/copier.yaml @@ -0,0 +1,17 @@ +name: Copier Updates + +on: + workflow_dispatch: + schedule: + - cron: "0 5 * * 0" + +jobs: + update: + permissions: + contents: write + pull-requests: write + runs-on: ubuntu-latest + steps: + - uses: actions-ext/copier-update@main + with: + token: ${{ secrets.WORKFLOW_TOKEN }} diff --git a/cppjswasm/.github/workflows/{% if add_docs %}docs.yaml{% endif %}.jinja b/cppjswasm/.github/workflows/{% if add_docs %}docs.yaml{% endif %}.jinja new file mode 100644 index 0000000..f9054a1 --- /dev/null +++ b/cppjswasm/.github/workflows/{% if add_docs %}docs.yaml{% endif %}.jinja @@ -0,0 +1,26 @@ +name: Publish Docs + +on: + push: + branches: + - main + workflow_dispatch: +permissions: + contents: write +jobs: + docs: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v6 + - uses: actions-ext/python/setup@main + - uses: actions-ext/node/setup@main + - uses: mymindstorm/setup-emsdk@v14 + - run: make develop + - run: uv pip install . + - run: uv pip install yardang + - run: yardang build + - uses: peaceiris/actions-gh-pages@v4 + with: + publish_branch: gh-pages + github_token: {% raw %}${{ secrets.GITHUB_TOKEN }}{% endraw %} + publish_dir: docs/html diff --git a/cppjswasm/.github/workflows/{% if add_wiki %}wiki.yaml{% endif %}.jinja b/cppjswasm/.github/workflows/{% if add_wiki %}wiki.yaml{% endif %}.jinja new file mode 100644 index 0000000..bf675c2 --- /dev/null +++ b/cppjswasm/.github/workflows/{% if add_wiki %}wiki.yaml{% endif %}.jinja @@ -0,0 +1,27 @@ +name: Publish Wiki + +on: + push: + branches: + - main + paths: + - "docs/**" + - "README.md" + workflow_dispatch: + +concurrency: + group: docs + cancel-in-progress: true + +permissions: + contents: write + +jobs: + deploy: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v6 + - run: cp README.md docs/wiki/Home.md + - uses: Andrew-Chen-Wang/github-wiki-action@v5 + with: + path: docs/wiki diff --git a/cppjswasm/.gitignore.jinja b/cppjswasm/.gitignore.jinja new file mode 100644 index 0000000..e0f91eb --- /dev/null +++ b/cppjswasm/.gitignore.jinja @@ -0,0 +1,163 @@ +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.a +*.so +*.obj +*.dll +*.exp +*.lib + +# Distribution / packaging +.Python +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +pip-wheel-metadata/ +share/python-wheels/ +*.egg-info/ +.installed.cfg +*.egg +MANIFEST + +# PyInstaller +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.nox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +junit.xml +*.cover +*.py,cover +.hypothesis/ +.pytest_cache/ + +# Translations +*.mo +*.pot + +# Django stuff: +*.log +local_settings.py +db.sqlite3 +db.sqlite3-journal + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# PyBuilder +target/ + +# IPython +profile_default/ +ipython_config.py + +# pyenv +.python-version + +# pipenv +Pipfile.lock + +# PEP 582; used by e.g. github.com/David-OConnor/pyflow +__pypackages__/ + +# Celery stuff +celerybeat-schedule +celerybeat.pid + +# SageMath parsed files +*.sage.py + +# Environments +.env +.venv +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ + +# Spyder project settings +.spyderproject +.spyproject + +# Rope project settings +.ropeproject + +# mkdocs documentation +/site + +# mypy +.mypy_cache/ +.dmypy.json +dmypy.json + +# Pyre type checker +.pyre/ + +# Documentation +/site +index.md +docs/_build/ +docs/src/_build/ +docs/api +docs/index.md +docs/html +docs/jupyter_execute +index.md + +# JS +js/coverage +js/dist +js/lib +js/node_modules +js/test-results +js/playwright-report +js/*.tgz +{{module}}/extension + +# Jupyter +.ipynb_checkpoints +.autoversion +Untitled*.ipynb +!{{module}}/extension/{{module}}.json +!{{module}}/extension/install.json +{{module}}/nbextension +{{module}}/labextension + +# Mac +.DS_Store + +# C++ +*.o +*.dSYM + +# Emscripten SDK (locally installed) +emsdk/ diff --git a/cppjswasm/.vscode/settings.json b/cppjswasm/.vscode/settings.json new file mode 100644 index 0000000..75a1a79 --- /dev/null +++ b/cppjswasm/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "eslint.workingDirectories": ["./js"] +} diff --git a/cppjswasm/LICENSE.jinja b/cppjswasm/LICENSE.jinja new file mode 100644 index 0000000..ee2a86d --- /dev/null +++ b/cppjswasm/LICENSE.jinja @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + 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. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/cppjswasm/Makefile.jinja b/cppjswasm/Makefile.jinja new file mode 100644 index 0000000..05576a5 --- /dev/null +++ b/cppjswasm/Makefile.jinja @@ -0,0 +1,202 @@ +######### +# BUILD # +######### +EMSDK_ENV := $(shell pwd)/emsdk/emsdk_env.sh +ACTIVATE_EMSDK := if [ -f "$(EMSDK_ENV)" ]; then . "$(EMSDK_ENV)" 2>/dev/null; fi + +.PHONY: develop-py develop-js develop-cpp develop +develop-py: + $(ACTIVATE_EMSDK) && uv pip install -e .[develop] + +develop-js: requirements-js + +develop-cpp: + make -C cpp develop + +develop: develop-cpp develop-js develop-py ## setup project for development + +.PHONY: requirements-py requirements-js requirements-cpp requirements +requirements-py: ## install prerequisite python build requirements + python -m pip install --upgrade pip toml + python -m pip install `python -c 'import toml; c = toml.load("pyproject.toml"); print("\n".join(c["build-system"]["requires"]))'` + python -m pip install `python -c 'import toml; c = toml.load("pyproject.toml"); print(" ".join(c["project"]["optional-dependencies"]["develop"]))'` + +requirements-js: ## install prerequisite javascript build requirements + cd js; pnpm install && npx playwright install + +requirements-cpp: ## install prerequisite C++ build requirements + make -C cpp requirements + +requirements: requirements-cpp requirements-js requirements-py ## setup project for development + +.PHONY: build-py build-js build-cpp build +build-py: + $(ACTIVATE_EMSDK) && python -m build -w -n + +build-js: + $(ACTIVATE_EMSDK) && cd js && pnpm build + +build-cpp: + make -C cpp build + +build: build-cpp build-js build-py ## build the project + +.PHONY: install +install: ## install python library + uv pip install . + +######### +# LINTS # +######### +.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}} + +lint-js: ## run js linter + cd js; pnpm lint + +lint-cpp: ## run C++ linter + make -C cpp lint + +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 %} + +lint: lint-cpp lint-js lint-py lint-docs ## run project linters + +# alias +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}} + +fix-js: ## fix js formatting + cd js; pnpm fix + +fix-cpp: ## fix C++ formatting + make -C cpp fix + +fix-docs: ## autoformat docs with mdformat and codespell + python -m mdformat README.md {% if add_wiki %}docs/wiki/{% endif %} + python -m codespell_lib --write README.md {% if add_wiki %}docs/wiki/{% endif %} + +fix: fix-cpp fix-js fix-py fix-docs ## run project autoformatters + +# alias +format: fix + +################ +# Other Checks # +################ +.PHONY: check-manifest checks check + +check-manifest: ## check python sdist manifest with check-manifest + check-manifest -v + +checks: check-manifest + +# alias +check: checks + +######### +# TESTS # +######### +.PHONY: test-py tests-py coverage-py +test-py: ## run python 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 + +.PHONY: test-js tests-js coverage-js +test-js: ## run js tests + cd js; pnpm test + +# alias +tests-js: test-js + +coverage-js: test-js ## run js tests and collect test coverage + +.PHONY: test-cpp tests-cpp coverage-cpp +test-cpp: ## run C++ tests + make -C cpp test + +# alias +tests-cpp: test-cpp + +coverage-cpp: ## run C++ tests and collect test coverage + make -C cpp coverage + +.PHONY: test coverage tests +test: test-py test-js test-cpp ## run all tests +coverage: coverage-py coverage-js coverage-cpp ## run all tests and collect test coverage + +# alias +tests: test + +########### +# VERSION # +########### +.PHONY: show-version patch minor major + +show-version: ## show current library version + @bump-my-version show current_version + +patch: ## bump a patch version + @bump-my-version bump patch + +minor: ## bump a minor version + @bump-my-version bump minor + +major: ## bump a major version + @bump-my-version bump major + +######## +# DIST # +######## +.PHONY: dist-py-wheel dist-py-sdist dist-check dist publish + +dist-py-wheel: ## build python wheel + python -m cibuildwheel --output-dir dist + +dist-py-sdist: ## build python sdist + python -m build --sdist -o dist + +dist-js: # build js dists + cd js; pnpm pack + +dist-check: ## run python dist checker with twine + python -m twine check dist/* + +dist: clean build dist-js dist-py-wheel dist-py-sdist dist-check ## build all dists + +publish: dist ## publish python assets + +######### +# CLEAN # +######### +.PHONY: deep-clean clean + +deep-clean: ## clean everything from the repository + git clean -fdx + +clean: ## clean the repository + rm -rf .coverage coverage cover htmlcov logs build dist *.egg-info + +############################################################################################ + +.PHONY: help + +# Thanks to Francoise at marmelab.com for this +.DEFAULT_GOAL := help +help: + @grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' + +print-%: + @echo '$*=$($*)' diff --git a/cppjswasm/README.md.jinja b/cppjswasm/README.md.jinja new file mode 100644 index 0000000..d8ce83b --- /dev/null +++ b/cppjswasm/README.md.jinja @@ -0,0 +1,13 @@ +# {{project_name}} + +{{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}}) + +## Overview + +> [!NOTE] +> This library was generated using [copier](https://copier.readthedocs.io/en/stable/) from the [Base Python Project Template repository](https://github.com/python-project-templates/base). diff --git a/cppjswasm/cpp/Makefile.jinja b/cppjswasm/cpp/Makefile.jinja new file mode 100644 index 0000000..69dc408 --- /dev/null +++ b/cppjswasm/cpp/Makefile.jinja @@ -0,0 +1,53 @@ + +EMSDK_VERSION ?= latest +EMSDK_DIR := $(shell cd .. && pwd)/emsdk + +.PHONY: requirements develop build +requirements: ## install emsdk locally and ensure C++ toolchain is available + @if [ ! -d "$(EMSDK_DIR)" ]; then \ + echo "Installing emsdk locally into $(EMSDK_DIR)..." && \ + git clone https://github.com/emscripten-core/emsdk.git "$(EMSDK_DIR)" && \ + cd "$(EMSDK_DIR)" && ./emsdk install $(EMSDK_VERSION) && ./emsdk activate $(EMSDK_VERSION); \ + else \ + echo "emsdk already installed at $(EMSDK_DIR)"; \ + fi + @echo "Ensure C++ compiler (g++/clang++) and clang-format are available" + +develop: requirements ## install required dev dependencies + +build: ## verify standalone C++ compilation + @echo "C++ library is compiled as part of Python (hatch-cpp) and JavaScript (emscripten) builds" + +.PHONY: lint lints fix format +lint: ## run clang-format for linting + clang-format --dry-run -Werror -i -style=file:../.clang-format `find . -name "*.*pp"` +# alias +lints: lint + +fix: ## fix code with clang-format + clang-format -i -style=file:../.clang-format `find . -name "*.*pp"` +#alias +format: fix + +.PHONY: check checks +check: ## verify compilation + @echo "C++ library is checked as part of Python and JavaScript builds" +# alias +checks: check + +.PHONY: test tests coverage +test: ## run the tests + @echo "C++ tests are run through Python and JavaScript test suites" + +# alias +tests: test + +coverage: test + +# Thanks to Francoise at marmelab.com for this +.DEFAULT_GOAL := help +help: + @grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' + +print-%: + @echo '$*=$($*)' diff --git a/cppjswasm/cpp/{{project_name_formatted}}/example.cpp.jinja b/cppjswasm/cpp/{{project_name_formatted}}/example.cpp.jinja new file mode 100644 index 0000000..a79a14c --- /dev/null +++ b/cppjswasm/cpp/{{project_name_formatted}}/example.cpp.jinja @@ -0,0 +1,6 @@ +#include "{{project_name_formatted}}/example.hpp" + +Example::Example(const std::string& value) + : stuff(value) {} + +int add(int i, int j) { return i + j; } diff --git a/cppjswasm/cpp/{{project_name_formatted}}/example.hpp b/cppjswasm/cpp/{{project_name_formatted}}/example.hpp new file mode 100644 index 0000000..fbc0cde --- /dev/null +++ b/cppjswasm/cpp/{{project_name_formatted}}/example.hpp @@ -0,0 +1,11 @@ +#pragma once +#include + +class Example { +public: + std::string stuff; + + Example(const std::string& value); +}; + +int add(int i, int j); diff --git a/cppjswasm/cpp/{{project_name_formatted}}/extension.cpp.jinja b/cppjswasm/cpp/{{project_name_formatted}}/extension.cpp.jinja new file mode 100644 index 0000000..6a7d50f --- /dev/null +++ b/cppjswasm/cpp/{{project_name_formatted}}/extension.cpp.jinja @@ -0,0 +1,18 @@ +#include +#include + +#include "{{project_name_formatted}}/example.hpp" + +namespace py = pybind11; + +PYBIND11_MODULE(extension_cpp, m) { + m.doc() = "pybind11 extension module"; + + m.def("add", &add, "A function that adds two numbers"); + + py::class_(m, "Example") + .def(py::init()) + .def_readwrite("stuff", &Example::stuff) + .def("__str__", [](const Example& e) { return e.stuff; }) + .def("__repr__", [](const Example& e) { return std::string("Example<") + e.stuff + ">"; }); +} diff --git a/cppjswasm/js/build.mjs.jinja b/cppjswasm/js/build.mjs.jinja new file mode 100644 index 0000000..e8f3e67 --- /dev/null +++ b/cppjswasm/js/build.mjs.jinja @@ -0,0 +1,95 @@ +import { NodeModulesExternal } from "@finos/perspective-esbuild-plugin/external.js"; +import { build } from "@finos/perspective-esbuild-plugin/build.js"; +import { BuildCss } from "@prospective.co/procss/target/cjs/procss.js"; +import { getarg } from "./tools/getarg.mjs"; +import fs from "fs"; +import cpy from "cpy"; +import path_mod from "path"; + +const DEBUG = getarg("--debug"); + +const COMMON_DEFINE = { + global: "window", + "process.env.DEBUG": `${DEBUG}`, +}; + +const BUILD = [ + { + define: COMMON_DEFINE, + entryPoints: ["src/ts/index.ts"], + plugins: [NodeModulesExternal()], + format: "esm", + loader: { + ".css": "text", + ".html": "text", + }, + 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/less", "dist/css"); + fs.mkdirSync(outpath, { recursive: true }); + + fs.readdirSync(path).forEach((file_or_folder) => { + if (file_or_folder.endsWith(".less")) { + const outfile = file_or_folder.replace(".less", ".css"); + const builder = new BuildCss(""); + builder.add( + `${path}/${file_or_folder}`, + fs + .readFileSync(path_mod.join(`${path}/${file_or_folder}`)) + .toString(), + ); + fs.writeFileSync( + `${path.replace("src/less", "dist/css")}/${outfile}`, + builder.compile().get(outfile), + ); + } else { + process_path(`${path}/${file_or_folder}`); + } + }); + }; + // recursively process all less files in src/less + process_path("src/less"); + cpy("src/css/*", "dist/css/"); +} + +async function 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() { + 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"); +} + +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(); +} + +build_all(); diff --git a/cppjswasm/js/package.json.jinja b/cppjswasm/js/package.json.jinja new file mode 100644 index 0000000..7aa4155 --- /dev/null +++ b/cppjswasm/js/package.json.jinja @@ -0,0 +1,63 @@ +{ + "name": "{{project_name_formatted}}", + "version": "0.1.0", + "description": "{{project_description}}", + "repository": "git@github.com:{{github}}/{{project_name_formatted}}.git", + "author": "{{team}} <{{email}}>", + "license": "Apache-2.0", + "private": true, + "type": "module", + "unpkg": "dist/cdn/index.js", + "jsdelivr": "dist/cdn/index.js", + "exports": { + ".": { + "types": "./dist/esm/index.d.ts", + "default": "./dist/esm/index.js" + }, + "./dist/*": "./dist/*", + "./package.json": "./package.json" + }, + "files": [ + "dist/**/*", + "index.d.ts" + ], + "types": "./dist/esm/index.d.ts", + "publishConfig": { + "access": "public" + }, + "scripts": { + "build:cpp": "bash -c 'if [ -f ../emsdk/emsdk_env.sh ]; then source ../emsdk/emsdk_env.sh 2>/dev/null; fi && mkdir -p dist/pkg && 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", + "dev": "npm-run-all -p start watch", + "lint:js": "prettier --check \"src/**/*.{js,ts,jsx,tsx,less,css}\" \"tests/**/*.{js,ts,jsx,tsx}\" \"*.mjs\" \"*.json\"", + "lint:cpp": "clang-format --dry-run -Werror -style=file:../.clang-format src/cpp/*.cpp", + "lint": "npm-run-all lint:*", + "fix:js": "prettier --write \"src/**/*.{js,ts,jsx,tsx,less,css}\" \"tests/**/*.{js,ts,jsx,tsx}\" \"*.mjs\" \"*.json\"", + "fix:cpp": "clang-format -i -style=file:../.clang-format src/cpp/*.cpp", + "fix": "npm-run-all fix:*", + "preinstall": "npx only-allow pnpm", + "prepack": "pnpm run build", + "start": "http-server -p 3000 -o examples/", + "start:tests": "http-server -p 3000 ", + "test:js": "playwright test", + "test": "npm-run-all test:*", + "watch": "nodemon --watch src -e ts,less,html,cpp,hpp --exec \"pnpm build:debug\"" + }, + "dependencies": {}, + "devDependencies": { + "@finos/perspective-esbuild-plugin": "^3.2.1", + "@playwright/test": "^1.56.1", + "@prospective.co/procss": "^0.1.17", + "cpy": "^12.1.0", + "esbuild": "^0.27.0", + "esbuild-plugin-less": "^1.3.35", + "http-server": "^14.1.1", + "nodemon": "^3.1.10", + "npm-run-all": "^4.1.5", + "prettier": "^3.7.4", + "typescript": "^5.9.3" + } +} diff --git a/cppjswasm/js/playwright.config.js b/cppjswasm/js/playwright.config.js new file mode 100644 index 0000000..e49718b --- /dev/null +++ b/cppjswasm/js/playwright.config.js @@ -0,0 +1,30 @@ +import { defineConfig, devices } from "@playwright/test"; + +export default defineConfig({ + testDir: "tests", + fullyParallel: true, + forbidOnly: !!process.env.CI, + retries: process.env.CI ? 2 : 0, + workers: process.env.CI ? 1 : undefined, + reporter: [ + ["line"], + ["html", { outputFile: "playwright-report/index.html", open: "never" }], + ["junit", { outputFile: "junit.xml" }], + ], + use: { + baseURL: "http://127.0.0.1:3000", + trace: "on-first-retry", + }, + projects: [ + { + name: "chromium", + use: { ...devices["Desktop Chrome"] }, + }, + ], + webServer: { + command: "yarn start:tests", + url: "http://127.0.0.1:3000", + reuseExistingServer: !process.env.CI, + timeout: 120 * 1000, + }, +}); diff --git a/cppjswasm/js/src/cpp/bindings.cpp.jinja b/cppjswasm/js/src/cpp/bindings.cpp.jinja new file mode 100644 index 0000000..80c62b8 --- /dev/null +++ b/cppjswasm/js/src/cpp/bindings.cpp.jinja @@ -0,0 +1,11 @@ +#include + +#include "{{project_name_formatted}}/example.hpp" + +using namespace emscripten; + +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 new file mode 100644 index 0000000..5ecca1e --- /dev/null +++ b/cppjswasm/js/src/html/index.html.jinja @@ -0,0 +1,13 @@ + + + + {{project_name}} + + + + + + + + + diff --git a/cppjswasm/js/src/less/index.less b/cppjswasm/js/src/less/index.less new file mode 100644 index 0000000..e69de29 diff --git a/cppjswasm/js/src/ts/css.d.ts b/cppjswasm/js/src/ts/css.d.ts new file mode 100644 index 0000000..31058d4 --- /dev/null +++ b/cppjswasm/js/src/ts/css.d.ts @@ -0,0 +1,4 @@ +declare module "*.css" { + const content: string; + export default content; +} diff --git a/cppjswasm/js/src/ts/index.ts.jinja b/cppjswasm/js/src/ts/index.ts.jinja new file mode 100644 index 0000000..d07a5e0 --- /dev/null +++ b/cppjswasm/js/src/ts/index.ts.jinja @@ -0,0 +1,11 @@ +// @ts-ignore - emscripten generated module +import createModule from "../../dist/pkg/{{module}}.js"; + +export { createModule }; + +export const placeholder = ""; + +export const add = async (i: number, j: number): Promise => { + const mod = await createModule(); + return mod.add(i, j); +}; diff --git a/cppjswasm/js/tests/index.spec.js b/cppjswasm/js/tests/index.spec.js new file mode 100644 index 0000000..0fa5b16 --- /dev/null +++ b/cppjswasm/js/tests/index.spec.js @@ -0,0 +1,7 @@ +import { test, expect } from "@playwright/test"; + +test.describe("Basics", () => { + test("basic", async ({ page }) => { + await expect("").toBe(""); + }); +}); diff --git a/cppjswasm/js/tools/getarg.mjs b/cppjswasm/js/tools/getarg.mjs new file mode 100644 index 0000000..30793a7 --- /dev/null +++ b/cppjswasm/js/tools/getarg.mjs @@ -0,0 +1,23 @@ +export const getarg = (flag, ...args) => { + if (Array.isArray(flag)) { + flag = flag.map((x, i) => x + (args[i] || "")).join(""); + } + const argv = process.argv.slice(2); + if (flag) { + const index = argv.indexOf(flag); + if (index > -1) { + const next = argv[index + 1]; + if (next) { + return next; + } else { + return true; + } + } + } else { + return argv + .map(function (arg) { + return "'" + arg.replace(/'/g, "'\\''") + "'"; + }) + .join(" "); + } + }; \ No newline at end of file diff --git a/cppjswasm/js/tsconfig.json b/cppjswasm/js/tsconfig.json new file mode 100644 index 0000000..b25bdae --- /dev/null +++ b/cppjswasm/js/tsconfig.json @@ -0,0 +1,24 @@ +{ + "compilerOptions": { + "allowImportingTsExtensions": true, + "declaration": true, + "emitDeclarationOnly": true, + "emitDecoratorMetadata": true, + "experimentalDecorators": true, + "isolatedModules": true, + "lib": ["ES2020", "DOM", "DOM.Iterable"], + "module": "ESNext", + "moduleResolution": "Bundler", + "noUnusedLocals": true, + "noUnusedParameters": true, + "noFallthroughCasesInSwitch": true, + "outDir": "./dist/esm", + "resolveJsonModule": true, + "rootDir": ".", + "skipLibCheck": true, + "strict": true, + "target": "ES2020", + "useDefineForClassFields": true + }, + "include": ["./src/ts/*.ts", "./tests/*.ts"] +} diff --git a/cppjswasm/pyproject.toml.jinja b/cppjswasm/pyproject.toml.jinja new file mode 100644 index 0000000..53d5739 --- /dev/null +++ b/cppjswasm/pyproject.toml.jinja @@ -0,0 +1,218 @@ +[build-system] +requires = [ + "hatchling", + "hatch-cpp", + "hatch-js", + "pybind11", +] +build-backend = "hatchling.build" + +[project] +name = "{{project_name_formatted}}" +authors = [ + {name = "{{team}}", email = "{{email}}"}, +] +description = "{{project_description}}" +readme = "README.md" +license = { text = "Apache-2.0" } +version = "0.1.0" +requires-python = ">=3.10" +keywords = [] + +classifiers = [ + "Development Status :: 3 - Alpha", + "Programming Language :: C++", + "Programming Language :: Python", + "Programming Language :: Python :: Implementation :: CPython", + "Programming Language :: Python :: Implementation :: PyPy", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.13", + "Programming Language :: Python :: 3.14", +] + +dependencies = [] + +[project.optional-dependencies] +develop = [ + "build", + "bump-my-version", + "check-manifest", + "cibuildwheel", + "codespell>=2.4,<2.5", + "hatch-cpp", + "hatch-js", + "hatchling", + "mdformat>=0.7.22,<1.1", + "mdformat-tables>=1", + "pytest", + "pytest-cov", + "ruff>=0.9,<0.15", + "twine", + "ty", + "uv", + "wheel", +] + +[project.scripts] + +[project.urls] +Repository = "https://github.com/{{github}}/{{project_name_formatted}}" +Homepage = "https://github.com/{{github}}/{{project_name_formatted}}" + +[tool.bumpversion] +current_version = "0.1.0" +commit = true +tag = true +commit_args = "-s" + +[[tool.bumpversion.files]] +filename = "{{module}}/__init__.py" +search = '__version__ = "{current_version}"' +replace = '__version__ = "{new_version}"' + +[[tool.bumpversion.files]] +filename = "pyproject.toml" +search = 'version = "{current_version}"' +replace = 'version = "{new_version}"' + +[[tool.bumpversion.files]] +filename = "js/package.json" +search = '"version": "{current_version}"' +replace = '"version": "{new_version}"' + +[tool.check-manifest] +ignore = [ + ".copier-answers.yaml", + ".clang-format", + "js/pnpm-lock.yaml", + "Makefile", + ".vscode/*", + "{{module}}/extension/**/*", + "{{module}}/*.dll", + "{{module}}/*.dylib", + "{{module}}/*.so", + "docs/**/*", + "js/dist/**/*", +] + +[tool.cibuildwheel] +build = "cp310-*" +test-command = "pytest -vvv {project}/{{module}}/tests" +test-extras = "develop" + +[tool.cibuildwheel.linux] +environment = {SKIP_HATCH_JS="1"} +skip = "*i686* *musllinux*" + +[tool.cibuildwheel.macos] +environment = {MACOSX_DEPLOYMENT_TARGET="11.0", SKIP_HATCH_JS="1"} +archs = "arm64" + +[tool.cibuildwheel.windows] +environment = {SKIP_HATCH_JS="1"} +skip = "*win32 *arm_64" + +[tool.coverage.run] +branch = true +omit = [ + "{{module}}/tests/integration/", +] +[tool.coverage.report] +exclude_also = [ + "raise NotImplementedError", + "if __name__ == .__main__.:", + "@(abc\\.)?abstractmethod", +] +ignore_errors = true +fail_under = 50 + +[tool.hatch.build] +artifacts = [ + "{{module}}/*.dll", + "{{module}}/*.dylib", + "{{module}}/*.so", + "{{module}}/extension", +] + +[tool.hatch.build.sources] +src = "/" + +[tool.hatch.build.hooks.hatch-js] +path = "js" +build_cmd = "build" +tool = "pnpm" +targets = [ + "{{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"} +] + +[tool.hatch.build.targets.sdist] +packages = [ + "{{module}}", + "/js", + "/cpp", +] +sources = [ + ".", +] + +[tool.hatch.build.targets.wheel] +packages = [ + "{{module}}", +] +exclude = [ + "/js", + "/cpp", +] + +[tool.pytest.ini_options] +addopts = [ + "-vvv", + "--junitxml=junit.xml", +] +testpaths = "{{module}}/tests" + +[tool.ruff] +line-length = 150 + +[tool.ruff.lint] +extend-select = [ + "I", +] + +[tool.ruff.lint.isort] +combine-as-imports = true +default-section = "third-party" +known-first-party = [ + "{{module}}", +] +section-order = [ + "future", + "standard-library", + "third-party", + "first-party", + "local-folder", +] + +[tool.ruff.lint.per-file-ignores] +"__init__.py" = [ + "F401", + "F403", +] + +{%- if add_docs %} + +[tool.yardang] +title = "{{ project_name }}" +root = "README.md" +pages = [] +use-autoapi = true +{% endif %} diff --git a/cppjswasm/{% if add_wiki %}docs{% endif %}/wiki/Installation.md.jinja b/cppjswasm/{% if add_wiki %}docs{% endif %}/wiki/Installation.md.jinja new file mode 100644 index 0000000..8dfc880 --- /dev/null +++ b/cppjswasm/{% if add_wiki %}docs{% endif %}/wiki/Installation.md.jinja @@ -0,0 +1,19 @@ +## Pre-requisites + +You need Python >=3.10 on your machine to install `{{project_name_formatted}}`. + +## Install with `pip` + +```bash +pip install {{project_name_formatted}} +``` + +## Install with `conda` + +```bash +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). diff --git a/cppjswasm/{% if add_wiki %}docs{% endif %}/wiki/_Footer.md.jinja b/cppjswasm/{% if add_wiki %}docs{% endif %}/wiki/_Footer.md.jinja new file mode 100644 index 0000000..4a5fb4b --- /dev/null +++ b/cppjswasm/{% if add_wiki %}docs{% endif %}/wiki/_Footer.md.jinja @@ -0,0 +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)._ diff --git a/cppjswasm/{% if add_wiki %}docs{% endif %}/wiki/_Sidebar.md.jinja b/cppjswasm/{% if add_wiki %}docs{% endif %}/wiki/_Sidebar.md.jinja new file mode 100644 index 0000000..988b1ac --- /dev/null +++ b/cppjswasm/{% if add_wiki %}docs{% endif %}/wiki/_Sidebar.md.jinja @@ -0,0 +1,16 @@ + + +**[Home](Home)** + +**Get Started** + +- [Installation](Installation) +- [Contributing](Contribute) +- [Development Setup](Local-Development-Setup) +- [Build from Source](Build-from-Source) 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 new file mode 100644 index 0000000..509cbfa --- /dev/null +++ b/cppjswasm/{% if add_wiki %}docs{% endif %}/wiki/contribute/Build-from-Source.md.jinja @@ -0,0 +1,144 @@ +`{{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) +- [Clone](#clone) +- [Install Python dependencies](#install-python-dependencies) +- [Build](#build) +- [Lint and Autoformat](#lint-and-autoformat) +- [Testing](#testing) + +## 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 + +```bash +> make + +build build the library +clean clean the repository +fix run autofixers +install install library +lint run lints +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. + +## Clone + +Clone the repo with: + +```bash +git clone https://github.com/{{github}}/{{project_name_formatted}}.git +cd {{project_name_formatted}} +``` + +## Install C++ Compiler + +Ensure you have a C++ compiler available (e.g. `g++`, `clang++`, or MSVC on Windows). + +## Install Emscripten + +Follow the instructions for [installing Emscripten SDK](https://emscripten.org/docs/getting_started/downloads.html) for your system. This is required for building the JavaScript/WebAssembly bindings. + +## Install Python dependencies + +Python build and develop dependencies are specified in the `pyproject.toml`, but you can manually install them: + +```bash +make requirements +``` + +Note that these dependencies would otherwise be installed normally as part of [PEP517](https://peps.python.org/pep-0517/) / [PEP518](https://peps.python.org/pep-0518/). + +## Build + +Build the python project in the usual manner: + +```bash +make build +``` + +## Lint and Autoformat + +`{{project_name_formatted}}` has linting and auto formatting. + +| Language | Linter | Autoformatter | Description | +| :--------- | :------------- | :------------- | :---------- | +| Python | `ruff` | `ruff` | Style | +| Python | `ruff` | `ruff` | Imports | +| C++ | `clang-format` | `clang-format` | Style | +| JavaScript | `prettier` | `prettier` | Style | +| Markdown | `mdformat` | `mdformat` | Style | +| Markdown | `codespell` | | Spelling | + +**Python Linting** + +```bash +make lint-py +``` + +**Python Autoformatting** + +```bash +make fix-py +``` + +**C++ Linting** + +```bash +make lint-cpp +``` + +**C++ Autoformatting** + +```bash +make fix-cpp +``` + +**JavaScript Linting** + +```bash +make lint-js +``` + +**JavaScript Autoformatting** + +```bash +make fix-js +``` + +**Documentation Linting** + +```bash +make lint-docs +``` + +**Documentation Autoformatting** + +```bash +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 + +```bash +make develop +``` + +**Python** + +```bash +make test-py +``` + +**JavaScript** + +```bash +make test-js +``` 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 new file mode 100644 index 0000000..7deea95 --- /dev/null +++ b/cppjswasm/{% if add_wiki %}docs{% endif %}/wiki/contribute/Contribute.md.jinja @@ -0,0 +1,15 @@ +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. +> 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 **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. + +For **documentation updates**, make PRs that update the pages in `/docs/wiki`. The documentation is pushed to the GitHub wiki automatically through a GitHub workflow. Note that direct updates to this wiki will be overwritten. 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 new file mode 100644 index 0000000..897872a --- /dev/null +++ b/cppjswasm/{% if add_wiki %}docs{% endif %}/wiki/contribute/Local-Development-Setup.md.jinja @@ -0,0 +1,55 @@ +## Table of Contents + +- [Table of Contents](#table-of-contents) +- [Step 1: Build from Source](#step-1-build-from-source) +- [Step 2: Configuring Git and GitHub for Development](#step-2-configuring-git-and-github-for-development) + - [Create your fork](#create-your-fork) + - [Configure remotes](#configure-remotes) + - [Authenticating with GitHub](#authenticating-with-github) +- [Guidelines](#guidelines) + +## Step 1: Build from Source + +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. + +## 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 +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. + +### Authenticating with GitHub + +If you have not already configured `ssh` access to GitHub, you can find +instructions to do so +[here](https://docs.github.com/en/authentication/connecting-to-github-with-ssh), +including instructions to create an SSH key if you have not done +so. Authenticating with SSH is usually the easiest route. If you are working in +an environment that does not allow SSH connections to GitHub, you can look into +[configuring a hardware +passkey](https://docs.github.com/en/authentication/authenticating-with-a-passkey/about-passkeys) +or adding a [personal access +token](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens) +to avoid the need to type in your password every time you push to your fork. + +## Guidelines + +After developing a change locally, ensure that both [lints](Build-from-Source#lint-and-autoformat) and [tests](Build-from-Source#testing) pass. Commits should be squashed into logical units, and all commits must be signed (e.g. with the `-s` git flag). We require [Developer Certificate of Origin](https://en.wikipedia.org/wiki/Developer_Certificate_of_Origin) for all contributions. + +If your work is still in-progress, open a [draft pull request](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/about-pull-requests#draft-pull-requests). Otherwise, open a normal pull request. It might take a few days for a maintainer to review and provide feedback, so please be patient. If a maintainer asks for changes, please make said changes and squash your commits if necessary. If everything looks good to go, a maintainer will approve and merge your changes for inclusion in the next release. + +Please note that non substantive changes, large changes without prior discussion, etc, are not accepted and pull requests may be closed. diff --git a/cppjswasm/{{_copier_conf.answers_file}}.jinja b/cppjswasm/{{_copier_conf.answers_file}}.jinja new file mode 100644 index 0000000..a537c26 --- /dev/null +++ b/cppjswasm/{{_copier_conf.answers_file}}.jinja @@ -0,0 +1,2 @@ +# Changes here will be overwritten by Copier +{{ _copier_answers|to_nice_yaml }} \ No newline at end of file diff --git a/cppjswasm/{{module}}/__init__.py b/cppjswasm/{{module}}/__init__.py new file mode 100644 index 0000000..6fc0df2 --- /dev/null +++ b/cppjswasm/{{module}}/__init__.py @@ -0,0 +1,18 @@ +import os +import os.path + +from .extension_cpp import * + +__version__ = "0.1.0" + + +def include_path(): + return os.path.abspath(os.path.join(os.path.dirname(__file__), "include")) + + +def bin_path(): + return os.path.abspath(os.path.join(os.path.dirname(__file__), "bin")) + + +def lib_path(): + return os.path.abspath(os.path.join(os.path.dirname(__file__), "lib")) diff --git a/cppjswasm/{{module}}/tests/test_all.py.jinja b/cppjswasm/{{module}}/tests/test_all.py.jinja new file mode 100644 index 0000000..4097771 --- /dev/null +++ b/cppjswasm/{{module}}/tests/test_all.py.jinja @@ -0,0 +1,6 @@ +from {{module}} import add + + +class TestAll: + def test_all(self): + assert 3 == add(1, 2) diff --git a/examples/cppjswasm.yaml b/examples/cppjswasm.yaml new file mode 100644 index 0000000..0cbde15 --- /dev/null +++ b/examples/cppjswasm.yaml @@ -0,0 +1,10 @@ +--- +add_docs: true +add_wiki: true +add_extension: cppjswasm +email: 3105306+timkpaine@users.noreply.github.com +github: python-project-templates +project_description: A C++-JavaScript-Python project template +project_name: python template cppjswasm +python_version_primary: '3.11' +team: Python Project Template Authors diff --git a/python-template-cppjswasm b/python-template-cppjswasm new file mode 120000 index 0000000..51d87eb --- /dev/null +++ b/python-template-cppjswasm @@ -0,0 +1 @@ +../python-template-cppjswasm \ No newline at end of file From d40e345415040c53a301874a64437d864d33b687 Mon Sep 17 00:00:00 2001 From: Tim Paine <3105306+timkpaine@users.noreply.github.com> Date: Sat, 14 Feb 2026 18:16:54 -0500 Subject: [PATCH 2/2] fix CI: remove duplicate git init in test-cpp, add fail-fast: false, symlink clang-format, deduplicate cpp matrix entry --- .github/workflows/build.yaml | 5 +++-- Makefile | 1 - 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index f16329a..c58a0a4 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -21,15 +21,15 @@ permissions: jobs: build: strategy: + fail-fast: false matrix: template: - python - # - cpp + - cpp - js - jupyter - rust - rustjswasm - - cpp - cppjswasm os: - ubuntu-latest @@ -62,6 +62,7 @@ jobs: run: | if [[ "$RUNNER_OS" == "Linux" ]]; then sudo apt-get install -y clang-format-14 + sudo ln -sf /usr/bin/clang-format-14 /usr/bin/clang-format elif [[ "$RUNNER_OS" == "macOS" ]]; then brew install clang-format fi diff --git a/Makefile b/Makefile index 7e1ae53..7d005ea 100644 --- a/Makefile +++ b/Makefile @@ -64,7 +64,6 @@ test-python: test-cpp: cd ../python-template-cpp && git config --global user.name "github-actions" && git config --global user.email "41898282+github-actions[bot]@users.noreply.github.c@example.com" && git init && git add . && git commit -m "initial commit" - cd ../python-template-cpp && git init && git add . && git commit -m "initial commit" cd ../python-template-cpp && make develop cd ../python-template-cpp && make lint cd ../python-template-cpp && make checks