Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: use copier #4

Closed
wants to merge 26 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions .git_archival.txt

This file was deleted.

101 changes: 0 additions & 101 deletions .github/CONTRIBUTING.md

This file was deleted.

4 changes: 2 additions & 2 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[submodule "kaitai_struct_cpp_stl_runtime"]
path = kaitai_struct_cpp_stl_runtime
path = {{project_name}}/kaitai_struct_cpp_stl_runtime
url = https://github.com/kaitai-io/kaitai_struct_cpp_stl_runtime.git
[submodule "kaitai_struct_compiler"]
path = kaitai_struct_compiler
path = {{project_name}}/kaitai_struct_compiler
url = https://github.com/ManasviGoyal/kaitai_struct_compiler.git
branch = ManasviGoyal/kaitai_awkward_target
73 changes: 30 additions & 43 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,19 +1,28 @@
ci:
autoupdate_commit_msg: "chore: update pre-commit hooks"
autofix_commit_msg: "style: pre-commit fixes"
autoupdate_schedule: "quarterly"

exclude: "^{{ project_name }}"

repos:
- repo: https://github.com/psf/black-pre-commit-mirror
rev: "23.7.0"
rev: "23.9.1"
hooks:
- id: black-jupyter

- repo: https://github.com/asottile/blacken-docs
rev: "1.15.0"
- repo: https://github.com/adamchainz/blacken-docs
rev: "1.16.0"
hooks:
- id: blacken-docs
additional_dependencies: [black==23.7.0]

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: "v0.0.292"
hooks:
- id: ruff
args: ["--fix", "--show-fixes"]

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: "v4.4.0"
hooks:
Expand All @@ -37,53 +46,31 @@ repos:
- id: rst-directive-colons
- id: rst-inline-touching-normal

- repo: https://github.com/pre-commit/mirrors-prettier
rev: "v3.0.1"
hooks:
- id: prettier
types_or: [yaml, markdown, html, css, scss, javascript, json]
args: [--prose-wrap=always]

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: "v0.0.284"
hooks:
- id: ruff
args: ["--fix", "--show-fixes"]

- repo: https://github.com/pre-commit/mirrors-clang-format
rev: "v16.0.6"
hooks:
- id: clang-format
types_or: [c++, c, cuda]

- repo: https://github.com/pre-commit/mirrors-mypy
rev: "v1.5.0"
rev: "v1.5.1"
hooks:
- id: mypy
files: src|tests
files: "(src|tests)"
args: []
additional_dependencies:
- click
- markdown-it-py
- pytest
- repo-review
- rich
- tomli
- types-PyYAML

- repo: https://github.com/codespell-project/codespell
rev: "v2.2.5"
hooks:
- id: codespell

- repo: https://github.com/shellcheck-py/shellcheck-py
rev: "v0.9.0.5"
hooks:
- id: shellcheck

- repo: local
- repo: https://github.com/pre-commit/mirrors-prettier
rev: "v3.0.3"
hooks:
- id: disallow-caps
name: Disallow improper capitalization
language: pygrep
entry: PyBind|Numpy|Cmake|CCache|Github|PyTest
exclude: .pre-commit-config.yaml
- id: prettier
types_or: [yaml, markdown, html, css, scss, javascript, json]
args: [--prose-wrap=always]

- repo: https://github.com/cheshirekow/cmake-format-precommit
rev: "v0.6.13"
- repo: https://github.com/codespell-project/codespell
rev: "v2.2.6"
hooks:
- id: cmake-format
- id: codespell
exclude: ^Gemfile\.lock$
args: ["-Lnd", "-w"]
45 changes: 22 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,33 +1,32 @@
# kaitai_awkward_runtime
# Awkward Array Kaitai Cookiecutter

Building Awkward Arrays using Kaitai binary file descriptors.
A [copier][] template for building Python packages from Kaitai Struct `.ksy`

Steps for reproducing the environment:

1. Clone `kaitai_awkward_runtime` repository:
```
git clone --recursive https://github.com/ManasviGoyal/kaitai_awkward_runtime.git
```
## To use

2. Change directory to `kaitai_awkward_runtime`:
```
cd kaitai_awkward_runtime
```
<!--- if we want to set up the package_name as ksy name we can just skip the PACKAGE_NAME argument -->
Install `copier`. Using [pipx][], that's:

3. Install the library, and open Python:
```
pip install .
python
```bash
pipx install copier
```

4. Print the returned `ak.Array`:
```python
import awkward_animal
awkward_array = awkward_animal.load("data/animal.raw")
print(awkward_array)
Now, run copier to generate your project:

```bash
copier copy gh:ManasviGoyal/kaitai_awkward_runtime <pkg>
```

(`<pkg>` is the path to put the new project)

You will get a nice CLI experience with answer validation. You will also get a
`.copier-answers.yml` file, which will allow you to perform updates in the
future.

> Note: Add `--vcs-ref=HEAD` to get the latest version instead of the last
> tagged version.



> **Info**
> `kaitai_awkward_runtime` depends upon `sbt`, and `gtest` dependencies.
[copier]: https://copier.readthedocs.io
[pipx]: https://pypa.github.io/pipx/
55 changes: 55 additions & 0 deletions copier.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# questions
_exclude:
- module-name

_envops:
keep_trailing_newline: false


project_name:
type: str
help: The name of your project
validator: >-
{% if not project_name %} You must provide a name for the project. {% endif %}

org:
type: str
help: The name of your (GitHub?) org
validator: >-
{% if not org %} You must provide a org for the project. It might just be
your user name on the site (like GitHub) you are targeting. {% endif %}

url:
type: str
help: The url to your GitHub or GitLab repository
default: "https://github.com/{{ org }}/{{ project_name }}"

full_name:
type: str
help: Your name
placeholder: My Name
validator: >-
{% if not full_name %} You must provide a name (possibly yours) to place in
your config files. {% endif %}

email:
type: str
help: Your email
placeholder: [email protected]
validator: >-
{% if not email %} You must provide an email (possibly yours) to place in
your config files, as required by PyPI. {% endif %}

project_short_description:
type: str
help: A short description of your project
default: A great package.

schema_name:
type: str
help: Then name of your KSY file to be added to "schemas/"

version:
type: str
help: The initial project version
default: 1.0.0
Binary file removed data/StilbeneAmCs_500_0253.b00
Binary file not shown.
Binary file removed data/StilbeneAmCs_500_0253.mca
Binary file not shown.
Binary file removed data/StilbeneAmCs_500_0253.set
Binary file not shown.
Binary file removed data/animal.raw
Binary file not shown.
Binary file removed data/fake.raw
Binary file not shown.
Binary file removed data/lists.raw
Binary file not shown.
Binary file removed data/numpy.raw
Binary file not shown.
1 change: 0 additions & 1 deletion data/records.raw

This file was deleted.

Binary file removed data/scdms.mid
Binary file not shown.
Binary file removed data/scdms_raw.bin
Binary file not shown.
45 changes: 0 additions & 45 deletions docs/conf.py

This file was deleted.

17 changes: 0 additions & 17 deletions docs/index.md

This file was deleted.

Loading