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

distutils recognises version as 0.0.0 instead of the correct 1.2.0 #19

Closed
badshah400 opened this issue Aug 5, 2020 · 14 comments
Closed

Comments

@badshah400
Copy link

When building and installing hepunits (I am trying to build packages for openSUSE), setuptools seems to copy the egg-info dir into /usr/lib/python3.8/site-packages/hepunits-0.0.0-py3.8.egg-info instead of the correct /usr/lib/python3.8/site-packages/hepunits-1.2.0-py3.8.egg-info. Probably some issue with distutils reading the pkg version.

Attempts to build packages for openSUSE at https://build.opensuse.org/package/show/home:badshah400:branches:science/python-hepunits, but I also attach the full build log here.
_log.zip

Thanks for your massively useful library, btw.

@henryiii
Copy link
Member

henryiii commented Aug 5, 2020

If you build from source, you need to install setuptools_scm. If you use pip or pep517.build instead of directly running setup.py (which is highly discouraged in modern Python packaging), it does this for you. If you install from the universal wheel instead, you do not need anything extra.

@henryiii
Copy link
Member

henryiii commented Aug 5, 2020

It looks like you can get it for opensuse here:

https://build.opensuse.org/package/view_file/devel:languages:python/python-setuptools_scm/python-setuptools_scm.spec?expand=1

So I think you can just require it? (really only is needed at build time)

@badshah400
Copy link
Author

Thanks for the quick response. I put in a BuildRequires for python-setuptools_scm but that seems to have not done the trick (egg-info still recognises the version as 0.0.0). See the same page for updated build results.

@henryiii
Copy link
Member

henryiii commented Aug 5, 2020

Is this being built with Python3 or Python2? I notice in the setuptools_scm there is some logic for supporting either one (even though it is noarch too), while I don't see similar logic here, and I see a warning about a usage of python2 in the logs.

I think we could improve the situation here by adding a import setuptools_scm line in setup.py, which would make sure you get the correct error, rather than just getting a 0.0.0 version. We could instead put manual version discovery in setup.py, since the version file is present in the source tarball - but that is a bit of a hack, while the correct solution is to properly set up the build environment if using the source file instead of the wheel.

@henryiii
Copy link
Member

henryiii commented Aug 5, 2020

By the way, since you are manually setting the version in the .spec file anyway, you could set SETUPTOOLS_SCM_PRETEND_VERSION=%{version}. Also, should this be:

Source:         https://files.pythonhosted.org/packages/source/h/%{modname}/%{modname}-%{version}.tar.gz

for simpler updating later?

@henryiii
Copy link
Member

henryiii commented Aug 5, 2020

Ahh, found the problem. I thought this:

Suggests:       python-toml

was Requires. It needs this package too to read the pyproject.toml to know where the version is.

@badshah400
Copy link
Author

It's set up to build for both python2 and python3 for openSUSE_Leap_15.x (which still support both versions of python) and only python3 for openSUSE_Tumbleweed (rolling distro that no longer supports python2). The macros help figure this out (so when it reports python2 missing, it only builds for python3 and so on).

Adding BuildRequires: %{python_module toml} did the trick (in addition to python-setuptools_scm). Thank you.

@henryiii
Copy link
Member

henryiii commented Aug 5, 2020

I've merged #20, which would have made this much easier to diagnose, I believe. I think we should likely do a 1.2.1 with this in the near future.

@henryiii henryiii closed this as completed Aug 5, 2020
@henryiii
Copy link
Member

henryiii commented Aug 5, 2020

Oh, one more thing - what version of setuptools are you using? I think 42+ will automatically install the pyproject.toml requirements - this manual addition is only needed for setuptools < 42.

@badshah400
Copy link
Author

Using different setuptools versions:

  • 44.0 for Tumbleweed
  • 40.5 for Leap 15.x.

I hope you don't mind my abusing this bug report with another question I have (I'll open a separate issue if you think it merits one). When building against python2, this error crops up:

[    8s] running egg_info
[    8s] error: 'egg_base' must be a directory name (got `src`)
[    8s] error: Bad exit status from /var/tmp/rpm-tmp.IOIVdc (%build)

Am I missing any python2 specific requirements? Thanks again for all your help.

@henryiii
Copy link
Member

henryiii commented Aug 5, 2020

This is a bug that was fixed in setuptools 40.7.

pypa/setuptools#1136

@henryiii
Copy link
Member

henryiii commented Aug 5, 2020

If you want to move this line from setup.cfg into setup.py, you can keep it from becoming Unicode. I'd probably just patch it.

Updating setuptools to 40.7 would be a better fix, though.

@henryiii
Copy link
Member

henryiii commented Aug 5, 2020

Okay, great, I see you've fixed it. We do require setuptools 42+ generally, so that looks like a reasonable fix due to lockin to an older version.

@badshah400
Copy link
Author

Yeah, I moved the installed egg-info dir around for the older openSUSEs. That should be all right, I think.

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