Closed lrq3000 closed 7 years ago
I am a bit puzzled by this issue. Why would you want to have Unidecode installed under a different package name? If you have another project that depends on Unidecode, specify it in requirements.txt
, install_requires
or something similar and it will be installed alongside your project.
As far as I know, it would be very unusual for a Python library to support such use cases. Specifically, PEP 8 recommends using absolute imports when not dealing "with complex package layouts".
Thank you @avian2 for your quick answer.
The problem is not to use this lub under a different package name, but inside another package. Usually, I put libraries in requirements.txt, but for packages that are meant to be only used internally at my company, I prefer to package everything together, so that shipping and reproducibility is easier (particularly when different versions of the lib are available, which happens over time...). In other words, this is a case of allowing complex package layouts, although indeed unidecode itself is not using a complex package layout.
Also but I am not sure, requiring absolute import might make freezing difficult (such as with pyInstaller), but I confess I never tested that.
I think you have a pretty unique use case. I understand that you might have special requirements for shipping software in your company. However, absolute imports are a standard practice in Python and I hesitate to change that in upstream Unidecode without some better reasoning.
Also, I tried adding level=2
to the __import__()
call and this breaks unit tests with ValueError: attempted relative import beyond top-level package
.
I'm now closing this issue, sorry. If you would like to propose another change regarding the imports, please make a pull request.
Unidecode cannot currently be moved/packaged inside another project, as it uses absolute
__import__
in__init__.py
.The easy fix is to set
level=x
where x is the recursion level from the top package of the parent project, in my case it had to belevel=2
.Could you try to make unidecode more "packaging-friendly"?
Thank you for this great library!