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

Missing version file #606

Closed
henryiii opened this issue Aug 26, 2021 · 9 comments · Fixed by #607
Closed

Missing version file #606

henryiii opened this issue Aug 26, 2021 · 9 comments · Fixed by #607

Comments

@henryiii
Copy link
Contributor

henryiii commented Aug 26, 2021

As of about an hour ago, projects are failing to write out a write_to version file. It's also not picking up the version properly, not sure why, I"m getting 0.0.0. No warning that I see in verbose mode.

I'm using (as always):

[build-system]
requires = ["wheel", "setuptools>=42", "setuptools_scm[toml]>=3.4"]
build-backend = "setuptools.build_meta"

[tool.setuptools_scm]
write_to = "src/hist/version.py"

(Technically, ==6.1 to force the issue, locally it might pick up an older cached version)

Pretty much any install command seems to trigger it, pip install -e . does, but pip install . seems to too. It makes 0.0.0 and then my tests crash because src/hist/version.py wasn't produced.

Pinning <6.1 fixes the issue, though I'm not looking forward to going through a dozen or more projects and adding the pin... edit: yanked, thanks!

@henryiii
Copy link
Contributor Author

Pretty sure this is not related to #605, as using the latest setuptools doesn't fix it, and I'm not seeing an error, it's just not writing the file or getting the version (in CI or locally).

@henryiii
Copy link
Contributor Author

Maybe you could yank the release until this and #605 are resolved?

@RonnyPfannschmidt
Copy link
Contributor

@henryiii does the issue happen if setuptools >=45 is enforced there?

@ntextreme3
Copy link

@RonnyPfannschmidt I'm using setuptools-57.4.0 and see the same issue.

@RonnyPfannschmidt
Copy link
Contributor

@ntextreme3 can you provide a output with SETUPTOOLS_SCM_DEBUG=1

@henryiii
Copy link
Contributor Author

henryiii commented Aug 26, 2021

Looks like

defn = __import__("toml").load(strm)
should be tomli. Shouldn't this be tested (pyproject.toml test)?

@henryiii
Copy link
Contributor Author

henryiii commented Aug 26, 2021

I think this is the relevant part of the output from SETUPTOOLS_SCM_DEBUG:

  Running command /Users/henryschreiner/git/scikit-hep/particle/.nox/tests/bin/python /Users/henryschreiner/git/scikit-hep/particle/.nox/tests/lib/python3.9/site-packages/pip/_vendor/pep517/in_process/_in_process.py build_wheel /var/folders/_8/xtbws09n017fbzdx9dmgnyyr0000gn/T/tmptlikjqkw
  finalize hook {'name': None, 'version': None, 'author': None, 'author_email': None, 'maintainer': None, 'maintainer_email': None, 'url': None, 'license': None, 'description': None, 'long_description': None, 'keywords': None, 'platforms': None, 'classifiers': None, 'download_url': None, 'provides': None, 'requires': None, 'obsoletes': None}
  Traceback (most recent call last):
    File "/private/var/folders/_8/xtbws09n017fbzdx9dmgnyyr0000gn/T/pip-build-env-36nyqvbj/overlay/lib/python3.9/site-packages/setuptools_scm/integration.py", line 59, in infer_version
      config = Configuration.from_file(dist_name=dist_name)
    File "/private/var/folders/_8/xtbws09n017fbzdx9dmgnyyr0000gn/T/pip-build-env-36nyqvbj/overlay/lib/python3.9/site-packages/setuptools_scm/config.py", line 174, in from_file
      defn = __import__("toml").load(strm)
  ModuleNotFoundError: No module named 'toml'

(Using a different package and pinning 6.1.0)

@ntextreme3
Copy link

@ntextreme3 can you provide a output with SETUPTOOLS_SCM_DEBUG=1

Not sure what I should run that with, but if it helps:

from:
SETUPTOOLS_SCM_DEBUG=1 python3.9 setup.py --version
finalize hook {'name': None, 'version': None, 'author': None, 'author_email': None, 'maintainer': None, 'maintainer_email': None, 'url': None, 'license': None, 'description': None, 'long_description': None, 'keywords': None, 'platforms': None, 'classifiers': None, 'download_url': None, 'provides': None, 'requires': None, 'obsoletes': None}
l {'root': '.', 'relative_to': None}
root '/w/s'
relative_to None
dist name: None
looking for ep setuptools_scm.parse_scm /w/s
found ep EntryPoint(name='.git', value='setuptools_scm.git:parse', group='setuptools_scm.parse_scm') in /w/s
cmd 'git rev-parse --show-prefix'
 in /w/s
out b'\n'
real root /w/s
cmd 'git describe --dirty --tags --long --match *[0-9]*'
 in /w/s
out b'3.23.1-6-ga4c3d4ef-dirty\n'
cmd 'git rev-parse --abbrev-ref HEAD'
 in /w/s
out b'HEAD\n'
cmd 'git log -n 1 HEAD --format=%cI'
 in /w/s
out b'2021-08-26T17:55:59-04:00\n'
tag 3.23.1
tag '3.23.1' parsed to {'version': '3.23.1', 'prefix': '', 'suffix': ''}
version pre parse 3.23.1
version <Version('3.23.1')>
version 3.23.1 -> 3.23.1
scm version <ScmVersion 3.23.1 d=6 n=ga4c3d4ef d=True b=HEAD>
config {'version_scheme': 'guess-next-dev', 'local_scheme': 'node-and-date'}
ep found: guess-next-dev
version 3.23.2.dev6
ep found: node-and-date
local_version +ga4c3d4ef.d20210826
3.23.2.dev6+ga4c3d4ef.d20210826

Which shows the right version there. But then using write_to from pyproject.toml like OP also seeing the 0.0.0

@henryiii
Copy link
Contributor Author

henryiii commented Aug 27, 2021

If you add "toml" (the package, not the extra name) to the pyproject.toml, it works with 6.1.0, so I'm quite sure the bug is that it still tries to read this with toml, not tomli.

To fix this, should it just be a hard switch to tomli here, or should it try both? If someone manually added toml instead of using the extra, then a hard switch could cause it to stop working here. Also, it would be nice if this errored out (say if there was no other config and toml/tomli was not available) instead of just assigning 0.0.0 and ignoring the options., but that could be for later if you wanted to do it. And this really should be tested - a simple example following the readme of a pyproject.toml project should be run in the tests. There does not seem to be a single mention of "requires" in the tests. Happy to help if needed.

RonnyPfannschmidt added a commit to RonnyPfannschmidt/setuptools_scm that referenced this issue Aug 27, 2021
when switching to tomli i missed a part and the test env containing the toml lib did hide the issue
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.

3 participants