[Distutils] Execute command before pip install

Brett Cannon brett at python.org
Wed Apr 11 13:54:32 EDT 2018

On Wed, 11 Apr 2018 at 10:36 John Thorvald Wodder II <jwodder at gmail.com>

> > On 2018 Apr 11, at 06:55, Jorge Maldonado Ventura <
> jorgesumle at freakspot.net> wrote:
> >
> > I need to execute a command automatically when running `pip install` to
> solve https://notabug.org/jorgesumle/boot-em-all/issues/1
> >
> > 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?
> >
> > The whole code is free software, so you can check my `setup.py` file.
> The repository can be cloned executing `git clone
> https://notabug.org/jorgesumle/boot-em-all`
> <https://notabug.org/jorgesumle/boot-em-all>.
> 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:

Yep, it's by design to make installation as fast as copying some files from
a zip file.

> 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.
> 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.
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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/distutils-sig/attachments/20180411/8e3059e7/attachment-0001.html>

More information about the Distutils-SIG mailing list