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

Dynamic metadata: entry-points possible? #296

Open
bilke opened this issue Apr 19, 2023 · 5 comments
Open

Dynamic metadata: entry-points possible? #296

bilke opened this issue Apr 19, 2023 · 5 comments

Comments

@bilke
Copy link

bilke commented Apr 19, 2023

Are other dynamic metadata than version and readme possible with scikit-build-core?

The following did not work for me (no error but also no console entry point generated):

[project]
...
dynamic = ["version", "entry-points"]

[tool.setuptools.dynamic]
entry-points = { file = "entry_points.txt" }
[console_scripts]
mycmd = mycmd:main

Or do we need to implement this as a plugin similar to version and readme?

Thanks!

@henryiii
Copy link
Collaborator

We don't read tool.setuptools, we are tool.scikit-build. :) It needs to be a plugin, similar to the existing two, yes. It should be very easy to do, even as a local plugin; I'd recommend adding it to scikit-build-core's plugins, though, since the API is still in flux; I will update the integrated plugins as the API changes. If it's local or external, you'll need to require >=0.3,<0.4 (and set tool.scikit-build.experimental=true). More examples are good, though, since I'll be working on a PEP(s) for it soon, and the more use cases we have the better.

@henryiii
Copy link
Collaborator

henryiii commented Apr 19, 2023

(Unless you are using the experimental setuptools backend, in which case the above should work, we don't touch entry points if setuptools is handling it)

@bilke
Copy link
Author

bilke commented Apr 20, 2023

Thanks for the plugin pointers!

Indeed, a local plugin is easy to implement, e.g. for scripts:

from __future__ import annotations

__all__ = ["dynamic_metadata"]


def __dir__() -> list[str]:
    return __all__


def dynamic_metadata(
    fields: frozenset[str],
    settings: dict[str, object] | None = None,
) -> dict[str, str | dict[str, str | None]]:
    if fields != {"scripts"}:
        msg = "Only the 'scripts' field is supported"
        raise ValueError(msg)

    if settings:
        msg = "No inline configuration is supported"
        raise ValueError(msg)

    scripts = {"mycmd": "mycmd:main"}

    return {"scripts": scripts}

I will develop this further for our specific use case and will provide a generalized plugin soon...

@njzjz
Copy link
Contributor

njzjz commented May 28, 2024

Just curious if there is a timeline to make the API stable, or have a temporary API but keep compatibility with it. It's not good to always use the experimental API.

@henryiii
Copy link
Collaborator

scikit-build/dynamic-metadata#21 is the next step.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants