[Distutils] Fwd: setup('postinstall'='my.py')

Paul Moore p.f.moore at gmail.com
Wed Feb 3 14:29:41 EST 2016

On 3 February 2016 at 19:04, Leonardo Rochael Almeida
<leorochael at gmail.com> wrote:
> Unless, of course, you only upload the source package to PyPI. But in this
> case your setup.py will be run on every machine only as a side effect of the
> fact that your package would have to be built every time it is downloaded.

Modern versions of pip would build once and then cache the generated
wheel on all subsequent installs.

Long story short - for distribution Python *packages*, there is no
real "post-install" step, and your setup.py cannot even be guaranteed
to be run on the target machine, let alone for every install.

>From the OP's description, he may in fact be building a Python
*application*. Many Python applications can be (and are) distributed
as packages with entry points for the actual executable command(s).
But that's only really the correct option for applications that can
live with the limitations involved (no post-install step, etc).

Looking at your application (which I deduce is at
https://github.com/altsheets/coinquery) it looks like the sort of
thing that would *almost* work as a package distribution, except for
this "UID" initial setup step. Have you thought of maybe not relying
on the UID being generated at "install" time, but rather having a
"coinq init" command that the user runs *once* to set up his/her UID?
The other commands could then check for that UID wherever you choose
to store it, and if they don't find it bail out with an error message
something like "You need to initialise your environment with 'coinq
init' before running coinq commands". (Or they could even
automatically run init if they find no UID).

I know this isn't how you originally thought of the design - it's a
question of whether you want to modify the design to work with the
tools you have, or use different tools that let you achieve what you
want (in this case, a standard installer and some sort of py2exe or
zipapp type of solution).


More information about the Distutils-SIG mailing list