Skip to content

Commit

Permalink
specs: switch from YAML to JSON
Browse files Browse the repository at this point in the history
Fix failing CI on MacOS:

      File "/Users/runner/work/gopro-lib-node.gl/gopro-lib-node.gl/venv/lib/python3.11/site-packages/setuptools/wheel.py", line 162, in _convert_metadata
        os.rename(dist_info, egg_info)
    OSError: [Errno 66] Directory not empty: '/Users/runner/work/gopro-lib-node.gl/gopro-lib-node.gl/pynodegl/.eggs/PyYAML-6.0-py3.11-macosx-10.9-universal2.egg/PyYAML-6.0.dist-info' -> '/Users/runner/work/gopro-lib-node.gl/gopro-lib-node.gl/pynodegl/.eggs/PyYAML-6.0-py3.11-macosx-10.9-universal2.egg/EGG-INFO'

Python 3.11 works locally on Linux, so it's likely something broken in
PyYAML wheel.

Similarly, trying ruamel.yaml fails on Windows:

    ImportError: cannot import name 'YAML' from 'ruamel.yaml' (d:\a\gopro-lib-node.gl\gopro-lib-node.gl\pynodegl\.eggs\ruamel.yaml.clib-0.2.7-py3.8-win-amd64.egg\ruamel\yaml\__init__.py)

It is thus decided to simplify the build by using a JSON specs instead
of YAML.
  • Loading branch information
ubitux authored and cboesch-gpsw committed Nov 23, 2022
1 parent 1fa4d19 commit 3d83978
Show file tree
Hide file tree
Showing 5 changed files with 817 additions and 860 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ Versioning](https://semver.org/spec/v2.0.0.html) for `libnodegl`.
### Fixed
- Color channel difference in `ngl-diff` is now done in linear space

### Changed
- The installed `nodes.specs` is now in `JSON` instead of `YAML`

## [2022.8] [libnodegl 0.6.1] - 2022-09-22
### Fixed
- Crash with specific draw time sequences in some time filtered diamond-tree
Expand Down
6 changes: 3 additions & 3 deletions doc/dev/expl/pynodegl.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ graph

### libnodegl → nodes.specs

`libnodegl` writes the [nodes.specs][specs] specifications in YAML using a
`libnodegl` writes the [nodes.specs][specs] specifications in JSON using a
dedicated tool ([gen_specs.c][gen-specs-c]) crawling the internal node C
definitions.

Expand All @@ -59,13 +59,13 @@ generated `Makefile`) is installed on the system or targeted environment by the

In its [setup.py][pynodegl-setup], `pynodegl` uses `pkg-config` to query the
`libnodegl` installation data directory, in order to obtain the path to the
installed `nodes.specs` file. The file is then loaded as YAML file.
installed `nodes.specs` file. The file is then loaded as JSON file.

[pynodegl-setup]: /pynodegl/setup.py

### pynodegl → nodes_def.pyx

Using the loaded `nodes.specs` as YAML, `setup.py` writes the Cython code
Using the loaded `nodes.specs` as JSON, `setup.py` writes the Cython code
definitions into a `nodes_def.pyx` file.

### nodes_def.pyx ← Cython
Expand Down
17 changes: 12 additions & 5 deletions libnodegl/gen_specs.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,23 +33,26 @@ extern const struct param_specs ngli_params_specs[];

static void print_node_params(const char *name, const struct node_param *p)
{
printf("%s:\n", name);
printf(" \"%s\": [\n", name);
if (p) {
while (p->key) {
printf(" - [%s, %s, \"%s%s%s\"]\n", p->key, ngli_params_specs[p->type].name,
printf(" [\"%s\", \"%s\", \"%s%s%s\"]%s\n", p->key, ngli_params_specs[p->type].name,
(p->flags & NGLI_PARAM_FLAG_ALLOW_LIVE_CHANGE) ? "L" : "", /* [L]ive */
(p->flags & NGLI_PARAM_FLAG_ALLOW_NODE) ? "N" : "", /* [N]ode */
(p->flags & NGLI_PARAM_FLAG_NON_NULL) ? "M" : ""); /* [M]andatory */
(p->flags & NGLI_PARAM_FLAG_NON_NULL) ? "M" : "", /* [M]andatory */
(p + 1)->key ? "," : ""
);
p++;
}
}
printf("\n");
printf(" ]");
}

#define CLASS_COMMALIST(type_name, cls) &cls,

int main(void)
{
printf("{\n");
print_node_params("_Node", ngli_base_node_params);

static const struct node_class *node_classes[] = {
Expand All @@ -74,16 +77,20 @@ int main(void)
if (mapped_param) {
ngli_assert(mapped_param == p);
} else {
printf(",\n");
print_node_params(pname, p);
ngli_hmap_set(params_map, c->params_id, (void *)p);
}
printf("%s: %s\n\n", c->name, pname);
printf(",\n");
printf(" \"%s\": \"%s\"", c->name, pname);
ngli_free(pname);
} else {
printf(",\n");
print_node_params(c->name, p);
}
}

ngli_hmap_freep(&params_map);
printf("\n}\n");
return 0;
}
Loading

0 comments on commit 3d83978

Please sign in to comment.