skyfielders / python-skyfield

Elegant astronomy for Python
MIT License
1.41k stars 211 forks source link

Update developer `requirements.txt` so folks can contribute using more recent Pythons #987

Open pepi-p opened 1 month ago

pepi-p commented 1 month ago

I tried to batch install packages from https://github.com/pepi-p/python-skyfield/blob/master/requirements.txt on windows 11, MINGW64, Python 3.12.2, but It failed. The reason was the imp module on which astropy 3.2.2 depends.

$ pip install -r requirements.txt
Collecting https://github.com/brandon-rhodes/assay/archive/master.zip (from -r requirements.txt (line 14))
  Using cached https://github.com/brandon-rhodes/assay/archive/master.zip
  Preparing metadata (setup.py) ... done
Collecting astropy==3.2.2 (from -r requirements.txt (line 1))
  Using cached astropy-3.2.2.tar.gz (8.0 MB)
  Preparing metadata (setup.py) ... error
  error: subprocess-exited-with-error

  × python setup.py egg_info did not run successfully.
  │ exit code: 1
  ╰─> [92 lines of output]
        error: subprocess-exited-with-error

        python setup.py egg_info did not run successfully.
        exit code: 1

        [15 lines of output]
        C:\Users\pepip\AppData\Local\Temp\pip-wheel-ttkhq3ks\astropy-helpers_a11538e9b1b1457a974ec7b85cb05777\setup.py:13: DeprecationWarning: distutils Version classes are deprecated. Use packaging.version instead.
          if LooseVersion(setuptools.__version__) < '30.3':
        Traceback (most recent call last):
          File "<string>", line 2, in <module>
          File "<pip-setuptools-caller>", line 34, in <module>
          File "C:\Users\pepip\AppData\Local\Temp\pip-wheel-ttkhq3ks\astropy-helpers_a11538e9b1b1457a974ec7b85cb05777\setup.py", line 17, in <module>
            from astropy_helpers.version_helpers import generate_version_py  # noqa
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
          File "C:\Users\pepip\AppData\Local\Temp\pip-wheel-ttkhq3ks\astropy-helpers_a11538e9b1b1457a974ec7b85cb05777\astropy_helpers\version_helpers.py", line 34, in <module>
            from .distutils_helpers import is_distutils_display_option
          File "C:\Users\pepip\AppData\Local\Temp\pip-wheel-ttkhq3ks\astropy-helpers_a11538e9b1b1457a974ec7b85cb05777\astropy_helpers\distutils_helpers.py", line 18, in <module>
            from .utils import silence
          File "C:\Users\pepip\AppData\Local\Temp\pip-wheel-ttkhq3ks\astropy-helpers_a11538e9b1b1457a974ec7b85cb05777\astropy_helpers\utils.py", line 4, in <module>
            import imp
        ModuleNotFoundError: No module named 'imp'
        [end of output]

Since the latest version of astropy is 6.1.2 and the version specified in requirements.txt is 3.2.2, it seems that the problem can be solved by depending on a newer version of astropy.

brandon-rhodes commented 1 month ago

The last time I tried updating requirements.txt, it burned something like an entire day of work, and I still couldn't get a working set of dependencies all working together. Plus it will require rewriting doctests, since some of the libraries have changed things like their repr() behaviors. But I'll keep the idea on my long-term-improvements list; in the meantime, I'm happy at least that Skyfield itself still works on the most recent versions of Python.

I wish the Python community had more respect for other people's time, and would maintain backwards compatibility.

EndlessDex commented 1 month ago

@brandon-rhodes here is a working requirements.txt using all latest packages except for the commented ones.

Passes all tests. No code changes required. But does make min python version 3.10 due to astropy. Dropping astropy from latest (6.1.2) down to (6.0.1) makes min python version 3.9 instead. Both options fix OP's initial issue of imp deprecation. Python 3.8 is EOL at the end of this year so I didn't check for that one.

Only two problem packages:

  1. numpy: As you stated its repr changed from 64.0 to np.float(64.0)
  2. sphinx: Something weird about not finding Time.M.

Locking sphinx to v2.4.5 unfortunately makes it necessary to pin sphinxcontrib-*, alabaster, and jinja2 as well.

# python>=3.10
astropy==6.1.2
beautifulsoup4==4.12.3
html5lib==1.1.0
lxml==5.3.0
mock==5.1.0
numpy==1.26.4 # breaks if upgraded to v2.0.0 due to repr changes
matplotlib==3.9.2
pandas==2.2.2
pyflakes==3.2.0
python-dateutil>=2.5.0
pytz
sphinx==2.4.5 # breaks if upgraded to v3.0.0
jinja2==3.0.3 # breaks if upgraded to v3.1.0 due to deprecated functions
alabaster==0.7.13 # alabaster>=0.7.14 requiers sphinx>=3.4.0
sphinxcontrib-applehelp==1.0.4 # sphinxcontrib-applehelp>=1.0.5 requires sphinx>=5.0.0
sphinxcontrib-devhelp==1.0.2 # sphinxcontrib-devhelp>=1.0.3 requires sphinx>=5.0.0
sphinxcontrib-htmlhelp==2.0.1 # sphinxcontrib-htmlhelp>=2.0.2 requires sphinx>=5.0.0
sphinxcontrib-jsmath==1.0.1
sphinxcontrib-qthelp==1.0.3 # sphinxcontrib-qthelp>=1.0.4 requires sphinx>=5.0.0
sphinxcontrib-serializinghtml==1.1.5 # sphinxcontrib-serializinghtml>=1.1.6 requires sphinx>=5.0.0
spktype21
https://github.com/brandon-rhodes/assay/archive/master.zip
EndlessDex commented 1 month ago

Also, as a side note, there appears to be some sort of race condition in assay regarding the tracking of files. Sometimes it reports an unclosed files warning and other times not. Sometime it also gets RuntimeError: dictionary changed size during iteration but only rarely.

EndlessDex commented 1 month ago

So I went down a rabbit hole of your CI pipeline and whatnot and ended up making a PR for my proposed updates 😅 ...

You can see the action results here: https://github.com/EndlessDex/python-skyfield/actions/runs/10443120176