Issue #318 open

SandboxViolation with setup_requires and distribute installed in USER_BASE

Erik Bray
created an issue

This is related to issue #95. At some point distribute was fixed to detect when it's installed in the user's local site, and forces user=True for the easy_install command.

This creates a problem when installing a package that has requirements in setup_requires--those requirements should be installed in '.' (the cwd that setup.py was run from), but instead since {{{easy_install.init}}} forces {{{self.user = True}}}, easy_install tries to install the setup_requires packages to the user local dir, causing a SandboxViolation.

A simple fix is to add {{{user=False}}} when initializing the {{{easy_install}}} command obj in {{{Distribution.fetch_build_egg}}}. I tested that this solves the problem, though I haven't run the full test suite with that change.

Comments (12)

  1. Arfrever Frehtes Taifersar Arahesis

    The new test fails with Python 2.5:

    testExtractConst (setuptools.tests.DependsTests) ... ok
    testFindModule (setuptools.tests.DependsTests) ... ok
    testModuleExtract (setuptools.tests.DependsTests) ... ok
    testRequire (setuptools.tests.DependsTests) ... ok
    testContents (setuptools.tests.DistroTests) ... ok
    testDistroType (setuptools.tests.DistroTests) ... ok
    testEmpty (setuptools.tests.DistroTests) ... ok
    testExcludePackage (setuptools.tests.DistroTests) ... ok
    testExcludePackages (setuptools.tests.DistroTests) ... ok
    testIncludeExclude (setuptools.tests.DistroTests) ... ok
    testInvalidIncludeExclude (setuptools.tests.DistroTests) ... ok
    testAvailability (setuptools.tests.FeatureTests) ... ok
    testDefaults (setuptools.tests.FeatureTests) ... ok
    testFeatureOptions (setuptools.tests.FeatureTests) ... ok
    testFeatureWithInvalidRemove (setuptools.tests.FeatureTests) ... ok
    testUseFeatures (setuptools.tests.FeatureTests) ... ok
    testConflictingOptions (setuptools.tests.TestCommandTests) ... ok
    testDefaultSuite (setuptools.tests.TestCommandTests) ... ok
    testDefaultWModuleOnCmdLine (setuptools.tests.TestCommandTests) ... ok
    testLongOptSuiteWNoDefault (setuptools.tests.TestCommandTests) ... ok
    testNoSuite (setuptools.tests.TestCommandTests) ... ok
    testTestIsCommand (setuptools.tests.TestCommandTests) ... ok
    Doctest: api_tests.txt ... ok
    test_devnull (setuptools.tests.test_sandbox.TestSandbox) ... ok
    test_decompose (setuptools.tests.test_sdist.TestSdistTest) ... ok
    test_hfs_quote (setuptools.tests.test_sdist.TestSdistTest) ... ok
    test_manifest_is_read_with_surrogateescape_error_handler (setuptools.tests.test_sdist.TestSdistTest) ... ok
    test_manifest_is_read_with_utf8_encoding (setuptools.tests.test_sdist.TestSdistTest) ... ok
    test_manifest_is_written_with_surrogateescape_error_handler (setuptools.tests.test_sdist.TestSdistTest) ... ok
    test_manifest_is_written_with_utf8_encoding (setuptools.tests.test_sdist.TestSdistTest) ... ok
    Regression test for pull request #4: ensures that files listed in ... ok
    test_sdist_with_latin1_encoded_filename (setuptools.tests.test_sdist.TestSdistTest) ... ok
    test_sdist_with_utf8_encoded_filename (setuptools.tests.test_sdist.TestSdistTest) ... ok
    testCollection (setuptools.tests.test_resources.DistroTests) ... ok
    testDistroBasics (setuptools.tests.test_resources.DistroTests) ... ok
    testDistroDependsOptions (setuptools.tests.test_resources.DistroTests) ... ok
    testDistroDependsSimple (setuptools.tests.test_resources.DistroTests) ... ok
    testDistroMetadata (setuptools.tests.test_resources.DistroTests) ... ok
    testDistroParse (setuptools.tests.test_resources.DistroTests) ... ok
    testResolve (setuptools.tests.test_resources.DistroTests) ... ok
    testSetuptoolsDistributeCombination (setuptools.tests.test_resources.DistroTests) ... ok
    testBasics (setuptools.tests.test_resources.EntryPointTests) ... ok
    testParse (setuptools.tests.test_resources.EntryPointTests) ... ok
    testParseList (setuptools.tests.test_resources.EntryPointTests) ... ok
    testParseMap (setuptools.tests.test_resources.EntryPointTests) ... ok
    testRejects (setuptools.tests.test_resources.EntryPointTests) ... ok
    test_two_levels_deep (setuptools.tests.test_resources.NamespaceTests) ... ok
    testEmptyParse (setuptools.tests.test_resources.ParseTests) ... ok
    testSafeName (setuptools.tests.test_resources.ParseTests) ... ok
    testSafeVersion (setuptools.tests.test_resources.ParseTests) ... ok
    testSimpleRequirements (setuptools.tests.test_resources.ParseTests) ... ok
    testSplitting (setuptools.tests.test_resources.ParseTests) ... ok
    testVersionEquality (setuptools.tests.test_resources.ParseTests) ... ok
    testVersionOrdering (setuptools.tests.test_resources.ParseTests) ... ok
    testYielding (setuptools.tests.test_resources.ParseTests) ... ok
    testAdvancedContains (setuptools.tests.test_resources.RequirementsTests) ... ok
    testBasicContains (setuptools.tests.test_resources.RequirementsTests) ... ok
    testBasics (setuptools.tests.test_resources.RequirementsTests) ... ok
    testDistributeSetuptoolsOverride (setuptools.tests.test_resources.RequirementsTests) ... ok
    testOptionsAndHashing (setuptools.tests.test_resources.RequirementsTests) ... ok
    testOrdering (setuptools.tests.test_resources.RequirementsTests) ... ok
    testVersionEquality (setuptools.tests.test_resources.RequirementsTests) ... ok
    test_get_script_header (setuptools.tests.test_resources.ScriptHeaderTests) ... ok
    test_get_script_header_jython_workaround (setuptools.tests.test_resources.ScriptHeaderTests) ... ok
    test_develop (setuptools.tests.test_develop.TestDevelopTest) ... ok
    test_get_ext_filename (setuptools.tests.test_build_ext.TestBuildExtTest) ... ok
    test_create_zipfile (setuptools.tests.test_upload_docs.TestUploadDocsTest) ... ok
    test_test (setuptools.tests.test_test.TestTestTest) ... ok
    test_markers (setuptools.tests.test_markerlib.TestMarkerlib) ... ok
    test_bdist_egg (setuptools.tests.test_bdist_egg.TestDevelopTest) ... ok
    test_get_script_args (setuptools.tests.test_easy_install.TestEasyInstallTest) ... ok
    test_install_site_py (setuptools.tests.test_easy_install.TestEasyInstallTest) ... Creating /tmp/tmpztdGLc/site.py
    ok
    test_no_find_links (setuptools.tests.test_easy_install.TestEasyInstallTest) ... Not found: link1
    Not found: link2
    ok
    test_no_setup_cfg (setuptools.tests.test_easy_install.TestEasyInstallTest) ... ok
    a pth file manager should set dirty ... ok
    test_add_from_site_is_ignored (setuptools.tests.test_easy_install.TestPTHFileWriter) ... ok
    test_setup_requires_honors_fetch_params (setuptools.tests.test_easy_install.TestSetupRequires) ... Creating /tmp/tmpALT5Yt/site.py
    Processing distribute-test-fetcher-1.0.tar.gz
    Writing /tmp/easy_install-64aDiV/setup.cfg
    Running setup.py -q bdist_egg --dist-dir /tmp/easy_install-64aDiV/egg-dist-tmp-h-ugFP
    Checking .pth file support in .
    /usr/bin/python2.5 -E -c pass
    Searching for does-not-exist
    Reading http://localhost:41447/does-not-exist/
    Couldn't find index page for 'does-not-exist' (maybe misspelled?)
    Scanning index of all packages (this may take a while)
    Reading http://localhost:41447/
    No local packages or download links found for does-not-exist
    ok
    test_local_index (setuptools.tests.test_easy_install.TestUserInstallTest) ... Searching for foo
    Best match: foo 1.0
    Adding foo 1.0 to easy-install.pth file
    
    Using /tmp/tmpf5N4Wb
    ok
    test_multiproc_atexit (setuptools.tests.test_easy_install.TestUserInstallTest) ... ok
    Regression test for issue #318 ... ERROR
    test_user_install_implied (setuptools.tests.test_easy_install.TestUserInstallTest) ... ok
    test_user_install_not_implied_without_usersite_enabled (setuptools.tests.test_easy_install.TestUserInstallTest) ... ok
    test_conditional_dependencies (setuptools.tests.test_dist_info.TestDistInfo) ... ok
    test_distinfo (setuptools.tests.test_dist_info.TestDistInfo) ... ok
    
    ======================================================================
    ERROR: Regression test for issue #318
    ----------------------------------------------------------------------
    Traceback (most recent call last):
      File "/tmp/distribute-0.6.30/setuptools/tests/test_easy_install.py", line 312, in test_setup_requires
        lambda: run_setup(test_setup_py, ['install'])
      File "/tmp/distribute-0.6.30/setuptools/tests/test_easy_install.py", line 459, in reset_setup_stop_context
        f()
      File "/tmp/distribute-0.6.30/setuptools/tests/test_easy_install.py", line 312, in <lambda>
        lambda: run_setup(test_setup_py, ['install'])
      File "/tmp/distribute-0.6.30/setuptools/sandbox.py", line 30, in run_setup
        lambda: execfile(
      File "/tmp/distribute-0.6.30/setuptools/sandbox.py", line 78, in run
        return func()
      File "/tmp/distribute-0.6.30/setuptools/sandbox.py", line 32, in <lambda>
        {'__file__':setup_script, '__name__':'__main__'}
      File "setup.py", line 2, in <module>
      File "/usr/lib64/python2.5/distutils/core.py", line 168, in setup
        raise SystemExit, "error: " + str(msg)
    SystemExit: error: can't create or remove files in install directory
    
    The following error occurred while trying to add or remove files in the
    installation directory:
    
        [Errno 13] Permission denied: '/usr/lib64/python2.5/site-packages/test-easy-install-30276.write-test'
    
    The installation directory you specified (via --install-dir, --prefix, or
    the distutils default setting) was:
    
        /usr/lib64/python2.5/site-packages/
    
    Perhaps your account does not have write access to this directory?  If the
    installation directory is a system-owned directory, you may need to sign in
    as the administrator or "root" account.  If you do not have administrative
    access to this machine, you may wish to choose a different installation
    directory, preferably one that is listed in your PYTHONPATH environment
    variable.
    
    For information on other options, you may wish to consult the
    documentation at:
    
      http://packages.python.org/distribute/easy_install.html
    
    Please make the appropriate changes for your system and try again.
    
    
    ----------------------------------------------------------------------
    Ran 84 tests in 0.507s
    
    FAILED (errors=1)
    
  2. Erik Bray reporter

    I wasn't able to reproduce the reported issue with the tests on Python 2.5. The tests do fail on Python 2.4 but in a different way.

  3. Erik Bray reporter

    Scratch that--I figured out how to reproduce it. I wasn't able to before because I have write permission on my Python2.5 installation's site-packages. I think this can be fixed pretty easily.

  4. Log in to comment