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

setuptools-gettext is not run by python -m build #94

Open
rrthomas opened this issue Dec 14, 2024 · 8 comments
Open

setuptools-gettext is not run by python -m build #94

rrthomas opened this issue Dec 14, 2024 · 8 comments

Comments

@rrthomas
Copy link

This package looks like exactly what I need, but I can't work out how to use it!

I read the issue about support, or lack of it, for pybuild, i.e. python -m build, but I couldn't work out what I was supposed to do to work around it.

I have checked out the repo, and looked at the example project.

When I run python setup.py, the build_mo stage is run; great!

When I run python -m build, the build_mo stage is not run.

So so far, my understanding is that I'll need to run python setup.py rather than python -m build, (which is a shame as the former tells me it's deprecated when I run it).

The next thing I can't work out is how the .mo files are added to a dist package. I tried running python setup.py followed by python -m build in the hope that, having built the files, they would now get packaged, but no luck!

I appreciate your effort in trying to improve the state of affairs for packaging with gettext, and I also appreciate that Python packaging is not in a great state for stuff that is standard for GNU-style packages but not for Python—I've had similar frustration with packaging manpages, where despite strenuous efforts by the author, I cannot persuade argparse-manpage to work without a setup.py either.

So in sum, what I'm after is a recipe that will let me use setuptools-gettext with pybuild, or if that's not possible, a summary of what the options are.

@rrthomas
Copy link
Author

The best I've managed to come up with so far that seems to work is to do the following:

  • Use the minimal setup.py that the example project has, renamed to setup-gettext.py and run python setup-gettext.py build before running python -m build.
  • Add the generated .mo files to tools.setuptools.package-data in pyproject.yaml

The first step causes the .mo files to be built and the second causes them to be packaged.

The reason I rename setup.py is that I don't want pip to try to use it. This means of course that my .mo files will not be installed in a system locale directory, but this is what I want in my case, as the package in question is an application which I build into a single binary, so I need the .mo files to be in an application-specific location anyway.

I guess that if I did want the .mo files to be installed I could simply not rename setup.py, but I haven't tested that.

This still seems a bit hacky, though!

@jelmer
Copy link
Member

jelmer commented Dec 20, 2024 via email

@rrthomas rrthomas changed the title Please document the build process a bit more extensively setuptools-gettext is not run by python -m build Dec 20, 2024
@rrthomas
Copy link
Author

Thanks @jelmer, I have retitled the issue.

@jelmer
Copy link
Member

jelmer commented Dec 21, 2024

I'm a bit puzzled how this is meant to work though - we register hooks with setuptools so this should work for all ways in which setuptools gets invoked.

There are other setuptools extensions that do work so I'll have a look at those and see if they do anything special. For example, setuptools_rust.

@rrthomas
Copy link
Author

@jelmer, good point! I also use argparse-manpage, and it seems to work there.

@jelmer
Copy link
Member

jelmer commented Dec 21, 2024

So it looks like argparse-manpage actually modifies the standard build_py command, which is a bit ugly. setuptools-rust seems to be doing something different.

@nijel
Copy link
Contributor

nijel commented Jan 20, 2025

This seems lacking interface in setuptools, see pypa/build#729 (it also links one approach to address this).

PS: See also pypa/setuptools#2591.

@jelmer
Copy link
Member

jelmer commented Jan 20, 2025

Ah, thanks for the links.

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

No branches or pull requests

3 participants