PBR command classes overwrite setup.cfg cmdclass settings

Bug #1300381 reported by Sam Stavinoha
16
This bug affects 3 people
Affects Status Importance Assigned to Milestone
PBR
Triaged
Low
Unassigned
satori
New
Undecided
Unassigned

Bug Description

A user should be able to subclass pbr's command classes found in pbr/packaging.py, and declare that they be used by specifying them in the setup.cfg:

_____________________________________

# setup.cfg

[global]
commands = setup.MyLocalInstall
_____________________________________

The MyLocalInstall class might be defined in the project's setup.py:

_____________________________________

# setup.py

from pbr.packaging import LocalInstall

class MyLocalInstall(LocalInstall):

    # override __init__() and run()
    ...
_____________________________________

After noticing that my custom class wasn't being called, I traced the behavior to here:

https://github.com/openstack-dev/pbr/blob/master/pbr/util.py#L360

Since pbr.hooks.commands appends to a string of command class names, the pbr classes are always at the end of that string. Any command class specified in setup.cfg that has the same `command_name` (class attribute) as a pbr class defined in pbr.packaging, the class from pbr.packaging will overwrite that class in the config returned by setup_cfg_to_setup_kwargs().

Sam Stavinoha (smlstvnh)
description: updated
Revision history for this message
Doug Hellmann (doug-hellmann) wrote :

I'm not certain this is something we want to support in pbr.

What's the use case for overriding the install command?

Revision history for this message
Sam Stavinoha (smlstvnh) wrote :

I have seen various threads on extending setuptools command classes...

http://stackoverflow.com/questions/15853058/run-custom-task-when-call-pip-install
http://stackoverflow.com/questions/17806485/execute-a-python-script-post-install-using-distutils-setuptools
http://www.niteoweb.com/blog/setuptools-run-custom-code-during-install

but for me it was to add user_options and execute additional tasks based on those options. e.g. installing an additional package for a tag like --with-redis, where in my code I try, except imports when constructing the database client instance.

Regarding this bug:

The only time this occurs is if a command class is specified for which pbr has a corresponding command class (has the same `command_name`). I created custom classes for 'develop' and 'install', but only the class I created for 'install' was being overwritten, which I thought was pretty odd behavior.

I have other packages using this type of setup for custom command classes, and no matter the purpose of the customization, I would really like to start using pbr on all of those projects, but this prevents me from doing so.

I went ahead and submitted a patch just in case:

https://review.openstack.org/#/c/84218/

Changed in pbr:
status: New → Triaged
importance: Undecided → Low
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Change abandoned on pbr (master)

Change abandoned by lifeless (<email address hidden>) on branch: master
Review: https://review.openstack.org/84218
Reason: WIP is still in the review queue, marking abandoned.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.