Re-sending to the list as well:
---------- Forwarded message ----------
From: Leonardo Rochael Almeida <leorochael(a)gmail.com>
Date: 3 February 2016 at 16:23
Subject: Re: [Distutils] setup('postinstall'='my.py')
To: Alt Sheets <altsheets(a)gmail.com>
On 3 February 2016 at 14:45, Alt Sheets <altsheets(a)gmail.com> wrote:
> Thx for your answer!
> I am a bit surprised it turns out to be such a difficult thing to do.
> Aren't postinstall scripts pretty standard?
They're common in infrastructure designed to install software packages into
operating systems, e.g. dpkg/rpm for Linux distros and Windows installers.
On the other hand, I don't think there's a post-install in the usual way of
installing things on the Mac. It's just a folder that is dragged into
another folder (not a Mac user myself, so I could be wrong, there could be
some side effects on this action).
In any case, AFAIU, the use-case for pypa stack is mostly about
distributing (Python) code, not end-user applications. There's also some
consideration (and disagreement) about running arbitrary code during
install, which could be a privileged operation compared to just using a
> mentioned a windows installer,
> I want to deploy through windows installer, but also through pypi.
> All ways necessary to get to the people.
Consider in which ways the users of your package might want or not the UUID
to be generated automatically depending on whether they're using the
installer or some other package.
I, for example, would not want the UUID generated automatically in a
machine that is used for automatic testing of your package, as I might want
to use a pre-determined UUID to simulate certain situations...
> thing about setup.py is that it only runs at "build time".
> Does that mean that setup.py is then also not run during deployment
> through pypi?
No. By the time a wheel is generated (or an egg, or any other bdist_*
command is run) the job of the setup.py for your package is done.
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
On the other hand, if someone creates a local package index (or find-links
location), they could put a pre-built package there and every install will
use the pre-built package, with its already generated UUID.
In your case, besides the tweaking of the Windows installer, I would
consider the following strategies:
- Create the UUID on first run (e.g. at import time)
- Add a script (or function) for creating the UUID and document for your
users that it needs to be called before using your library
In the cases above, the first time your application is run could be under
different privileges than those when it was installed, so it might not be
able to write to the same places. So you need to consider where exactly
you'll write this UUID, like:
- Somewhere on the Windows Registry
- A File in the user home
Thanks a lot! Very helpful.