iotile / iotile/coretools

Consistent naming of entrypoints across iotile-build, packages and dev components

Open
#838 0 comments 0 reactions 0 assignees View on GitHub
iotile-build iotile-core type:enhancement
Dominant language
Python
Stars
14
Forks
7
PR merge metrics
No merged PRs in 30d

Description

We now have a unified entrypoint system for loading extensions into CoreTools. Each extension is a python entrypoint with a group, name and object that is either a module or arbitrary object depending on the group. However, depending on the source of the entrypoint, the `name` may not be consistent or configurable.

For many entrypoints, the `name` is not important, however for some it is such as `iotile-ship` recipe actions. See:
https://github.com/iotile/coretools/blob/master/iotileship/iotile/ship/recipe_manager.py#L28

The `entrypoint` name is used as the key to lookup the recipe action for referencing in a recipe. For python packages, the name is fully configurable in the `setup.py` file. However, for the development mode (`iotile registry add_component X`) components and python support packages for tiles, the name of the entrypoint is not currently configurable.

- **Development Mode Components:** The entrypoint is created dynamically [here](https://github.com/iotile/coretools/blob/master/iotilecore/iotile/core/dev/registry.py#L279). The `name` of the entrypoint is hardcoded to the `basename` of the module that is being loaded. See [here](https://github.com/iotile/coretools/blob/master/iotilecore/iotile/core/dev/registry.py#L704).

This should return the `object` name if there is a `:` in the path indicating that we want to return an object directly instead of a module.

- **Python Support Wheels:** Python support wheels are normal python packages, which means they have a `setup.py` file that defines their entrypoints in the normal way. However this setup.py file is autogenerated based on products in `module_settings.json` and there is no way to configure the `name` associated with the entrypoint. The logic that assigns names is [here](https://github.com/iotile/coretools/blob/master/iotilebuild/iotile/build/config/site_scons/pythondist.py#L101). Similar to the above case, it hardcodes the name to always be the basename of the module even when the entrypoint is specifying an object inside of the module.

This should set the name to `obj_name` when `obj_name` is not None.

So there are two fixes needed to properly name extensions no matter where the extension is loaded from:

- [ ] Update `iotile-core` to use `obj_name` for development mode components when it is not `None`
- [ ] Update `iotile-build` to build support wheels with entrypoint name set to `obj_name` when it is not `None`.

@mattrunchey @timothyfroehlich RE the discussion about naming conventions for `iotile-ship` steps when included in components installed in dev mode or via support wheels.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.