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

Get version from an entrypoint #109

Open
nedbat opened this issue Oct 8, 2023 · 6 comments
Open

Get version from an entrypoint #109

nedbat opened this issue Oct 8, 2023 · 6 comments

Comments

@nedbat
Copy link
Owner

nedbat commented Oct 8, 2023

From a discussion in Discord with @RonnyPfannschmidt:

RonnyPfannschmidt: @nedbat does scriv have any way to get the next version from something like setuptools_scm ?

nedbat: Nothing built-in, and I don't know anything about setuptools_scm, but maybe we can figure something out.
nedbat: scriv collect --version=$(setuptools_scm something?)

RonnyPfannschmidt: that works out - also wondering if perhaps a cli command could be used as default version source like (python -m setuptools_scm --strip-dev)

nedbat: you mean, we could add a setting to scriv that is the command to run to get the version?  That could work.
nedbat: I like the nature of that: nothing hard-coded, but easy to configure the connections you want. The docs could include example commands for other tools.

RonnyPfannschmidt: or a entrypoint to call

nedbat: yes
nedbat: We already have a setting: version = literal: pyproject.toml: project.version  It could be extended:
    version = command: setuptools_scm something
    or
    version = call: setuptools_scm.main(strip_dev=True)

nedbat: (maybe full python there is weird)

RonnyPfannschmidt: lets not go there, - if its a command, its a string and fair game, if its a "entrypint" it should be pre-configred for scriv

nedbat: what's an example of an entrypoint? A named entrypoint, or module.callable ?

RonnyPfannschmidt: aka there should be a entrypoint like "scriv.get_version" and importlib metadata should be used to fetch a name of that group, no parameters should be passed
RonnyPfannschmidt: lets not go down the path of random pythonpath modification and module lookup, its a can of killer worms

nedbat: I'm assuming you want to use a setuptools_scm entrypoint?  What from here would be useful? https://github.com/pypa/setuptools_scm/blob/main/pyproject.toml#L69-L101

RonnyPfannschmidt: @nedbat i think you misunderstood me - i would add a scriv.get_version entrypoint to setuptools_scm like setuptools_scm = setuptools_scm._integration.scriv:return_version_for_scriv - and then people could configure that in their scriv config

nedbat: ok, so it would be an entrypoint from setuptools_scm, that's fine if it doesn't exist yet.
nedbat: i think setuptools_scm is well ahead of the curve in terms of exporting many entrypoints, so I'm not sure I would limit the callability to only entrypoints.

RonnyPfannschmidt: @nedbat i an understand the sentiment, unfortunately that opens up the failure vector of having to manage pythonpath ^^ based on year of suffering its not something a tool wants tobe in charge of

nedbat: I will keep an eye out for that.
@nedbat
Copy link
Owner Author

nedbat commented Oct 9, 2023

I understand it now better than I did in Discord! :)

A scriv-specific entrypoint seems esoteric to me, I'm not sure many tools would implement one. Running a command would let individual adopters plug tools together without the other tool needing to provide a scriv endpoint. But is it safe to have a config file in your repo with command: run_untrusted_code blah blah as a setting?

@RonnyPfannschmidt
Copy link
Contributor

the ux would be better than having a RELEASING.md that tell people to copy&paste sciv ... --version $(...) or a extra integration script

personally i'd prefer a entrypoint or actually using build

i recently learned that build has a entrypoint to get the project metadata, so perhaps it wouldbe a acceptable comprmise to ask build as opposed to all/random tools

@nedbat
Copy link
Owner Author

nedbat commented Oct 9, 2023

I realized that a shell command in a scriv setting is no worse than a Makefile or tox.ini full of shell commands, or any other way we have to automate local execution.

But tell me more about using build. What's the invocation, and what would that look like?

@RonnyPfannschmidt
Copy link
Contributor

https://pypa-build.readthedocs.io/en/latest/api.html#build.util.project_wheel_metadata is the api I believe ought to be used

Once I'm back to the computer I can do a example call

@nedbat
Copy link
Owner Author

nedbat commented Oct 9, 2023

I added command: syntax in commit 951c0f8.

@nedbat
Copy link
Owner Author

nedbat commented Oct 12, 2023

command: is now released as part of scriv 1.4.0.

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

2 participants