How to discourage directly calling

This is kind of a followon to the “Best practice…” topic, from an application viewpoint.

We’ve actually had users find old documentation and try to “python install” and it fails for them, so we’re motivated to pretty actively discourage it, but hopefully without immediately breaking people for whom it still works. I know one approach is to just get rid of it, but as we’ve seen elsewhere, that’s likely to break Linux distro packagers and others whose stanzas still look like (taken from the current Fedora specfile for us):

%{_bindir}/python3.8 install -O1 --skip-build --root %{buildroot} \
 --install-scripts=%{_bindir} \

We’re pretty far down the food chain as far as popularity so don’t want to rock the boat on that front.

I can’t see how to tell the difference between a user running from their shell and a tool calling Any thoughts?

/me wearing my Fedora packager hat:

That quote is from an outdated or unmaintained spec file. It does not follow recent Fedora Python packaging guidelines. A modern spec files should use the pyproject RPM macros such as %pyproject_wheel + %pyproject_install. Projects that don’t support wheel building may still use the old style %py3_build / %py3_install macros. Here is how the spec file for black looks like.

1 Like

How recent are those macros? Do they exist in EL7?

No. RHEL7 predates PEP 516 & PEP 517, and RHEL8 predates the deprecation of calling directly (and the tooling improvements that made the alternative usable). For those systems, stick with yesteryear’s best practice.

Packagers can provide different instructions for different systems in a separate Git branches, or with %if/%else in the spec file.
Note that the snippet from the original post is from such an %else block, so it isn’t actually for Fedora (where hardcoding Python 3.8 wouldn’t really work). The Fedora part can be updated.

Yes, you’re right, I completely missed it being conditional, and in fact the main part looks like:

%if 0%{?el7} || 0%{?fedora} || 0%{?eln}
%py3_install -- --install-scripts=%{_bindir} --install-data=%{_datadir}

… plus some additional fiddling that isn’t material here.

with my original snip in the else past.

However, the intent of my question wasn’t to poke at Fedora, but to ask in general, I don’t think everybody has done this kind of work yet. Can I safely put something in itself that gives information to someone manually running the without breaking a distro package which maybe also calls, or tools like build, which end up invoking as a command?

If the warning is just a message to stderr, it shouldn’t break anything.

A warning that’s hidden for users of the new API sounds like a feature request for setuptools & pip.