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

Stop using the deprecated distutils #56

Open
wants to merge 10 commits into
base: master
Choose a base branch
from

Conversation

avalentino
Copy link
Contributor

Use setuptools instead.

@brandon-rhodes
Copy link
Owner

Am I correct that this will break users who attempt to install from .tar.gz but who don't have setuptools installed, but only their system's standard Python?

@avalentino
Copy link
Contributor Author

Am I correct that this will break users who attempt to install from .tar.gz but who don't have setuptools installed, but only their system's standard Python?

Yes, correct.
The mossing part is a pyproject.toml declaring build requirements.
I can provide it.

Actually we could move most of the content of the current setup.py to the pyproject.toml file.
If you agree I can provide a patch also for that.

@miccoli
Copy link

miccoli commented Aug 22, 2023

Am I correct that this will break users who attempt to install from .tar.gz but who don't have setuptools installed, but only their system's standard Python?

Yes, but on the other side, under python 3.12 (to be released 2023-10-02) the build will fail with ModuleNotFoundError: No module named 'distutils'.

@brandon-rhodes
Copy link
Owner

I've been pondering this week whether to add a try...except so that Python 2 installation keeps functioning, or whether to break Python 2 but maybe have a try…except that prints out a message that says to open an issue here on GitHub if you need Python 2 to be supported. If no issue is ever opened, then I could move forward without distutils still being in the code anywhere! If instead someone opened an issue, I could quickly release a new version that restores Python 2 compatibility, and I'd finally have an issue to point at the next time someone said "but no one uses Python 2 any more!" to show them that in the real world of systems and users, it's still in use.

And yet —

If the next install fails for someone, would they really go create a GitHub account and go through the work of figuring out how to create an issue? Or would they just install the previous version of jplephem instead, assuming they could figure out the magic incantation to do that (and assuming they could figure out what the previous version had been)? Or would they give up entirely?

The problem with breaking things for users is that it can be traumatic for the user while never signalling the developer that something is wrong.

I'm likely to take the first option: a try...except that keeps things working for Python 2. Because I myself tend to be almost furious when other developers break things for me gratuitously, and so I don't want to do that for others. But I'll think about it another day or two. Hopefully I'll decide this weekend!

@avalentino
Copy link
Contributor Author

Hi @brandon-rhodes, sorry, I have probably misunderstood your first comment.
By the way I would like to point out that dropping distutils does not mean dropping Python 2 (although I disabled it in CI because GHA no longer supports it).

setuptools v44.x is the latest version compatible with Python 2
I will revert the last commit ("Move project metadata to pyproject.toml") so that the new setup.py will be fully compatible with Python 2 + setuptools v44.x.

Regarding the scenario in which setuptools is not installed, the change should be transparent to users installing the package via pip thanks to the new pyproject.toml file.

The only scenario which is not covered is the one in which the user runs the setup.py script directly:

$ python setup.py install

For this case, using the try...except solution that you suggest is for sure the simpler option.
I will implement it in a new commit.

By the way I would strongly recommend to deprecate the direct invocation of the setup.py script in favour of more modern installation methods. Few lines in the release notes should suffice IMHO.

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

Successfully merging this pull request may close these issues.

3 participants