python-sgp4 icon indicating copy to clipboard operation
python-sgp4 copied to clipboard

Deprecation warning about "pyproject.toml" when installing sgp4

Open Bernmeister opened this issue 2 years ago • 3 comments

When installing sgp4 on Debian 12 under a venv I got the following warning:

DEPRECATION: sgp4 is being installed using the legacy 'setup.py install' method,
because it does not have a 'pyproject.toml' and the 'wheel' package is not installed
pip 23.1 will enforce this behaviour change
A possible replacement is to enable the '--use-pep517' option. 
Discussion can be found at https://github.com/pypa/pip/issues/8559

I didn't think much of it until I then ran my script and got the terminal output:

    from sgp4 import alpha5, exporter, omm
ModuleNotFoundError: No module named 'sgp4'

So I then tried:

python3 -m pip install --force-reinstall --use-pep517 sgp4

and my script worked. I then wrote a small test script to reproduce the issue (in a fresh venv):

#!/usr/bin/env python3
# -*- coding: utf-8 -*-

from sgp4.api import accelerated
print( accelerated )

which unexpectedly prints True when executed (I assumed I would get the ModuleNotFoundError). I suspect caching is the culprit, so I uninstalled/reinstalled sgp4 (using the --no-cache-dir option) and I still got a True result.

So...

  1. Apologies as I hoped I could at least provide a test script which reproduced the ModuleNotFoundError. I suspect caching on my system prevents me from consistently reproducing the ModuleNotFoundError.

  2. Although I managed to get around the ModuleNotFoundError by using --use-pep517, I suspect this is a temporary worrkaround (presumably setup.py will need to be switched to pyproject.toml).

  3. A wheel must be being built, as sgp4 is uploaded to PyPI so I am unsure what the original deprecation warning means when stating "the 'wheel' package is not installed".

Bernmeister avatar Dec 14 '23 10:12 Bernmeister

I'm glad that you were able to get it installed! I am kind of dreading the day when I finally have to sit down and try writing TOML, based on what I've seen written about the process:

https://discuss.python.org/t/user-experience-with-porting-off-setup-py/37502/3

https://gregoryszorc.com/blog/2023/10/30/my-user-experience-porting-off-setup.py/

I think the complaint about the wheel package might be because a pip install wheel would give your pip superpowers that would let it build wheels? Or something like that?

Do you know why a wheel wasn't downloaded and installed in the first place? Is your version of Python one that's not provided with a wheel in the sgp4 files on PyPI? If so then maybe we could try fixing that!

https://pypi.org/project/sgp4/#files

brandon-rhodes avatar Dec 16 '23 11:12 brandon-rhodes

I think using the --use-pep517 flag when installing, as mentioned above, is good enough to get over the issue, at least on systems that now strongly encourage (enforce) using a venv such as Debian 12 and I suspect Ubuntu 24.04. My memory is foggy, but when installing on Ubuntu 20.04 / 22.04 there was no warning. In short, perhaps there is no "issue" as such in getting sgp4 installed.

In terms of building the wheel: I didn't. Just installed straight from pip into a fresh venv. The Python I used is whatever comes with Debian 12...I'm not crazy enough to tinker at that level!

To me, the warning is simply stating "use pyproject.toml and drop setup.py", yet I was surprised that I had to use the --use-pep517 flag. I would have thought a warning would be just that, but the package would still be installed. Maybe I'm misreading/misinterpreting the warning.

Regardless, as mentioned already, using --use-pep517 gets sgp4 installed, so happy enough.

As to your looming dread in migrating from setup.py to pyproject.toml: I have recently migrated a whole lot of code/projects (admittedly small) from no setup.py, just raw code (yes shame on me) to pyproject.toml. Was a bit of learning curve, but I think it's not too bad, particularly if you've already got a well-behaved project layout (which you do) and a setup.py that works (ditto).

As for this issue, I'm happy for you to close it...unless you want to use it as a reminder in the far future to migrate to pyproject.toml!

Bernmeister avatar Dec 16 '23 12:12 Bernmeister

Thanks for the additional thoughts and information!

Let's keep the issue open, so that other folks who happen to see the same warning won't have to open new issues each time.

brandon-rhodes avatar Dec 16 '23 14:12 brandon-rhodes