[Distutils] SandboxViolation: mkdir('/usr/local/virtualenvs/ansible/share', 511) {}

PJ Eby pje at telecommunity.com
Thu Jan 10 01:02:14 CET 2013

On Wed, Jan 9, 2013 at 4:04 PM, Guy Rozendorn <guy at rzn.co.il> wrote:
> Hi,
> I'm trying to make ansible (https://github.com/Infinidat/ansible) compatible with easy_install (so I can use it later in places that use easy_install and not pip).
> When I install it with pip, everything works, but not with easy_install:
> ~/g/i/ansible git:devel ❯❯❯ easy_install -U ansible (env: ansible) ⬆ ✱ ◼
> Searching for ansible
> Reading http://pypi01.infinidat.com/simple/ansible/
> Best match: ansible 0.9-develop-30
> Downloading http://pypi01.infinidat.com/media/dists/ansible-0.9-develop-30.tar.gz#md5=121f662744b0e33b9516c87598650fca
> Processing ansible-0.9-develop-30.tar.gz
> Writing /var/folders/f9/d108d_ds0sz0_qlnzr25_bcr0000gn/T/easy_install-ThM02g/ansible-0.9-develop-30/setup.cfg
> Running ansible-0.9-develop-30/setup.py -q bdist_egg --dist-dir /var/folders/f9/d108d_ds0sz0_qlnzr25_bcr0000gn/T/easy_install-ThM02g/ansible-0.9-develop-30/egg-dist-tmp-kZvXdB
> DATA FILES=[('/usr/local/virtualenvs/ansible/share/ansible/', ['./library/add_host', './library/apt', './library/apt_repository', './library/assemble', './library/async_status', './library/async_wrapper', './library/authorized_key', './library/command', './library/copy', './library/cron', './library/debug', './library/easy_install', './library/ec2', './library/facter', './library/fail', './library/fetch', './library/file', './library/fireball', './library/get_url', './library/git', './library/group', './library/group_by', './library/ini_file', './library/lineinfile', './library/mail', './library/mount', './library/mysql_db', './library/mysql_user', './library/nagios', './library/ohai', './library/pause', './library/ping', './library/pip', './library/postgresql_db', './library/postgresql_user', './library/raw', './library/script', './library/seboolean', './library/selinux', './library/service', './library/setup', './library/shell', './library/slurp', './library/subversion', './library/supervisorctl', './library/svr4pkg', './library/template', './library/user', './library/virt', './library/wait_for', './library/yum'])]
> warning: no files found matching 'packaging/distutils/setup.py'
> error: Setup script exited with error: SandboxViolation: mkdir('/usr/local/virtualenvs/ansible/share', 511) {}
> AFAIK, the violation occurs becuase ansible wants to write stuff to /usr/local/virtualenv/ansible, which is out of the sandbox.
> According to http://docs.python.org/2/distutils/setupscript.html#installing-additional-files, data files can be outside of the sandbox ('/etc/init.d'), and it looks like this isn't supported by distribute?
> Any idea would be greatly appreciated.

One simple solution: move the 'library' directory to
lib/ansible/library (or some such), and include them as package data
files.  This will also allow you to fix a couple of other problems,
namely the sys.path munging in setup.py and the importing of
ansible.constants (both of which are not recommended practices for
setup scripts running under easy_install).

You would need to change the runtime code to fall back to the contents
of ansible.library if an item isn't found in share/ansible, but
basically that's it.  You then have a completely encapsulated

(Btw, it seems to me that your setup.py is listing your scripts
*twice* -- if you have a console_scripts entry point, it's not
necessary to also list them in scripts, and it can indeed introduce a
conflict.  You should only include the scripts entry if you aren't
running under setuptools or distribute, otherwise the console_scripts
list is sufficient.)

More information about the Distutils-SIG mailing list