[Distutils] Comments on PEP 426

Daniel Holth dholth at gmail.com
Thu Sep 5 14:34:28 CEST 2013


On Thu, Sep 5, 2013 at 5:36 AM, Oscar Benjamin
<oscar.j.benjamin at gmail.com> wrote:
> On 4 September 2013 19:16, Éric Araujo <merwok at netwok.org> wrote:
>> Le 30/08/2013 03:23, Paul Moore a écrit :
>>> On 30 August 2013 00:08, Nick Coghlan <ncoghlan at gmail.com> wrote:
>>>> We also need to officially bless pip's trick of forcing the use of
>>>> setuptools for distutils based setup.py files.
>>> Do we? What does official blessing imply? We've managed for years without
>>> the trick being "official"...
>>>
>>> The main reason it is currently used is to allow setup.py install to
>>> specify --record, so that we can get the list of installed files. If
>>> distutils added a --record flag, for example, I don't believe we'd need the
>>> hack at all. (Obviously, we'd still need setuptools so we could use wheel
>>> to build wheels, but that's somewhat different as it's a new feature).
>>> Maybe a small distutils patch is better than blessing setuptools here?
>>
>> distutils’ install command provides --record.
>
> Indeed it does. I've created a minimal pip-compatible setup.py here:
> https://github.com/oscarbenjamin/setuppytest
> https://github.com/oscarbenjamin/setuppytest/blob/master/setuppytest/setup.py
>
> The parts that pip requires that are not included in distutils are:
> 1) The egg_info command.
> 2) Creating the .egg-info directory during the install command.
> 3) --single-version-externally-managed
>
> I didn't test what happens if the sdist is installed to satisfy a
> dependency (I'm not sure how to do that without uploading to PyPI) but
> it presumably would do something different from
> --single-version-externally-managed in that case.
>
> The precise invocations that the setup.py needs to support are:
>
> python setup.py egg_info --egg-base $EGG_DIRECTORY
>
> $ python setup.py install --record $RECORD_FILE         \
>                     --single-version-externally-managed \
>                     [--install-headers $HEADERS_DIR]
>
> The --install-headers option is provided when installing into a virtualenv.
>
>
> Oscar
> _______________________________________________
> Distutils-SIG maillist  -  Distutils-SIG at python.org
> https://mail.python.org/mailman/listinfo/distutils-sig

--single-version-externally-managed just means "install everything
into a flat site-packages" rather than installing them into their own
(egg) directories.

If you would like to advance the state of the art of distutils you
should consider implementing a dist-info command that builds a
dist-info directory instead of an egg-info directory [it's possible
pip will recognize this automatically if it uses pkg_resources to
inspect the dependencies]. You could also try for a bdist_wheel
feature -- Vinay's distil has shown how this can be done with the
install command by passing --install-platlib=x etc. as per the wheel
layout, by converting egg-info to dist-info, by adding a manifest, and
zipping the result.

In setuptools you can just write the new command plugins once as an
add-on package and have them available in every sdist.

You might also look into supporting installs by an installer without
running the hated setup.py install command. The installer could always
generate an intermediate wheel, or it could avoid some of the (usually
very fast) copying by defining and generating a manifest of category
-> [{source path : destination path relative to the scheme}, ...] as
in "purelib" : [ { "src/__init__.py" -> "__init__.py'"}, ...]; the
installer would be able to interpret the manifest in much the same way
as a wheel package.


More information about the Distutils-SIG mailing list