<div dir="ltr"><br><br><div class="gmail_quote"><div dir="ltr">On Wed, 11 Apr 2018 at 10:36 John Thorvald Wodder II <<a href="mailto:jwodder@gmail.com">jwodder@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">> On 2018 Apr 11, at 06:55, Jorge Maldonado Ventura <<a href="mailto:jorgesumle@freakspot.net" target="_blank">jorgesumle@freakspot.net</a>> wrote:<br>
> <br>
> I need to execute a command automatically when running `pip install` to solve <a href="https://notabug.org/jorgesumle/boot-em-all/issues/1" rel="noreferrer" target="_blank">https://notabug.org/jorgesumle/boot-em-all/issues/1</a><br>
> <br>
> I need to do that to compile the translation files. I found that overriding the `setuptools.command.install` makes it work with `python3 setup.py install`, but I want it to work with pip as well. Any advice or think I overlooked? Is there a clean or recommended way to do this?<br>
> <br>
> The whole code is free software, so you can check my `setup.py` file. The repository can be cloned executing `git clone <a href="https://notabug.org/jorgesumle/boot-em-all" rel="noreferrer" target="_blank">https://notabug.org/jorgesumle/boot-em-all`</a>.<br>
<br>
This can't be done. `pip install` installs from wheel (.whl) files, and that installation process currently (and, I believe, by design) has no provision for running arbitrary code. You have two options:<br></blockquote><div><br></div><div>Yep, it's by design to make installation as fast as copying some files from a zip file.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
1. Extend the `setup.py bdist_wheel` command to compile & bundle the translation files as part of building the wheel. I personally don't know how to do this, but I believe the process is somewhat similar to extending the `setup.py install` command. Note that if the compiled translation files are architecture-dependent, you'll also need to add the appropriate tags to the wheel.<br>
<br>
2. Give your library a `boot_em_all_compile_translations` command for compiling the translation files, which the user must then run manually after installation.<br><br></blockquote><div><br></div><div>Another option is to look at PEP 517-compatible tools like Enscons which will give you more control over the wheel compilation process without having to try to hack your way into Setuptools.<br></div></div></div>