Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 763045 - sys-apps/portage: portage._python_interpreter realpath usage is incompatible with virtualenv
Summary: sys-apps/portage: portage._python_interpreter realpath usage is incompatible ...
Status: RESOLVED FIXED
Alias: None
Product: Portage Development
Classification: Unclassified
Component: Core (show other bugs)
Hardware: All All
: Normal normal (vote)
Assignee: Portage team
URL:
Whiteboard:
Keywords: InVCS
Depends on:
Blocks:
 
Reported: 2021-01-02 06:21 UTC by Zac Medico
Modified: 2022-03-05 07:09 UTC (History)
0 users

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


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Zac Medico gentoo-dev 2021-01-02 06:21:32 UTC
When running unit tests in tox, the sys.path of the python interpreter varies depending on the path that python is invoked with, and the _python_interpreter = os.path.realpath(sys.executable) setting interferes with that. This causes unit tests to fail if a required python library is not available outside of the virtualenv that tox has created.

This issue blocks repoman unit tests from succeeding github, which can be observed if we enable the repoman tests by installing libxml2-dev libxml2-utils:

> diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
> index 09c944ba1..d4b960dc3 100644
> --- a/.github/workflows/ci.yml
> +++ b/.github/workflows/ci.yml
> @@ -30,5 +30,5 @@ jobs:
>        run: |
>          set -xe
> -        sudo apt-get install -y --no-install-recommends libxslt-dev libxml2-dev zstd
> +        sudo apt-get install -y --no-install-recommends libxslt-dev libxml2-dev libxml2-utils zstd
>          python -VV
>          python -m site

It triggers this error:

>   testSimple (repoman.tests.simple.test_simple.SimpleRepomanTestCase) ... Traceback (most recent call last):
>     File "/home/runner/work/portage/portage/repoman/bin/repoman", line 41, in <module>
>       from repoman.main import repoman_main
>     File "/home/runner/work/portage/portage/repoman/lib/repoman/main.py", line 33, in <module>
>       from repoman.scanner import Scanner
>     File "/home/runner/work/portage/portage/repoman/lib/repoman/scanner.py", line 19, in <module>
>       from repoman.modules.scan.module import ModuleConfig
>     File "/home/runner/work/portage/portage/repoman/lib/repoman/modules/scan/module.py", line 9, in <module>
>       import yaml
>   ModuleNotFoundError: No module named 'yaml'

https://github.com/gentoo/portage/runs/1635672237
Comment 1 Zac Medico gentoo-dev 2021-01-02 06:28:44 UTC
The realpath was first introduced in this commit:

https://gitweb.gentoo.org/proj/portage.git/commit/?id=10e78f24f72aee03f6a66ada1bd83d8ea191446b

commit 10e78f24f72aee03f6a66ada1bd83d8ea191446b
Author: Arfrever Frehtes Taifersar Arahesis <Arfrever@Gentoo.Org>
Date:   2010-08-16 18:11:06 +0200

    Ensure that PORTAGE_PYTHON isn't a symlink.

 pym/portage/package/ebuild/doebuild.py          | 2 +-
 pym/portage/tests/ebuild/test_doebuild_spawn.py | 2 +-
 pym/portage/tests/ebuild/test_ipc_daemon.py     | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)
Comment 2 Larry the Git Cow gentoo-dev 2021-01-02 08:16:19 UTC
The bug has been referenced in the following commit(s):

https://gitweb.gentoo.org/proj/portage.git/commit/?id=cd98dc8ccff848e9750fb729aea3de2b6c34495c

commit cd98dc8ccff848e9750fb729aea3de2b6c34495c
Author:     Zac Medico <zmedico@gentoo.org>
AuthorDate: 2021-01-02 06:57:30 +0000
Commit:     Zac Medico <zmedico@gentoo.org>
CommitDate: 2021-01-02 08:15:45 +0000

    ci: enable repoman tests
    
    Bug: https://bugs.gentoo.org/763045
    Signed-off-by: Zac Medico <zmedico@gentoo.org>

 .github/workflows/ci.yml | 2 +-
 lib/portage/__init__.py  | 3 ++-
 tox.ini                  | 2 +-
 3 files changed, 4 insertions(+), 3 deletions(-)