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

Allow Custom Version Scheme Outside setup.py (resolves #781) #803

Conversation

schang412
Copy link
Contributor

Currently, there is no way to specify a custom version_scheme if you are not using setup.py. When provided a string that does not match the name of a valid entrypoint, the main version is assigned None and fails the assert.

This patch provides a method to specify a qualified name for a function using the same syntax as an console script entrypoint:

[tool.setuptools_scm]
version_scheme = "my_module.my_file:my_custom_version_scheme_func"
local_scheme = "my_module.my_file:my_custom_local_scheme_func"

In order to accomplish this, when going through the available version schemes, if no version scheme is found, it treats the string as a qualified function name, and tries to load it using importlib.metadata.EntryPoint. If this does not lead to a valid function, it will maintain current behavior.

@RonnyPfannschmidt
Copy link
Contributor

Thanks for having a look at this

I'll have to investigate how that would integrate with the delayed simplify_types branch

@schang412
Copy link
Contributor Author

Looking at the branch in your fork, it seems like the changes just need to be moved to a different file. If you'd like, after merging simplify_types, I can update my PR to reflect the changes necessary.

@RonnyPfannschmidt
Copy link
Contributor

I'll enable that

I intend to completely change how version schemes work, so people can pick and choose them with extra configuration instead of dropping into functions most of the time

@RonnyPfannschmidt
Copy link
Contributor

its merged, please have a look

@schang412
Copy link
Contributor Author

Hi, I updated my branch. Please let me know if there’s any issues or anything I should change.

Copy link
Contributor

@RonnyPfannschmidt RonnyPfannschmidt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One item that's missing is a unit or acceptance test for the behaviour

@schang412
Copy link
Contributor Author

Sure, I can make one. Is testing/test_config.py the most appropriate place?

@RonnyPfannschmidt
Copy link
Contributor

Most likely for now

format_version(
version,
local_scheme="no-local-version",
version_scheme="setuptools_scm.version:guess_next_dev_version",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should pick a non-default version scheme and check that it is actually used

@schang412
Copy link
Contributor Author

Hi, I updated it to use a non-default version scheme, and merged the latest main branch in but some tests are failing for windows now. I'm not sure why. Curiously, one of the Windows tests passed.

Copy link
Contributor

@RonnyPfannschmidt RonnyPfannschmidt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks

@RonnyPfannschmidt RonnyPfannschmidt merged commit 72e25f7 into pypa:main Mar 9, 2023
@schang412 schang412 deleted the feature/custom_version_scheme_outside_setuppy branch March 9, 2023 20:32
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

Successfully merging this pull request may close these issues.

2 participants