This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: test_sysconfig failure when prefix matches /site
Type: behavior Stage: resolved
Components: Distutils, Distutils2, Library (Lib) Versions: Python 3.2, Python 3.3, Python 2.7, 3rd party
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: eric.araujo Nosy List: eric.araujo, hfuru, python-dev, tarek
Priority: normal Keywords: needs review, patch

Created on 2010-10-13 14:39 by hfuru, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
fix10086.diff eric.araujo, 2010-10-18 17:15 review
Messages (12)
msg118525 - (view) Author: Hallvard B Furuseth (hfuru) Date: 2010-10-13 14:39
test_sysconfig on Python 3.2a3 fails with AssertionError:
'/home/sjef/.local/lib/python3.2/site-packages' !=
'/home/sjef/.local/lib/python3.2/home/sjef/.local-packages'

Python-3.2a3$ ./python Lib/test/regrtest.py -v test_sysconfig
== CPython 3.2a3 (r32a3:85355, Oct 13 2010, 07:34:15) [GCC 4.4.3]
==   Linux-2.6.32-25-generic-x86_64-with-debian-squeeze-sid little-endian
==   /home/sjef/src/python/Python-3.2a3/build/test_python_17497
[1/1] test_sysconfig
test_get_config_h_filename (test.test_sysconfig.TestSysConfig) ... ok
test_get_config_vars (test.test_sysconfig.TestSysConfig) ... ok
test_get_makefile_filename (test.test_sysconfig.TestSysConfig) ... ok
test_get_path (test.test_sysconfig.TestSysConfig) ... ok
test_get_path_names (test.test_sysconfig.TestSysConfig) ... ok
test_get_paths (test.test_sysconfig.TestSysConfig) ... ok
test_get_platform (test.test_sysconfig.TestSysConfig) ... ok
test_get_scheme_names (test.test_sysconfig.TestSysConfig) ... ok
test_ldshared_value (test.test_sysconfig.TestSysConfig) ... ok
test_main (test.test_sysconfig.TestSysConfig) ... ok
test_symlink (test.test_sysconfig.TestSysConfig) ... ok
test_user_similar (test.test_sysconfig.TestSysConfig) ... FAIL

======================================================================
FAIL: test_user_similar (test.test_sysconfig.TestSysConfig)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/sjef/src/python/Python-3.2a3/Lib/test/test_sysconfig.py", line 278, in test_user_similar
    self.assertEquals(user_path, global_path.replace(base, user))
AssertionError: '/home/sjef/.local/lib/python3.2/site-packages' != '/home/sjef/.local/lib/python3.2/home/sjef/.local-packages'
- /home/sjef/.local/lib/python3.2/site-packages
?                                  ^^
+ /home/sjef/.local/lib/python3.2/home/sjef/.local-packages
?                                 +++++ ^ ++++++++


----------------------------------------------------------------------
Ran 12 tests in 0.145s

FAILED (failures=1)
test test_sysconfig failed -- Traceback (most recent call last):
  File "/home/sjef/src/python/Python-3.2a3/Lib/test/test_sysconfig.py", line 278, in test_user_similar
    self.assertEquals(user_path, global_path.replace(base, user))
AssertionError: '/home/sjef/.local/lib/python3.2/site-packages' != '/home/sjef/.local/lib/python3.2/home/sjef/.local-packages'
- /home/sjef/.local/lib/python3.2/site-packages
?                                  ^^
+ /home/sjef/.local/lib/python3.2/home/sjef/.local-packages
?                                 +++++ ^ ++++++++


1 test failed:
    test_sysconfig
msg118559 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2010-10-13 18:33
Thanks for the report.  Can you tell us what ./configure line you used before running make?  Or maybe you edited site.py or created a sitecustomize.py?

Tarek, Antoine: Is “Distutils” the right component for sysconfig bugs?  (I thought it would be “Library”.)
msg118580 - (view) Author: Hallvard B Furuseth (hfuru) Date: 2010-10-13 20:45
"./configure --prefix=/site" on Ubuntu.
Unedited site.py.
I had Python3.2a2 installed, but removing it did
not make the test do anything different.
Nor did removing /home/sjef/.local/lib/python3.2,
which only contained an empty site-packages/.
msg118664 - (view) Author: Hallvard B Furuseth (hfuru) Date: 2010-10-14 15:01
It's with 'purelib' because my prefix "/site" matches "/site-packages".
This fixes it for me, but maybe you should also assert that
global_path.startswith(os.path.join(base, "")).

--- Lib/test/test_sysconfig.py~	2010-09-20
+++ Lib/test/test_sysconfig.py	2010-10-14
@@ -278 +278 @@ class TestSysConfig(unittest.TestCase):
-            self.assertEquals(user_path, global_path.replace(base, user))
+            self.assertEquals(user_path, global_path.replace(base, user, 1))
msg119037 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2010-10-18 16:39
Thanks for the fix, good catch!  Do you want to write a patch to test_sysconfig to add a test?  Otherwise I’ll do it.
msg119038 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2010-10-18 16:43
I wrote too fast, I thought your diff was for sysconfig itself, not test_sysconfig.
msg119040 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2010-10-18 17:15
Attaching a patch with your two suggestions.

Two things worry me and prevent me from committing right now:
1) sysconfig was originally distutils.sysconfig, and some duplication remains.  Can’t this bug happen with distutils.sysconfig too?  Should we duplicate tests from test_sysconfig to distutils.test_sysconfig?

2) How to prevent a regression?  That is, how to run tests with custom ./configure options?
msg120213 - (view) Author: Hallvard B Furuseth (hfuru) Date: 2010-11-02 10:28
,AC�ric Araujo writes:
> Attaching a patch with your two suggestions.
> Added file: http://bugs.python.org/file19264/fix10086.diff

Not quite, since I suggested
   global_path.startswith(os.path.join(base, ""))
instead of
   global_path.startswith(base)

I should have mentioned, the join appends a directory terminator
to base.  Not sure if that's the correct way to do it.  Anyway,
your patch does not catch a similar failure (if this can happen):

   base        = "/site"
   global_path = "/site-nonsense/..."
msg137986 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2011-06-09 15:23
> 1) sysconfig was originally distutils.sysconfig, and some duplication
> remains.  Can’t this bug happen with distutils.sysconfig too?  Should
> we duplicate tests from test_sysconfig to distutils.test_sysconfig?

I’ve looked into it and converting the test to distutils.sysconfig is not trivial: the get_path function is wholly different in distutils, and I’m not even sure it’s possible to get the paths like test_sysconfig does.

> 2) How to prevent a regression?  That is, how to run tests with
> custom ./configure options?

I think I can commit this fix for a minor issue in a test without worrying about regressions.  I manually tested and it’s fixed.

> Anyway, your patch does not catch a similar failure (if this can
> happen):
>   base        = "/site"
>   global_path = "/site-nonsense/..."

If this can’t happen, let us not worry about it :)
msg143259 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2011-08-31 14:52
New changeset 1e01543c3d0a by Éric Araujo in branch '3.2':
Fix test_sysconfig when run from a Python installed under /site (#10086).
http://hg.python.org/cpython/rev/1e01543c3d0a

New changeset 0968acf0e6db by Éric Araujo in branch 'default':
Merge fix for #10086 from 3.2
http://hg.python.org/cpython/rev/0968acf0e6db
msg143262 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2011-08-31 15:35
New changeset 4dcbae65df3f by Éric Araujo in branch '2.7':
Fix test_sysconfig when run from a Python installed under /site (#10086).
http://hg.python.org/cpython/rev/4dcbae65df3f
msg143263 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2011-08-31 15:37
> I think I can commit this fix for a minor issue in a test without
> worrying about regressions.  I manually tested and it’s fixed.

Done!  Thanks again.
History
Date User Action Args
2022-04-11 14:57:07adminsetgithub: 54295
2011-08-31 15:37:08eric.araujosetstatus: open -> closed
messages: + msg143263

assignee: tarek -> eric.araujo
resolution: fixed
stage: patch review -> resolved
2011-08-31 15:35:19python-devsetmessages: + msg143262
2011-08-31 14:52:36python-devsetnosy: + python-dev
messages: + msg143259
2011-06-20 15:26:19vstinnersetnosy: - vstinner
2011-06-09 15:23:58eric.araujosettitle: test_sysconfig failure with site-packages -> test_sysconfig failure when prefix matches /site
messages: + msg137986
versions: + Python 3.3, - Python 3.1
2010-11-04 11:56:46vstinnersetnosy: + vstinner
2010-11-02 10:28:33hfurusetmessages: + msg120213
2010-10-18 17:15:15eric.araujosetkeywords: + patch, needs review
files: + fix10086.diff
messages: + msg119040

stage: needs patch -> patch review
2010-10-18 16:43:01eric.araujosetmessages: + msg119038
2010-10-18 16:39:46eric.araujosetnosy: hfuru, tarek, eric.araujo
messages: + msg119037
components: + Library (Lib), Distutils2
versions: + 3rd party, Python 3.1, Python 2.7
2010-10-14 15:01:58hfurusetmessages: + msg118664
2010-10-13 20:45:58hfurusetmessages: + msg118580
2010-10-13 18:33:40eric.araujosetmessages: + msg118559
2010-10-13 14:40:30pitrousetnosy: + eric.araujo, tarek

assignee: tarek
components: + Distutils, - Tests
stage: needs patch
2010-10-13 14:39:12hfurucreate