Skip to content

Import __version__ from package metadata to avoid mismatches#53

Open
LourensVeen wants to merge 1 commit into
developfrom
issue_48_broken_package_version
Open

Import __version__ from package metadata to avoid mismatches#53
LourensVeen wants to merge 1 commit into
developfrom
issue_48_broken_package_version

Conversation

@LourensVeen
Copy link
Copy Markdown
Contributor

I tried using setuptools-scm to get the version, but it turns out that that doesn't work with git-flow. Or at least, it'll work for releases, but for e.g. something on develop it will give an odd version because the latest release's tag is not an ancestor.

I think that that could be worked around with a custom setuptools-scm plugin, but that's a bit too complicated for now.

This keeps the version in pyproject.toml and requires manual changes, but at least the ymmsl.__version__ now comes from the metadata and doesn't have to be synchronised by hand.

Addresses #48

@LourensVeen LourensVeen requested a review from maarten-ic June 3, 2026 19:52
@LourensVeen LourensVeen self-assigned this Jun 3, 2026
Copy link
Copy Markdown
Collaborator

@maarten-ic maarten-ic left a comment

Choose a reason for hiding this comment

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

doesn't work with git-flow. Or at least, it'll work for releases, but for e.g. something on develop it will give an odd version because the latest release's tag is not an ancestor.

Ah, right, that's because of the github-specific annoying thing that any merge (even if it could be a fast-forward merge) gets a merge commit.
So merging develop -> master will push a new commit onto master, which gets the tag on release. The master and develop branch are now diverged and the tag is not in the commit history on develop... 🙁

Either way: one comment on the changes, otherwise good to merge!

Comment thread ymmsl/__init__.py
This package contains all the classes needed to represent a yMMSL file,
as well as to read and write yMMSL files.
"""
import importlib
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggested change
import importlib
import importlib.metadata

Perhaps it now works because someone (perhaps third party dependency?) already imported the metadata submodule, but in a fresh python session this gives an error:

>>> import importlib
>>> importlib.metadata
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: module 'importlib' has no attribute 'metadata'

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Ah, thanks, I'll fix that and test it!

@LourensVeen
Copy link
Copy Markdown
Contributor Author

It's a git-flow thing actually, I'm doing it exactly as prescribed. Anyway, this'll work for now, and I'll fix the import, thanks!

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