distlib Wheel.install API - proposed changes - distlib users, please comment

The API for installing wheels in distlib [1] will need changes as a result of recent discussions around the need to have better control over how scripts are generated at installation time. Currently, the API looks like this: def install(self, paths, dry_run=False, executable=None, warner=None, lib_only=False): """ Install a wheel to the specified paths. If ``executable`` is specified, it should be the Unicode absolute path the to the executable written into the shebang lines of any scripts installed. If ``warner`` is specified, it should be a callable, which will be called with two tuples indicating the wheel version of this software and the wheel version in the file, if there is a discrepancy in the versions. This can be used to issue any warnings to raise any exceptions. If ``lib_only`` is True, only the purelib/platlib files are installed, and the headers, scripts, data and dist-info metadata are not written. The return value is a :class:`InstalledDistribution` instance unless ``lib_only`` is True, in which case the return value is ``None``. """ Internally, this method constructs a ScriptMaker [2] instance and uses it to write the scripts, any variants of the type fooX and foo-X.Y, and any native executable wrappers, to the installation target directory. Currently, scripts defined in exports (the equivalent of setuptools' "entry points") are written into the wheel at build time, and just copied to the target installation directory in this method. This is likely to change to require script generation as well as copying to happen at installation time. This means that we need to pass additional information to the install method, but the API already has quite a few keyword arguments, and it seems unwise to add any more. The "executable" argument is just passed to the ScriptMaker, and not otherwise used. So I propose to stream the API to be as follows: def install(self, paths, maker, options): The dry_run will be taken from the maker instance. The caller will be responsible for instantiating the maker and configuring it (e.g. setting a custom executable for shebangs, enabling fooX/foo-X.Y variants, etc). The warner and lib_only will be obtained from the options argument, which is just a holder for values in attributes, using warner = getattr(options, 'warner', None) lib_only = getattr(options, 'lib_only', False) Although this approach hides the individual options from the signature, which I don't like, it will avoid adding more arguments to the signature, which I do like. With PEP 426 still somewhat fluid, better controllability might require more options to be added. Does anyone have any views about this, or any suggestions for improvement? In the absence of any feedback, I'll make these changes soon. They will of course break any code you have which uses this API, hence the call for comments. Regards, Vinay Sajip [1] https://bitbucket.org/pypa/distlib/src/tip/distlib/wheel.py?at=default#cl-37... [2] https://bitbucket.org/pypa/distlib/src/tip/distlib/scripts.py?at=default#cl-...
participants (1)
-
Vinay Sajip