Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test_sysconfig failure when prefix matches /site #54295

Closed
hfuru mannequin opened this issue Oct 13, 2010 · 12 comments
Closed

test_sysconfig failure when prefix matches /site #54295

hfuru mannequin opened this issue Oct 13, 2010 · 12 comments
Assignees
Labels
stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@hfuru
Copy link
Mannequin

hfuru mannequin commented Oct 13, 2010

BPO 10086
Nosy @tarekziade, @merwok
Files
  • fix10086.diff
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = 'https://github.com/merwok'
    closed_at = <Date 2011-08-31.15:37:08.016>
    created_at = <Date 2010-10-13.14:39:12.841>
    labels = ['type-bug', 'library']
    title = 'test_sysconfig failure when prefix matches /site'
    updated_at = <Date 2011-08-31.15:37:08.014>
    user = 'https://bugs.python.org/hfuru'

    bugs.python.org fields:

    activity = <Date 2011-08-31.15:37:08.014>
    actor = 'eric.araujo'
    assignee = 'eric.araujo'
    closed = True
    closed_date = <Date 2011-08-31.15:37:08.016>
    closer = 'eric.araujo'
    components = ['Distutils', 'Library (Lib)', 'Distutils2']
    creation = <Date 2010-10-13.14:39:12.841>
    creator = 'hfuru'
    dependencies = []
    files = ['19264']
    hgrepos = []
    issue_num = 10086
    keywords = ['patch', 'needs review']
    message_count = 12.0
    messages = ['118525', '118559', '118580', '118664', '119037', '119038', '119040', '120213', '137986', '143259', '143262', '143263']
    nosy_count = 4.0
    nosy_names = ['hfuru', 'tarek', 'eric.araujo', 'python-dev']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue10086'
    versions = ['3rd party', 'Python 2.7', 'Python 3.2', 'Python 3.3']

    @hfuru
    Copy link
    Mannequin Author

    hfuru mannequin commented Oct 13, 2010

    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

    @hfuru hfuru mannequin added tests Tests in the Lib/test dir type-bug An unexpected behavior, bug, or error labels Oct 13, 2010
    @pitrou pitrou added stdlib Python modules in the Lib dir and removed tests Tests in the Lib/test dir labels Oct 13, 2010
    @merwok
    Copy link
    Member

    merwok commented Oct 13, 2010

    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”.)

    @hfuru
    Copy link
    Mannequin Author

    hfuru mannequin commented Oct 13, 2010

    "./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/.

    @hfuru
    Copy link
    Mannequin Author

    hfuru mannequin commented Oct 14, 2010

    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))

    @merwok
    Copy link
    Member

    merwok commented Oct 18, 2010

    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.

    @merwok merwok added the stdlib Python modules in the Lib dir label Oct 18, 2010
    @merwok
    Copy link
    Member

    merwok commented Oct 18, 2010

    I wrote too fast, I thought your diff was for sysconfig itself, not test_sysconfig.

    @merwok
    Copy link
    Member

    merwok commented Oct 18, 2010

    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?

    @hfuru
    Copy link
    Mannequin Author

    hfuru mannequin commented Nov 2, 2010

    �,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/..."

    @merwok
    Copy link
    Member

    merwok commented Jun 9, 2011

    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.

    1. 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 :)

    @merwok merwok changed the title test_sysconfig failure with site-packages test_sysconfig failure when prefix matches /site Jun 9, 2011
    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Aug 31, 2011

    New changeset 1e01543c3d0a by Éric Araujo in branch '3.2':
    Fix test_sysconfig when run from a Python installed under /site (bpo-10086).
    http://hg.python.org/cpython/rev/1e01543c3d0a

    New changeset 0968acf0e6db by Éric Araujo in branch 'default':
    Merge fix for bpo-10086 from 3.2
    http://hg.python.org/cpython/rev/0968acf0e6db

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Aug 31, 2011

    New changeset 4dcbae65df3f by Éric Araujo in branch '2.7':
    Fix test_sysconfig when run from a Python installed under /site (bpo-10086).
    http://hg.python.org/cpython/rev/4dcbae65df3f

    @merwok
    Copy link
    Member

    merwok commented Aug 31, 2011

    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.

    @merwok merwok closed this as completed Aug 31, 2011
    @merwok merwok assigned merwok and unassigned tarekziade Aug 31, 2011
    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants