[Distutils] PEP 345, PEP 376, PEP 386
Paul Moore
p.f.moore at gmail.com
Thu Jun 4 15:59:59 CEST 2009
2009/6/4 Tarek Ziadé <ziade.tarek at gmail.com>:
> Paul
>> I'd say that it's distutils' responsibility not to offer to uninstall
>> anything it didn't install.
>
> Brian
>> Yep. Though I think that nowdays dpkg installs to a different directory than
>> Distutils' default. So users have to specify extra options to break
>> their systems.
>
> But how does those third-party install the projects ?
>
> Don't they use Distutils' install command under the hood ?
In the case of Windows, no. Maybe (I don't know) bdist_wininst uses
the install command to build the directory structure (under the build
directory) that is packed into a zip format as part of the final
installer EXE, but there's *other* files and data installed by the
bdist_wininst installer as well as the package data.
The installer generated by bdist_wininst contains an embedded zip of
the installed directory (minus compiled Python files - that's the
mistake eggs make, which cause them to be version-dependent for
pure-python files). The installer, when run, does the following:
- Pops up a GUI asking the user which system-installed Python
directory to install into (from the eligible ones)
- Unzips the embedded directory structure into the appropriate site-packages
- Writes an install log packagename-wininst.log into sys.prefix
recording all of the following actions
- Writes a prebuilt executable, which is *also* embedded in the
installer, as Removepackagename.exe in sys.prefix
- Writes metadata into the registry to add the package to Add/Remove,
which causes Removepackagename.exe to run on uninstall.
- Compile all .py files to .pyc and .pyo
Removepackagename.exe does the following:
- Locate packagename-wininst.log based on the name and location of the
Removepackagename.exe executable
- Remove files and registry entries based on the .log file
- Remove the .log file, and the uninstaller itself
(Note - the above is from memory and how I'd expect things to work.
I'd recommend reading the code if the details matter).
Also, you need to remember that bdist_wininst is not a "third-party"
tool. It's part of distutils (although it's probably written in such a
way that it could easily be extracted as a 3rd party addin - I
honestly don't know).
I'd seriously recommend looking at bdist_wininst as an example - it's
distributed with Python, so the source is easy to find, but it
installs extra system-level metadata above and beyond what setup.py
install does, so you can see what sorts of issues you have to deal
with. (Some of the Unix-level packagers like bdist_rpm may be equally
illuminating, but I've no experience with those).
Note - my understanding is that eggs and easy_install essentially
automate setup.py install (with the only relevant metadata to maintain
being the .pth files) so if your experience is limited to eggs you may
be missing the point of what people are saying here. If my attempts to
explain are unclear, feel free to ask more questions!
Paul.
More information about the Distutils-SIG
mailing list