[prev in list] [next in list] [prev in thread] [next in thread] 

List:       python-distutils-sig
Subject:    [Distutils]Possible change to PEP 517: look up the backend as $BACKEND.__build_backend__?
From:       Nathaniel Smith <njs () pobox ! com>
Date:       2018-06-24 6:19:35
Message-ID: CAPJVwBmnC7q1cGpoN=LMefMA9iWnZBRWewW1aC=smC7jXohA=w () mail ! gmail ! com
[Download RAW message or body]

Hi all,

I had a thought for something that might be a simple way to improve
dev experience with custom build backends.

A PEP 517 build backend is a Python object that has some special
methods on it. And the way a project picks which object to use, is via
pyproject.toml:

[build-system]
build-backend = "module1.module2:object"

Currently, this means that the build backend is the Python object:

module1.module2.object

Here's my idea: what if change it, so that the above config is
interpreted as meaning that the build backend is the Python object:

module1.module2.object.__build_backend__

(I.e., we tack a "__build_backend__" on the end before looking it up.)

Why does this matter? Well, with the current system, if you want to
use flit [1] as your build backend, you have to write:

build-backend = "flit.buildapi"

And if you want to use intreehooks [2],you have to writ:

build-backend = "intreehooks:loader"

These names are slightly awkward, because these projects don't want to
just jam all the PEP 517 methods directly onto the top-level module
object, so they each have to invent some ad hoc sub-object to put the
methods on. And then that's exposed to all their users as a bit of
random cruft you have to copy-paste.

The idea of __build_backend__ is that these projects could rename the
'buildapi' and 'loader' objects to be '__build_backend__' instead, and
then users could write:

build-backend = "flit"
build-backend = "intreehooks"
build-backend = "setuptools"

and it just feels nicer.

Right now PEP 517 is still marked provisional, and pip hasn't shipped
support yet, so I think changing this is still pretty easy. (It would
mean a small amount of work for projects like flit that have already
implemented backends.)

What do you think? (Thomas, I'd love your thoughts in particular :-).)

-n

[1] https://github.com/takluyver/flit/
[2] https://github.com/takluyver/intreehooks

-- 
Nathaniel J. Smith -- https://vorpus.org
--
Distutils-SIG mailing list -- distutils-sig@python.org
To unsubscribe send an email to distutils-sig-leave@python.org
https://mail.python.org/mm3/mailman3/lists/distutils-sig.python.org/
Message archived at https://mail.python.org/mm3/archives/list/distutils-sig@python.org/message/FTYC5MD4GSNRWMVPF6ZNFWACTMF7K2Q5/



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic