Skip to content

Cannot generate py or cpp types #47

@gtaylormb

Description

@gtaylormb

I'm able to generate sv only. When I try py or cpp the tool seems to crash with a traceback. OS is Rocky 9.

[gtaylor@gt-pa-desktop structs]$ python3.12 -m packtype --debug code package py ./output_dir spec.py
[10:15:18] DEBUG    Loading specification: spec.py                                                                                                                                            start.py:78
           DEBUG    Importing specification as a file: /home/gtaylor/git/packtype/examples/structs/spec.py                                                                                    start.py:86
           DEBUG    Discovered 1 baseline definitions                                                                                                                                         start.py:96
           DEBUG    Using output directory: /home/gtaylor/git/packtype/examples/structs/output_dir                                                                                           start.py:325
╭─────────────────────────────── Traceback (most recent call last) ────────────────────────────────╮
│ in _run_module_as_main:198                                                                       │
│ in _run_code:88                                                                                  │
│                                                                                                  │
│ /home/gtaylor/.local/lib/python3.12/site-packages/packtype/__main__.py:14 in <module>            │
│                                                                                                  │
│   11 if __name__ == "__main__":  # pragma: no cover                                              │
│   12 │   try:                                                                                    │
│   13 │   │   setup_logging_and_exceptions()                                                      │
│ ❱ 14 │   │   main(prog_name="packtype")                                                          │
│   15 │   except AssertionError as e:                                                             │
│   16 │   │   get_log().error(str(e))                                                             │
│   17 │   │   get_log().error(traceback.format_exc())                                             │
│                                                                                                  │
│ /home/gtaylor/.local/lib/python3.12/site-packages/click/core.py:1485 in __call__                 │
│                                                                                                  │
│   1482 │                                                                                         │
│   1483 │   def __call__(self, *args: t.Any, **kwargs: t.Any) -> t.Any:                           │
│   1484 │   │   """Alias for :meth:`main`."""                                                     │
│ ❱ 1485 │   │   return self.main(*args, **kwargs)                                                 │
│   1486                                                                                           │
│   1487                                                                                           │
│   1488 class _FakeSubclassCheck(type):                                                           │
│                                                                                                  │
│ /home/gtaylor/.local/lib/python3.12/site-packages/click/core.py:1406 in main                     │
│                                                                                                  │
│   1403 │   │   try:                                                                              │
│   1404 │   │   │   try:                                                                          │
│   1405 │   │   │   │   with self.make_context(prog_name, args, **extra) as ctx:                  │
│ ❱ 1406 │   │   │   │   │   rv = self.invoke(ctx)                                                 │
│   1407 │   │   │   │   │   if not standalone_mode:                                               │
│   1408 │   │   │   │   │   │   return rv                                                         │
│   1409 │   │   │   │   │   # it's not safe to `ctx.exit(rv)` here!                               │
│                                                                                                  │
│ /home/gtaylor/.local/lib/python3.12/site-packages/click/core.py:1873 in invoke                   │
│                                                                                                  │
│   1870 │   │   │   │   super().invoke(ctx)                                                       │
│   1871 │   │   │   │   sub_ctx = cmd.make_context(cmd_name, args, parent=ctx)                    │
│   1872 │   │   │   │   with sub_ctx:                                                             │
│ ❱ 1873 │   │   │   │   │   return _process_result(sub_ctx.command.invoke(sub_ctx))               │
│   1874 │   │                                                                                     │
│   1875 │   │   # In chain mode we create the contexts step by step, but after the                │
│   1876 │   │   # base command has been invoked.  Because at that point we do not                 │
│                                                                                                  │
│ /home/gtaylor/.local/lib/python3.12/site-packages/click/core.py:1269 in invoke                   │
│                                                                                                  │
│   1266 │   │   │   echo(style(message, fg="red"), err=True)                                      │
│   1267 │   │                                                                                     │
│   1268 │   │   if self.callback is not None:                                                     │
│ ❱ 1269 │   │   │   return ctx.invoke(self.callback, **ctx.params)                                │
│   1270 │                                                                                         │
│   1271 │   def shell_complete(self, ctx: Context, incomplete: str) -> list[CompletionItem]:      │
│   1272 │   │   """Return a list of completions for the incomplete value. Looks                   │
│                                                                                                  │
│ /home/gtaylor/.local/lib/python3.12/site-packages/click/core.py:824 in invoke                    │
│                                                                                                  │
│    821 │   │                                                                                     │
│    822 │   │   with augment_usage_errors(self):                                                  │
│    823 │   │   │   with ctx:                                                                     │
│ ❱  824 │   │   │   │   return callback(*args, **kwargs)                                          │
│    825 │                                                                                         │
│    826 │   def forward(self, cmd: Command, /, *args: t.Any, **kwargs: t.Any) -> t.Any:           │
│    827 │   │   """Similar to :meth:`invoke` but fills in default keyword                         │
│                                                                                                  │
│ /home/gtaylor/.local/lib/python3.12/site-packages/packtype/start.py:368 in code                  │
│                                                                                                  │
│   365 │   │   base_name = baseline_cls.__name__                                                  │
│   366 │   │   baseline = baseline_cls()                                                          │
│   367 │   │   # Iterate outputs to render                                                        │
│ ❱ 368 │   │   for tmpl_name, suffix in tmpl_list[language]:                                      │
│   369 │   │   │   out_path = outdir / f"{snake_case(base_name)}{suffix}"                         │
│   370 │   │   │   log.debug(f"Rendering {base_name} as {language} to {out_path}")                │
│   371 │   │   │   with out_path.open("w", encoding="utf-8") as fh:                               │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯
KeyError: 'py'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions