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

generated _version.py breaks on python <3.8 #905

Closed
marcelm opened this issue Sep 20, 2023 · 9 comments · Fixed by #907
Closed

generated _version.py breaks on python <3.8 #905

marcelm opened this issue Sep 20, 2023 · 9 comments · Fixed by #907

Comments

@marcelm
Copy link

marcelm commented Sep 20, 2023

I have this in my pyproject.toml:

[tool.setuptools_scm]
write_to = "src/toolname/_version.py"

setuptools_scm 8.0.0 seems to incorrectly generate the _version.py file (it contains syntax errors):

# file generated by setuptools_scm
# don't change, don't track in version control
from __future__ import annotations
__version__ : str = version : str = '4.5.dev38+g44c9a18'
__version_tuple__ : 'tuple[int | str, ...]' = \
  version_tuple : 'tuple[int | str, ...]' = (4, 5, 'dev38', 'g44c9a18')

Logs for a failed GitHub Actions run.

@RonnyPfannschmidt
Copy link
Contributor

this is a unfortunate oversight, with the drop of python3.7 in the support matrix

as your build env uses a higher python version that new setuptools_scm version is pulled in
i'll release a bugfix that allows the old syntax to keep that working

@RonnyPfannschmidt RonnyPfannschmidt changed the title Syntax error in generated _version.py generated _version.py breaks on python <3.8 Sep 20, 2023
@marcelm
Copy link
Author

marcelm commented Sep 20, 2023

Thanks! I’m not sure I understand. I get the SyntaxError even on Python 3.10:

$ python3
Python 3.10.12 (main, Jun 11 2023, 05:26:28) [GCC 11.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from __future__ import annotations
>>> a : str = b : str = "hello"
  File "<stdin>", line 1
    a : str = b : str = "hello"
                ^
SyntaxError: invalid syntax

(Thanks BTW, due to your comment, I noticed that apparently my build matrix is configured incorrectly and uses Python 3.10 for all builds, independent of the specified version number.)

@RonnyPfannschmidt
Copy link
Contributor

i have a local bugfix + a regression test that switches to type comments, release incoming in a few

@marcelm
Copy link
Author

marcelm commented Sep 20, 2023

Thanks for this quick fix! With that, I can drop my _version.pyi file that I kept for this purpose.

I wanted to clarify my comment from above. The Python version is not the problem as Python 3.7 understands this style of annotation:

a : str = "hello"

The problem is attempting to use two annotations in a row like this:

a : str = b : str = "hello"

That is a SyntaxError up until at least Python 3.11.

@ssbarnea
Copy link

This affects lots of project and breaks also with newer versions of python, I would recommend yanking 8.0 release until we have a fix to limit the ecosystem impact.

@leouieda
Copy link

Just wanted to say a big thank you for finding and fixing this so quickly! I love this package and use in every single project I develop. Much love from the community ❤️

@abhinavsingh
Copy link

This affects lots of project and breaks also with newer versions of python, I would recommend yanking 8.0 release until we have a fix to limit the ecosystem impact.

Totally, v8 must be yanked imho, so that we can remove the pin.
See #908

@RonnyPfannschmidt
Copy link
Contributor

@abhinavsingh just yanked it

@RonnyPfannschmidt
Copy link
Contributor

bug-fix release triggered

felipesanches added a commit to felipesanches/fontbakery that referenced this issue Sep 20, 2023
felipesanches added a commit to fonttools/fontbakery that referenced this issue Sep 20, 2023
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 a pull request may close this issue.

5 participants