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

With MacOS and PyPy installation fails: AttributeError: 'LooseVersion' object has no attribute 'version' #26536

Closed
bhy opened this issue May 27, 2019 · 8 comments

Comments

@bhy
Copy link

commented May 27, 2019

On MacOS 10.14, PyPy3.6-7.1.1 installation fails:

$ pip3 install pandas
Collecting pandas
  Using cached https://files.pythonhosted.org/packages/b2/4c/b6f966ac91c5670ba4ef0b0b5613b5379e3c7abdfad4e7b89a87d73bae13/pandas-0.24.2.tar.gz
    ERROR: Complete output from command python setup.py egg_info:
    ERROR: Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/private/var/folders/50/8j9r2pm93n15lw18936l7zkc0000gn/T/pip-install-96rmqzke/pandas/setup.py", line 438, in <module>
        if python_target < '10.9' and current_system >= '10.9':
      File "/Users/haoyu/.pyenv/versions/pypy3.6-7.1.1/lib-python/3/distutils/version.py", line 52, in __lt__
        c = self._cmp(other)
      File "/Users/haoyu/.pyenv/versions/pypy3.6-7.1.1/lib-python/3/distutils/version.py", line 335, in _cmp
        if self.version == other.version:
    AttributeError: 'LooseVersion' object has no attribute 'version'

A workaround is to install with:
MACOSX_DEPLOYMENT_TARGET=10.14.4 pip3 install pandas

The cause for this is that in pandas setup.py, get_config_var('MACOSX_DEPLOYMENT_TARGET') will return None on PyPy, while a version number like 10.9 is expected. (See https://github.com/pandas-dev/pandas/blob/master/setup.py#L453).

@simonjayhawkins

This comment has been minimized.

Copy link
Member

commented May 27, 2019

@bhy Thanks for the report.

PyPy is not included in our CI or distributed binaries for PyPy. (not tested / officially supported).

May be worth raising this on the PyPy issue tracker. Closing this as we don't make any guarantees about PyPy.

@TomAugspurger

This comment has been minimized.

Copy link
Contributor

commented May 28, 2019

@simonjayhawkins we still accept patches for PyPy compatibility. This may be on us, but that's not clear yet.

@bhy is that never defined for pypy? If so, do you know why?

cc @robbuckley just as an FYI.

@simonjayhawkins

This comment has been minimized.

Copy link
Member

commented May 28, 2019

This may be on us, but that's not clear yet.

@TomAugspurger : ok. i'll reopen for now.

@robbuckley

This comment has been minimized.

Copy link
Contributor

commented May 29, 2019

a quick fix could be to change the indicated line from

if is_platform_mac():
    if 'MACOSX_DEPLOYMENT_TARGET' not in os.environ:
        current_system = LooseVersion(platform.mac_ver()[0])
        python_target = LooseVersion(
            get_config_var('MACOSX_DEPLOYMENT_TARGET'))
        if python_target < '10.9' and current_system >= '10.9':
            os.environ['MACOSX_DEPLOYMENT_TARGET'] = '10.9'

to

if is_platform_mac():
    if 'MACOSX_DEPLOYMENT_TARGET' not in os.environ:
        current_system = LooseVersion(platform.mac_ver()[0])
        python_target = LooseVersion(
            get_config_vars().get('MACOSX_DEPLOYMENT_TARGET', current_system))
        if python_target < '10.9' and current_system >= '10.9':
            os.environ['MACOSX_DEPLOYMENT_TARGET'] = '10.9'

Also changing this line:

from distutils.sysconfig import get_config_var

to:

from distutils.sysconfig import get_config_vars

Note the additonal 's'. This shouldnt break CPython (caveat: no tests done yet!). I have no easy way to test this on PyPy, but Im happy to submit a patch and test on CPython if that helps.

@TomAugspurger

This comment has been minimized.

Copy link
Contributor

commented May 29, 2019

yeah, that seems like an option @robbuckley. But let's wait to hear more from @bhy to better understand what's going wrong with PyPy here before we change anything.

@bhy

This comment has been minimized.

Copy link
Author

commented May 29, 2019

@TomAugspurger I never saw it defined across the versions of PyPy I tried with (6.0 and 7.1). I'm not familiar with PyPy development, but their document mentions (http://doc.pypy.org/en/latest/cpython_differences.html):

The get_config_vars method of sysconfig and distutils.sysconfig are not complete. On POSIX platforms, CPython fishes configuration variables from the Makefile used to build the interpreter. PyPy should bake the values in during compilation, but does not do that yet.

@TomAugspurger

This comment has been minimized.

Copy link
Contributor

commented May 31, 2019

Thanks. Given that I think that @robbuckley's proposal is reasonable. @bhy can you test it out locally, and perhaps submit a PR?

robbuckley added a commit to robbuckley/pandas that referenced this issue Jun 14, 2019

robbuckley added a commit to robbuckley/pandas that referenced this issue Jun 14, 2019

robbuckley added a commit to robbuckley/pandas that referenced this issue Jun 14, 2019

robbuckley added a commit to robbuckley/pandas that referenced this issue Jun 14, 2019

@robbuckley

This comment has been minimized.

Copy link
Contributor

commented Jun 14, 2019

I've made a PR, but I cant easily test it on PyPy - @bhy can you do that please?

robbuckley added a commit to robbuckley/pandas that referenced this issue Jun 15, 2019

@jreback jreback added this to the 0.25.0 milestone Jun 16, 2019

jreback added a commit that referenced this issue Jun 21, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants
You can’t perform that action at this time.