Ouranosinc / xscen

A climate change scenario-building analysis framework.
https://xscen.readthedocs.io/
Apache License 2.0
15 stars 2 forks source link

Can't compile translation catalog when installing from source #342

Closed aulemahal closed 1 month ago

aulemahal commented 7 months ago

Setup Information

Description

The setuptools hack we added in setup.py only works for pip install . or pip install xscen, but no when the argument is a git url or if the -e option is specified. This is gossing.

Steps To Reproduce

pip install git+https://github.com/ouranosinc/xscen.git
python -c "import xscen"

Additional context

Opinion : I though gettext and babel would help the work of translating xscen. I do not have that feeling anymore. For some reason, babel only canonically works with setuptools.

There would alternatives : we might be able to hack something by using a build backend that allows running custom commands during the build process (poetry seems to allow that).

OR : we go back to the simple method that xclim uses : put all the strings in a text file (yaml would be better than json). In the end, gettext only... gets texts. We could reimplement the core of what we use from it in only 5-6 lines. And remove the need for "compilation" completely.

Contribution

RondeauG commented 7 months ago

I don't have any strong reason to keep gettext if it complicates things needlessly. For now, we indeed only translate a very limited number of lines.

juliettelavoie commented 7 months ago

with "-e", can you do "make translate" by hand ?

For translation tools,I don't have a strong opinion.

RondeauG commented 7 months ago

My understanding is that this is essentially an issue when trying to install xscen without going through PyPI/conda. In other words, it's mostly an hassle for developers, which is why I don't have a strong opinion on keeping or removing it.

However for our current needs, it might be overcomplicated.

Edit: make translate doesn't work on Windows, but python setup.py compile_catalog does. At minimum, we should have that info somewhere.

Zeitsperre commented 7 months ago

Edit: make translate doesn't work on Windows, but python setup.py compile_catalog does. At minimum, we should have that info somewhere.

If we want, we can change the way that a Makefile command is called depending on the platform it's running on. This is a very standard practice. If a user is using make commands, they should work for all platforms.

we might be able to hack something by using a build backend that allows running custom commands during the build process (poetry seems to allow that).

Good idea. I was thinking this might happen, so perhaps you could explore this option (https://github.com/taskipy/taskipy). I've contributed it to conda-forge as well.

We could reimplement the core of what we use from [xclim] in only 5-6 lines. And remove the need for "compilation" completely.

Would it make sense to expose this functionality in xclim? I know that other downstream projects (hydro) are also reliant on translation.

aulemahal commented 7 months ago

The make issue could easily be "fixed" by simply documenting the process. Our makefile really is just a map of aliases.

Would it make sense to expose this functionality in xclim?

Yes, but the idea is still fuzzy in my head:

I'll suggest something soon.