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

__version__ is broken with 1.7.1 #60

Closed
saimn opened this issue Nov 17, 2020 · 15 comments
Closed

__version__ is broken with 1.7.1 #60

saimn opened this issue Nov 17, 2020 · 15 comments

Comments

@saimn
Copy link
Contributor

saimn commented Nov 17, 2020

I updated to version 1.7.1 and __version__ reports '0.0.0', which then breaks astropy import because the version requirement is not met. cc @mhvk and @astrofrog @embray for the setuptools-scm knowledge.

In [3]: erfa.__version__
Out[3]: '0.0.0'
@saimn
Copy link
Contributor Author

saimn commented Nov 17, 2020

So I have setuptools-scm, and in your version.py code

try:
    try:
        from ._dev.scm_version import get_version as _get_version
        _version = _get_version()
        del _get_version
    except ImportError:
        from ._version import version as _version
except Exception:
    import warnings
    warnings.warn(
        f'could not determine {__name__.split(".")[0]} package version; '
        f'this indicates a broken installation')
    del warnings

    _version = '0.0.0'

_get_version() raises a LookupError: setuptools-scm was unable to detect version for '/home/simon/.pyenv/versions/3.8.1/lib/python3.8/site-packages' which is not catched as ImportError and thus does not fallback to _version.

@pllim
Copy link
Contributor

pllim commented Nov 17, 2020

Is it the leading v in the tags?

@saimn
Copy link
Contributor Author

saimn commented Nov 17, 2020

Not, it's expected that setuptools-scm cannot find the version from an installed package (i.e. not a git repo), it's just that the exception raised is not the one that is expected here. This could be harmless if astropy was not verifying the version. and if the code on both sides was more robust (if ._version exists, it should be used as fallback).

@avalentino
Copy link
Member

avalentino commented Nov 17, 2020

Hi @saimn I'm not able to reproduce the issue in a clean venv environment.

$ python --version
Python 3.8.5

$ python -c "import platform; print(platform.platform())"
Linux-5.4.0-54-generic-x86_64-with-glibc2.29

$ pip list
Package       Version
------------- -------
numpy         1.19.4 
pip           20.0.2 
pkg-resources 0.0.0  
pyerfa        1.7.1  
setuptools    44.0.0 

Can you please provide more details on your setup?

@saimn
Copy link
Contributor Author

saimn commented Nov 17, 2020

You don't have setuptools-scm, so in that case I guess _get_version() raises the ImportError and it works.

@avalentino
Copy link
Member

ah, sorry. Now I can reproduce. Thanks

@saimn
Copy link
Contributor Author

saimn commented Nov 17, 2020

I see now that you version.py is customized compared to astropy, so the good news is that other packages should not be affected by this.

@avalentino
Copy link
Member

OK, the problem is that the erfa/_dev folder for some reason has been included in the distribution.

@avalentino
Copy link
Member

Strange, this problem should be captured by the test suite:

$ python3 -m pytest --pyargs erfa
======================================================= test session starts ========================================================
platform linux -- Python 3.8.5, pytest-6.1.2, py-1.9.0, pluggy-0.13.1
rootdir: /home/antonio
collected 26 items                                                                                                                 

projects/pyerfa/tmp/.venv/lib/python3.8/site-packages/erfa/tests/test_erfa.py ...F....................s.                     [100%]

============================================================= FAILURES =============================================================
__________________________________________ TestVersion.test_version_with_embedded_liberfa __________________________________________

self = <erfa.tests.test_erfa.TestVersion object at 0x7ffa745c20d0>

    @pytest.mark.skipif(not embedded_liberfa(), reason='system liberfa')
    def test_version_with_embedded_liberfa(self):
        version = erfa.__version__
>       assert version.startswith(erfa.version.erfa_version)
E       AssertionError: assert False
E        +  where False = <built-in method startswith of str object at 0x7ffa74bcb530>('1.7.1')
E        +    where <built-in method startswith of str object at 0x7ffa74bcb530> = '0.0.0'.startswith
E        +    and   '1.7.1' = <module 'erfa.version' from '/home/antonio/projects/pyerfa/tmp/.venv/lib/python3.8/site-packages/erfa/version.py'>.erfa_version
E        +      where <module 'erfa.version' from '/home/antonio/projects/pyerfa/tmp/.venv/lib/python3.8/site-packages/erfa/version.py'> = erfa.version

projects/pyerfa/tmp/.venv/lib/python3.8/site-packages/erfa/tests/test_erfa.py:64: AssertionError
========================================================= warnings summary =========================================================
projects/pyerfa/tmp/.venv/lib/python3.8/site-packages/erfa/version.py:15
  /home/antonio/projects/pyerfa/tmp/.venv/lib/python3.8/site-packages/erfa/version.py:15: UserWarning: could not determine erfa package version; this indicates a broken installation
    warnings.warn(

-- Docs: https://docs.pytest.org/en/stable/warnings.html
===================================================== short test summary info ======================================================
FAILED projects/pyerfa/tmp/.venv/lib/python3.8/site-packages/erfa/tests/test_erfa.py::TestVersion::test_version_with_embedded_liberfa
======================================== 1 failed, 24 passed, 1 skipped, 1 warning in 0.80s ========================================

@saimn can you please confirm that the test fails for you as well?

@mhvk mhvk closed this as completed in c10f6d7 Nov 17, 2020
mhvk added a commit that referenced this issue Nov 17, 2020
Fix wrong version number (Closes: gh-60)
@avalentino
Copy link
Member

Should we make a patch release?

@mhvk
Copy link
Contributor

mhvk commented Nov 18, 2020

Yes, I think so!

@saimn
Copy link
Contributor Author

saimn commented Nov 18, 2020

Yes, would be great 👍

@maxnoe
Copy link

maxnoe commented Nov 18, 2020

Yes please, this breaks astropy imports.

@avalentino
Copy link
Member

The new release should be available now.

@yucelkilic
Copy link

I was stuck in the pyerfa version control during the astropy installation. pyerfa's version was '0.0.0'. For this reason, astropy installation failed with pip's dependency control.

I checked the source code and removed the relative path "." from the line below. Then it worked.

from ._dev.scm_version import get_version as _get_version

I changed to:

python from _dev.scm_version import get_version as _get_version

Note: Python 3.10.8 (Mach-O 64-bit executable arm64), macOS Monterey, M2.

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

6 participants