Setting a sane default for DIST_MODULE_PATH

Hi folks,

When installing the latest ansible (1.6.3) as a normal
“unprivileged” user in a virtualenv via pip, this error
is generated:

error: could not create ‘/usr/share/ansible’: Permission denied

Comments on a ticket not that ansible is a
“…systems application, not just a python library”::

https://github.com/ansible/ansible/issues/7450

I’d like to consider that there may be instances where
installing ansible in a more isolated environment would
be preferable to injecting ansible into the sys.prefix
or /usr/local/share.

I’d like to propose using ‘~/.ansible’ as a fallback.

In my environment, my preference is to leave the
system python alone, and use isolated virtualenv
setups for application installs. Ansible runs as
a non-privileged user, and I’d expect it to be able
to install without sudo/root privs.

I’m sure there are holes in my logic, but I’d suggest
a patch that sets DIST_MODULE_PATH up front,
similar to the changes here:

https://github.com/itd/ansible/blob/devel/lib/ansible/constants.py#L93

Lines 93-104 are the changes.

It uses the current default of ‘/usr/share/ansible/’
but if the dir doesn’t already exist, and
the user can’t create that dir, it assumes
~/.ansible/ as the default.

Okay. Tell me that it’s a bad idea and why, and I’ll gladly
eat crow.

Thanks,
Kurt

So Twitter was saying they had some patches that dealt with this using setuptools, I’m still open to them, and this would make user level installs in pip a thing.

I think I’d prefer that than the system trying another path if the thing wasn’t writeable, as that may happen if someone just forgets to sudo.

I don’t think I like ~/.ansible as that tends to imply a data file directory and if things were lurking there, people might have mixed versions of ansible and their library files.

Open to ideas.