astropy/astropy — Issue #123: What to do when ~/.astropy is not writeable
Author: astrofrog
Created: 2012-01-07 10:22:01+00:00
State: open

While trying to run the astropy build on a mac with Jenkins to automate testing with different Python versions, I ran into an issue. The tests are run using the anonymous user, and when Jenkins tries to build astropy, it needs to be able to create the .astropy directory in the home directory. However, in this case, it tries to access ``/var/root``, which is of course not writeable:

Started by user anonymous
Checkout:workspace / /Users/Shared/Jenkins/Home/jobs/astropy-python2.7/workspace - hudson.remoting.LocalChannel@611c4041
Using strategy: Default
Last Built Revision: Revision 48af8d6b12f8b2964e037ee7137ad91fa298d5b7 (origin/HEAD, origin/master)
Checkout:workspace / /Users/Shared/Jenkins/Home/jobs/astropy-python2.7/workspace - hudson.remoting.LocalChannel@611c4041
Fetching changes from 1 remote Git repository
Fetching upstream changes from git://github.com/astropy/astropy.git
Seen branch in repository origin/HEAD
Seen branch in repository origin/master
Commencing build of Revision 48af8d6b12f8b2964e037ee7137ad91fa298d5b7 (origin/HEAD, origin/master)
Checking out Revision 48af8d6b12f8b2964e037ee7137ad91fa298d5b7 (origin/HEAD, origin/master)
Warning : There are multiple branch changesets here
[workspace] $ /bin/sh -xe /var/folders/zz/zzzivhrRnAmviuee+++++E++++2/-Tmp-/hudson8835089690851720710.sh
+ /opt/local/bin/python2.7 setup.py build
Traceback (most recent call last):
File "setup.py", line 11, in
import astropy
File "/Users/Shared/Jenkins/Home/jobs/astropy-python2.7/workspace/astropy/__init__.py", line 22, in
from .tests.helper import TestRunner
File "/Users/Shared/Jenkins/Home/jobs/astropy-python2.7/workspace/astropy/tests/__init__.py", line 8, in
from . import helper
File "/Users/Shared/Jenkins/Home/jobs/astropy-python2.7/workspace/astropy/tests/helper.py", line 16, in
from ..config import ConfigurationItem
File "/Users/Shared/Jenkins/Home/jobs/astropy-python2.7/workspace/astropy/config/__init__.py", line 11, in
from .data import *
File "/Users/Shared/Jenkins/Home/jobs/astropy-python2.7/workspace/astropy/config/data.py", line 15, in
'dataurl','http://data.astropy.org/','URL for astropy remote data site.')
File "/Users/Shared/Jenkins/Home/jobs/astropy-python2.7/workspace/astropy/config/configs.py", line 135, in __init__
self()
File "/Users/Shared/Jenkins/Home/jobs/astropy-python2.7/workspace/astropy/config/configs.py", line 264, in __call__
sec = get_config(self.module)
File "/Users/Shared/Jenkins/Home/jobs/astropy-python2.7/workspace/astropy/config/configs.py", line 342, in get_config
cfgfn = join(get_config_dir(),rootname+'.cfg')
File "/Users/Shared/Jenkins/Home/jobs/astropy-python2.7/workspace/astropy/config/paths.py", line 109, in get_config_dir
return path.abspath(_find_or_create_astropy_dir('config',linkto))
File "/Users/Shared/Jenkins/Home/jobs/astropy-python2.7/workspace/astropy/config/paths.py", line 154, in _find_or_create_astropy_dir
mkdir(innerdir)
OSError: [Errno 13] Permission denied: '/var/root/.astropy'
Build step 'Execute shell' marked build as failure
Finished: FAILURE

Of course, I can fix this by doing:

HOME=/Users/Shared/Jenkins python setup.py build

but this got me thinking that maybe at least (but not necessarily all) of the following should probably happen:

* ``~/.astropy`` should be created on ``install``, not ``build`` (in my view, ``build`` should only affect the local directory, while ``install`` can place files outside the tree)
* there should be a way to disable creating ``~/.astropy`` on build for this kind of situation
* if ``~/.astropy`` cannot be created, a warning should be raised, but this should not be fatal

@eteq, @mdboom, and @iguananaut - since you've been involved in the ``~/.astropy`` stuff I was wondering whether you have any thoughts regarding how this should behave?

In the mean time, I changed the build command to:

HOME=/tmp