Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 533556 - dev-python/logilab-common fails test if older version is already installed
Summary: dev-python/logilab-common fails test if older version is already installed
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Eclasses (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Python Gentoo Team
URL:
Whiteboard:
Keywords:
: 546686 (view as bug list)
Depends on:
Blocks:
 
Reported: 2014-12-25 23:26 UTC by Ian Delaney (RETIRED)
Modified: 2016-09-13 12:28 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
my emerge --info (emerge.info,5.42 KB, application/x-info)
2014-12-25 23:26 UTC, Ian Delaney (RETIRED)
Details
build log of the test run (logilab-common-0.63.2-build.log,77.06 KB, text/x-log)
2014-12-25 23:28 UTC, Ian Delaney (RETIRED)
Details
diff -u of most recent ebuild ebuild or the new release (logilab-common-0.63.2.diff,1.15 KB, patch)
2014-12-25 23:30 UTC, Ian Delaney (RETIRED)
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Ian Delaney (RETIRED) gentoo-dev 2014-12-25 23:26:53 UTC
Created attachment 392402 [details]
my emerge --info

The new release of logilab-common, 0.63.2 has the testsuite fail with the setup inherited by the previous ebuild.  The suite is written to be run post system install.

~/cvsPortage/gentoo-x86/dev-python/logilab-common $ PYTHON_TARGETS=python2_7 ebuild logilab-common-0.63.2.ebuild clean test

yields

going into /mnt/gen2/TmpDir/portage/dev-python/logilab-common-0.63.2/work/logilab-common-0.63.2-python2_7/build/test/lib/logilab_common-0.63.2-py2.7.egg/logilab/common/test
*******************************************************************************
Ran 427 test cases in 11.38s (0.36s CPU), 1 skipped
All 22 modules OK
>>> Completed testing dev-python/logilab-common-0.63.2

with py3.3

Ran 419 test cases in 11.48s (0.47s CPU), 24 skipped
All 21 modules OK
>>> Completed testing dev-python/logilab-common-0.63.2

The outcome though is conditional.  With the package purged from the system, the testsuite will pass fine.  If the prior version is installed, it will fail with a series of 

------------------------------------------
  File "/mnt/gen2/TmpDir/portage/dev-python/logilab-common-0.63.2/work/logilab-common-0.63.2-python2_7/build/test/lib/logilab_common-0.63.2-py2.7.egg/logilab/common/test/unittest_pytest.py", line 54, in test_replace_trace
    with replace_trace(tracefn):
NameError: global name 'replace_trace' is not defined
-----------------------------------------

ditto py3.3

a Simple grep between the two files pytest.py between the 2 versions reveals "replace_trace" is a new addition to logilab's inhouse testrunner 'pytest'.  This is proof enough that if a previous version is installed, the testsuite imports from the installed system and not the local structure generated by 'distutils_install_for_testing'.  It appears to be a case of PYTHONPATH needing to point ONLY at the source generated by this function. It seems to be over-ridden.

The log submitted here lists some other failures occurring in the run by py3.3. These are separate issues of the suite or package itself.
Comment 1 Ian Delaney (RETIRED) gentoo-dev 2014-12-25 23:28:18 UTC
Created attachment 392404 [details]
build log of the test run
Comment 2 Ian Delaney (RETIRED) gentoo-dev 2014-12-25 23:30:45 UTC
Created attachment 392406 [details, diff]
diff -u of most recent ebuild ebuild or the new release
Comment 3 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2014-12-25 23:44:08 UTC
Please follow the rules when assigning bugs.
Comment 4 Matthew Thode ( prometheanfire ) archtester Gentoo Infrastructure gentoo-dev Security 2014-12-26 01:36:35 UTC
what rules?
Comment 5 Ian Delaney (RETIRED) gentoo-dev 2014-12-26 02:42:24 UTC
mgorny CC'd in light of him being the author of the eclass and this function
Comment 6 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2014-12-26 09:55:45 UTC
(In reply to Ian Delaney from comment #5)
> mgorny CC'd in light of him being the author of the eclass and this function

Please restrain from adding random people to CC. In case you didn't get that yet, I'm on python@.
Comment 7 Tiziano Müller (RETIRED) gentoo-dev 2016-09-13 11:56:43 UTC
*** Bug 546686 has been marked as a duplicate of this bug. ***
Comment 8 Tiziano Müller (RETIRED) gentoo-dev 2016-09-13 12:00:04 UTC
this has nothing to do with `distutils_install_for_testing`: the testsuite does not expect the package to be installed (otherwise it would actually install the tests in site-packages as well, which it does not).

The problem is that `logilab.common` declares a namespace and namespaces have precedence over simple modules causing an already installed module (belonging to that namespace) to be loaded before.

This can be checked by looking at `python -c 'import sys; print(sys.modules)'`.
Comment 9 Tiziano Müller (RETIRED) gentoo-dev 2016-09-13 12:28:29 UTC
I've fixed this in the version bump to 1.2.2 by manually clearing the list of registered modules in the runscript (in a `pytest-local` based on `pytest`):

  import sys
  try:
      # remove an already installed logilab-common module from
      # the list of namespaces to force the local module to be tested
      del sys.modules['logilab']
  except KeyError:
      pass

This forces the local module to be used instead of one already registered for the namespace. Compare (nicer output with python2, but the same with python3):

/tmp/logilab-common-1.2.2 $ PYTHONPATH=. python2 -v -c 'import logilab.common' |& grep "import logilab"
import logilab.common # directory /usr/lib64/python2.7/site-packages/logilab/common
import logilab.common # from /usr/lib64/python2.7/site-packages/logilab/common/__init__.py
import logilab # directory /tmp/logilab-common-1.2.2/logilab
import logilab # precompiled from /tmp/logilab-common-1.2.2/logilab/__init__.pyc

vs.

/tmp/logilab-common-1.2.2 $ PYTHONPATH=. python2 -v -c 'import sys; del sys.modules["logilab"]; import logilab.common' |& grep "import logilab"
import logilab # directory logilab
import logilab # precompiled from logilab/__init__.pyc
import logilab.common # directory logilab/common
import logilab.common # precompiled from logilab/common/__init__.pyc

In the first example logilab.common is directly loaded from site-packages while only the logilab/__init__.py from the local dir is used (which contains nothing).
The second one shows the correct way: first load logilab and then logilab.common from the local dir.