The bug tracker for setuptools 0.7 or higher is on BitBucket

 

Issue93

Title SandboxViolation when opening os.devnull
Priority bug Status resolved
Superseder Nosy List habnabit, legolegs, pje, tec
Assigned To Keywords

Created on 2009-11-07.02:32:16 by habnabit, last changed 2013-05-25.17:05:04 by pje.

Messages
msg716 (view) Author: pje Date: 2013-05-15.22:06:25
Ok, I've applied this fix in development versions; from within your virtualenv you should be able to install "setuptools==dev06" to get the 0.6 development version.  Thanks for following up on this.
msg708 (view) Author: legolegs Date: 2013-03-17.17:37:37
Excuse me for inconvenience, I've should read the package description more carefully. However it is kinda tricky to determine which EasyInstall I am using. The system-wide installed rpm package has version 0.6.27, but I tried to install numpy inside virtualenv environment and file ./ENV/bin/easy_install looks like that:
=============
#!/home/legolegs/programing/mcedit/ENV/bin/python
# EASY-INSTALL-ENTRY-SCRIPT: 'setuptools==0.6c11','console_scripts','easy_install'
__requires__ = 'setuptools==0.6c11'
import sys
from pkg_resources import load_entry_point

sys.exit(
   load_entry_point('setuptools==0.6c11', 'console_scripts', 'easy_install')()
)
=============
That's confusing.

Anyway I managed to get a workaround using

$ virtualenv --unzip-setuptools ENV

and then applying this crude patch:

--- a/ENV/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg/setuptools/sandbox.py 2013-03-17 21:27:40.871240236 +0400
+++ b/ENV/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg/setuptools/sandbox.py 2013-03-17 21:27:27.259386248 +0400
@@ -207,6 +207,7 @@
         self._violation("tmpnam")
 
     def _ok(self,path):
+        if path==os.devnull: return True
         active = self._active
         try:
             self._active = False

Note the absence of "_" before "os" - as tec suggested. The condition "hasattr(_os,'devnull')" is false on my system.

The numpy has been installed (sort of), but spewed at me really big chunk of warnings and errors, not sure if it is ok or not, but my following adventures of course are not related to an issue discussed here.
msg707 (view) Author: tec Date: 2013-03-17.04:05:03
Another issue is that posix does not have devnull attribute: (at least for python 2.6.5)
>>> import sys,os
>>> os.name
'posix'
>>> sys.modules[os.name]
<module 'posix' (built-in)>
>>> hasattr(posix,'devnull')
False
>>> hasattr(os,'devnull')
True
>>> os.devnull
'/dev/null'
So this fix cannot work on Linux. (with python 2.6.5)
Why not check on os.devnull directly?
msg706 (view) Author: tec Date: 2013-03-17.03:26:41
I just download and install setuptools-0.6c11-py2.6.egg, and the bug still exists.

I have just checked the package provided on https://pypi.python.org/pypi/setuptools (around time 2013-3-17 3:10 UTC), but cannot find the fix in following 3 packages: (I've not checked others)
setuptools-0.6c11-py2.6.egg (md5) 	Python Egg 	2.6 	2009-10-20 	325KB 	1773276 (ms5: bfa92100bd772d5a213eedd356d64086)
setuptools-0.6c11-py2.7.egg (md5) 	Python Egg 	2.7 	2010-07-08 	324KB 	2046654 (md5: fe1f997bc722265116870bc7919059ea)
setuptools-0.6c11.tar.gz (md5) 	Source 		2009-10-20 	250KB 	438201 (md5: 7df2a529a074f613b509fb44feefe74e)
msg705 (view) Author: pje Date: 2013-03-16.18:41:53
There is no setuptools 0.6.27 -- you're using Distribute, not setuptools.

If the change had no effect on easy_install, it would be a good idea to check whether the easy_install you're running is the same as the one provided by your Fedora python-setuptools package.
msg704 (view) Author: legolegs Date: 2013-03-16.15:01:00
I had to reopen that issue.
Just tried to easy_install numpy:
================
Running from numpy source directory.
error: SandboxViolation: open('/dev/null', 'w') {}

The package setup script has attempted to modify files on your system
that are not within the EasyInstall build area, and has been aborted.
================
I'm using python-setuptools-0.6.27-2.fc17.noarch (fedora 17).
The file /usr/lib/python2.7/site-packages/setuptools/sandbox.py does not have fix with "hasattr" checks listed by pje. I tried to apply that path (as root) but it doesn't cause any changes in easy_install behavior.
msg602 (view) Author: pje Date: 2011-03-23.20:52:09
Closing, due to no reply being received in over a year.  (Patch has been in development snapshots for some time now, so it's assumed to be working.)
msg491 (view) Author: pje Date: 2010-02-01.17:51:41
Would you mind testing this patch (made against 0.6c11?  Thanks!

Index: setuptools/sandbox.py
===================================================================
--- setuptools/sandbox.py       (revision 75384)
+++ setuptools/sandbox.py       (working copy)
@@ -207,6 +207,7 @@
         self._violation("tmpnam")

     def _ok(self,path):
+        if hasattr(_os,'devnull') and path==_os.devnull: return True
         active = self._active
         try:
             self._active = False
msg459 (view) Author: habnabit Date: 2009-11-07.02:32:15
This is a bug in setuptools 0.6c9. Console output follows.

ender:test habnabit$ easy_install oursql
/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-
packages/Pyrex/Compiler/Errors.py:17: DeprecationWarning: BaseException.message 
has been deprecated as of Python 2.6
  self.message = message
Searching for oursql
Reading http://pypi.python.org/simple/oursql/
Reading http://launchpad.net/oursql
Best match: oursql 0.1
Downloading http://launchpad.net/oursql/trunk/0.1/+download/oursql-0.1.zip
Processing oursql-0.1.zip
Running oursql-0.1/setup.py -q bdist_egg --dist-dir 
/var/folders/vt/vtsTQLkkFNCqREdN+o2BqE+++TI/-Tmp-/easy_install-H7Ob5k/oursql-
0.1/egg-dist-tmp-xuwDCz
error: Setup script exited with error: SandboxViolation: open('/dev/null', 'w') 
{}

The package setup script has attempted to modify files on your system
that are not within the EasyInstall build area, and has been aborted.

This package cannot be safely installed by EasyInstall, and may not
support alternate installation locations even if you run its setup
script by hand.  Please inform the package's author and the EasyInstall
maintainers to find out if a fix or workaround is available.
History
Date User Action Args
2013-05-25 17:05:04pjesetstatus: chatting -> resolved
2013-05-15 22:06:25pjesetmessages: + msg716
2013-03-17 17:37:37legolegssetmessages: + msg708
2013-03-17 04:05:03tecsetmessages: + msg707
2013-03-17 03:26:41tecsetnosy: + tec
messages: + msg706
2013-03-16 18:41:53pjesetstatus: unread -> chatting
messages: + msg705
2013-03-16 15:01:00legolegssetstatus: resolved -> unread
nosy: + legolegs
messages: + msg704
2011-03-23 20:52:09pjesetstatus: testing -> resolved
messages: + msg602
2010-02-01 17:51:41pjesetstatus: unread -> testing
nosy: + pje
messages: + msg491
2009-11-07 02:32:16habnabitcreate