hippke / tls

Transit Least Squares: An optimized transit-fitting algorithm to search for periodic transits of small planets
MIT License
48 stars 25 forks source link

Dependency on batman / numpy makes it impossible to install TLS #103

Closed dcf21 closed 2 years ago

dcf21 commented 2 years ago

Describe the bug

Has anybody else been finding it totally impossible to install TLS for about the past three months since numpy 1.22 was released?

To Reproduce

On a vanilla Ubuntu 22.04 machine (or 20.04 behaves the same):

dcf21@europa:/tmp/foo$ virtualenv venv dcf21@europa:/tmp/foo$ ./venv/bin/pip install transitleastsquares dcf21@europa:/tmp/foo$ ./venv/bin/python3 Python 3.10.4 (main, Apr 2 2022, 09:04:19) [GCC 11.2.0] on linux Type "help", "copyright", "credits" or "license" for more information.

import transitleastsquares RuntimeError: module compiled against API version 0xf but this version of numpy is 0xe Traceback (most recent call last): File "", line 1, in File "/tmp/foo/venv/lib/python3.10/site-packages/transitleastsquares/init.py", line 13, in from transitleastsquares.main import transitleastsquares File "/tmp/foo/venv/lib/python3.10/site-packages/transitleastsquares/main.py", line 40, in from transitleastsquares.transit import reference_transit, fractional_transit, get_cache File "/tmp/foo/venv/lib/python3.10/site-packages/transitleastsquares/transit.py", line 2, in import batman # https://www.cfa.harvard.edu/~lkreidberg/batman/ File "/tmp/foo/venv/lib/python3.10/site-packages/batman/init.py", line 6, in from .transitmodel import * File "/tmp/foo/venv/lib/python3.10/site-packages/batman/transitmodel.py", line 18, in from . import _nonlinear_ld ImportError: numpy.core.multiarray failed to import

The above example installs TLS using the PyPi repository, but I get exactly the same bahaviour if I download the code from GitHub and install via that route.

Desktop (please complete the following information):

Additional context

It would be really good to get this fixed quite urgently, since I'm trying to evaluate TLS as a possible transit-detection algorithm of choice for the PLATO pipeline, but obviously if it doesn't actually run then that's a bit of a disadvantage... :-)

hippke commented 2 years ago

Yes this is a known problem with batman. There are two work-arounds:

  1. If you can accept an older numpy, then pip install numpy==1.21.1 (may need conda to force this exact version)
  2. Download the batman package from Github, change numpy to oldest-supported-numpy in batman's pyproject.toml file and then doing a pip install .

If this doesn't get resolved soon (@lkreidberg please help, this is such a cool package), I will have to replace the usage of batman in TLS with e.g. PyTransit. Quite unfortunate situation.

dcf21 commented 2 years ago

Thanks so much for the quick reply, @hippke . That's done the trick!

I had already tried doing (1), but I would never have guessed I had to do (2) as well.

I have a lot of sympathy for the unfortunate situation you're in - it seems to me the Python community should be worrying much more about how hard it is to reproduce a known-good Python environment from three months ago!

hippke commented 2 years ago

Fixed by batman 2.4.9. Please try pip install batman-package --upgrade. I will leave this issue open for a few week to check if it solves the problem for everybody. In case any issues remain, I have prepared a TLS version that uses PyTransit instead of batman-package. I could then change it out.