python-babel / babel

The official repository for Babel, the Python Internationalization Library
http://babel.pocoo.org/
BSD 3-Clause "New" or "Revised" License
1.29k stars 432 forks source link

Make setuptools an optional dependency? #1040

Closed akx closed 7 months ago

akx commented 8 months ago

It's a bit rough that this forces setuptools on everyone that has babel in their dependency chain - is there a plan to remove it again eventually? Could this be made an optional feature?

Originally posted by @sigma67 in https://github.com/python-babel/babel/issues/1031#issuecomment-1783024880

oprypin commented 8 months ago

OK so the issue is... the file "babel/messages/frontend.py" implements the setuptools commands integration and the command line interface of pybabel itself, and these two implementations are very tightly connected.

Sure it would be nice to make the setuptools commands integration optional, but:

oprypin commented 8 months ago

One weird approach to solving this would be to make a new package "babel-core" and move everything except "frontend" into that package. Annoying to maintain, though.

sigma67 commented 8 months ago

I think most people get babel through the immensely popular sphinx. Not sure if sphinx relies on setuptools functionality of babel.

I think both ideas you mentioned are viable from a user's perspective, either way it will be a breaking change. But it may be a good chance to rework the frontend?

jpmckinney commented 8 months ago

I use the babel CLI (extract-messages, update-catalog, compile-catalog).

What is the “setuptools commands integration”?

oprypin commented 8 months ago

setup.py can be used as a "command runner" and this integration allows you to add convenience commands that invoke babel in a particular way.

See this commit (from a project that uses babel) that removes this integration because we don't use setup.py anymore. https://github.com/mkdocs/mkdocs/commit/12ee265cc1c117f4816434cea8af1a1874f435ea#diff-2450391302526c6fb43e265d1253d6f5fa62ad38c7c8841090760cf9e6d940b3

Documentation: https://github.com/python-babel/babel/blob/65de3dcf2dc217d6135eff999dc87a3861065e8d/docs/setup.rst

akx commented 8 months ago

TBH, I think we can do with a fairly small translation/emulation layer so our underlying commands are runner-agnostic, and we have a setuptools wrapper for each of them, and a standalone CLI (argparse) wrapper for them. The latter is already done, really, it's just a matter of un-inheriting the current Commands from the setuptools Command base class and writing the wrapper that way...