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

tests require easy_install, removed from setuptools 52+ #1893

Closed
hroncok opened this issue Feb 2, 2021 · 5 comments · Fixed by #1894
Closed

tests require easy_install, removed from setuptools 52+ #1893

hroncok opened this issue Feb 2, 2021 · 5 comments · Fixed by #1894
Labels
bug:normal affects many people or has quite an impact

Comments

@hroncok
Copy link
Contributor

hroncok commented Feb 2, 2021

I just wanted to build tox in Fedora after we have upgraded to setuptools 52 (no more easy_install) and two tests seem to be affected by the removal:

_________________________________ test_create __________________________________
[gw1] linux -- Python 3.9.1 /usr/bin/python3

mocksession = <tox._pytestplugin.create_mocksession.<locals>.MockSession object at 0x7f6f3911e670>
newconfig = <function create_new_config_file.<locals>.create_new_config_file_ at 0x7f6f391334c0>

    def test_create(mocksession, newconfig):
        config = newconfig(
            [],
            """\
            [testenv:py123]
            """,
        )
        envconfig = config.envconfigs["py123"]
        mocksession.new_config(config)
        venv = mocksession.getvenv("py123")
        assert venv.path == envconfig.envdir
        assert not venv.path.check()
        with mocksession.newaction(venv.name, "getenv") as action:
            tox_testenv_create(action=action, venv=venv)
        pcalls = mocksession._pcalls
        assert len(pcalls) >= 1
        args = pcalls[0].args
        assert "virtualenv" == str(args[2])
        if not tox.INFO.IS_WIN:
            # realpath is needed for stuff like the debian symlinks
            our_sys_path = py.path.local(sys.executable).realpath()
            assert our_sys_path == py.path.local(args[0]).realpath()
            # assert Envconfig.toxworkdir in args
>           assert venv.getcommandpath("easy_install", cwd=py.path.local())

action     = <tox.action.Action object at 0x7f6f39347100>
args       = ['/usr/bin/python3', '-m', 'virtualenv', '--no-download', '--python', '/usr/bin/python3', ...]
config     = <tox.config.Config object at 0x7f6f39347520>
envconfig  = <tox.config.TestenvConfig object at 0x7f6f3913ddc0>
mocksession = <tox._pytestplugin.create_mocksession.<locals>.MockSession object at 0x7f6f3911e670>
newconfig  = <function create_new_config_file.<locals>.create_new_config_file_ at 0x7f6f391334c0>
our_sys_path = local('/usr/bin/python3.9')
pcalls     = [<tox._pytestplugin.pcallMock object at 0x7f6f3a527760>]
venv       = <VirtualEnv at local('/tmp/pytest-of-mockbuild/pytest-0/popen-gw1/test_create0/.tox/py123')>

tests/unit/test_venv.py:81: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <VirtualEnv at local('/tmp/pytest-of-mockbuild/pytest-0/popen-gw1/test_create0/.tox/py123')>
name = 'easy_install', venv = True
cwd = local('/builddir/build/BUILD/tox-3.21.3')

    def getcommandpath(self, name, venv=True, cwd=None):
        """Return absolute path (str or localpath) for specified command name.
    
        - If it's a local path we will rewrite it as as a relative path.
        - If venv is True we will check if the command is coming from the venv
          or is allowed to come from external.
        """
        name = str(name)
        if os.path.isabs(name):
            return name
        if os.path.split(name)[0] == ".":
            path = cwd.join(name)
            if path.check():
                return str(path)
    
        if venv:
            path = self._venv_lookup_and_check_external_allowlist(name)
        else:
            path = self._normal_lookup(name)
    
        if path is None:
>           raise tox.exception.InvocationError(
                "could not find executable {}".format(pipes.quote(name)),
            )
E           tox.exception.InvocationError: InvocationError for command could not find executable easy_install

cwd        = local('/builddir/build/BUILD/tox-3.21.3')
name       = 'easy_install'
path       = None
self       = <VirtualEnv at local('/tmp/pytest-of-mockbuild/pytest-0/popen-gw1/test_create0/.tox/py123')>
venv       = True

../../BUILDROOT/python-tox-3.21.3-1.fc34.x86_64/usr/lib/python3.9/site-packages/tox/venv.py:193: InvocationError
_______________________ test_run_custom_install_command ________________________
[gw3] linux -- Python 3.9.1 /usr/bin/python3

newmocksession = <function newmocksession.<locals>.newmocksession_ at 0x7f26883edaf0>

    def test_run_custom_install_command(newmocksession):
        mocksession = newmocksession(
            [],
            """\
            [testenv]
            install_command=easy_install {opts} {packages}
            """,
        )
        venv = mocksession.getvenv("python")
        venv.just_created = True
        venv.envconfig.envdir.ensure(dir=1)
        with mocksession.newaction(venv.name, "hello") as action:
>           venv.run_install_command(packages=["whatever"], action=action)

action     = <tox.action.Action object at 0x7f2688379040>
mocksession = <tox._pytestplugin.create_mocksession.<locals>.MockSession object at 0x7f2683928910>
newmocksession = <function newmocksession.<locals>.newmocksession_ at 0x7f26883edaf0>
venv       = <VirtualEnv at local('/tmp/pytest-of-mockbuild/pytest-0/popen-gw3/test_run_custom_install_comman0/.tox/python')>

tests/unit/test_venv.py:914: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
../../BUILDROOT/python-tox-3.21.3-1.fc34.x86_64/usr/lib/python3.9/site-packages/tox/venv.py:426: in run_install_command
    self._pcall(
        action     = <tox.action.Action object at 0x7f2688379040>
        cmd        = ['easy_install', 'whatever']
        env        = {'CFLAGS': '-O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security...-fstack-clash-protection -fcf-protection', 'CONFIG_SITE': 'NONE', 'HISTCONTROL': 'ignoredups', 'HISTSIZE': '1000', ...}
        expand     = <function VirtualEnv.run_install_command.<locals>.expand at 0x7f2688371280>
        old_stdout = <_io.TextIOWrapper name="<_io.FileIO name=8 mode='rb+' closefd=True>" mode='r+' encoding='utf-8'>
        options    = ()
        packages   = ['whatever']
        self       = <VirtualEnv at local('/tmp/pytest-of-mockbuild/pytest-0/popen-gw3/test_run_custom_install_comman0/.tox/python')>
../../BUILDROOT/python-tox-3.21.3-1.fc34.x86_64/usr/lib/python3.9/site-packages/tox/venv.py:591: in _pcall
    args[0] = self.getcommandpath(args[0], venv, cwd)
        action     = <tox.action.Action object at 0x7f2688379040>
        args       = ['easy_install', 'whatever']
        bin_dir    = '/tmp/pytest-of-mockbuild/pytest-0/popen-gw3/test_run_custom_install_comman0/.tox/python/bin'
        cwd        = local('/tmp/pytest-of-mockbuild/pytest-0/popen-gw3/test_run_custom_install_comman0')
        env        = {'CFLAGS': '-O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security...-fstack-clash-protection -fcf-protection', 'CONFIG_SITE': 'NONE', 'HISTCONTROL': 'ignoredups', 'HISTSIZE': '1000', ...}
        ignore_ret = False
        is_test_command = False
        path       = '/builddir/build/BUILDROOT/python-tox-3.21.3-1.fc34.x86_64/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/sbin'
        redirect   = True
        returnout  = False
        self       = <VirtualEnv at local('/tmp/pytest-of-mockbuild/pytest-0/popen-gw3/test_run_custom_install_comman0/.tox/python')>
        venv       = True
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <VirtualEnv at local('/tmp/pytest-of-mockbuild/pytest-0/popen-gw3/test_run_custom_install_comman0/.tox/python')>
name = 'easy_install', venv = True
cwd = local('/tmp/pytest-of-mockbuild/pytest-0/popen-gw3/test_run_custom_install_comman0')

    def getcommandpath(self, name, venv=True, cwd=None):
        """Return absolute path (str or localpath) for specified command name.
    
        - If it's a local path we will rewrite it as as a relative path.
        - If venv is True we will check if the command is coming from the venv
          or is allowed to come from external.
        """
        name = str(name)
        if os.path.isabs(name):
            return name
        if os.path.split(name)[0] == ".":
            path = cwd.join(name)
            if path.check():
                return str(path)
    
        if venv:
            path = self._venv_lookup_and_check_external_allowlist(name)
        else:
            path = self._normal_lookup(name)
    
        if path is None:
>           raise tox.exception.InvocationError(
                "could not find executable {}".format(pipes.quote(name)),
            )
E           tox.exception.InvocationError: InvocationError for command could not find executable easy_install

cwd        = local('/tmp/pytest-of-mockbuild/pytest-0/popen-gw3/test_run_custom_install_comman0')
name       = 'easy_install'
path       = None
self       = <VirtualEnv at local('/tmp/pytest-of-mockbuild/pytest-0/popen-gw3/test_run_custom_install_comman0/.tox/python')>
venv       = True

../../BUILDROOT/python-tox-3.21.3-1.fc34.x86_64/usr/lib/python3.9/site-packages/tox/venv.py:193: InvocationError

The error is tox.exception.InvocationError: InvocationError for command could not find executable easy_install

@hroncok hroncok added the bug:normal affects many people or has quite an impact label Feb 2, 2021
@gaborbernat
Copy link
Member

Feel free to fill in a PR to fix it 👍🏻 thanks for catching this.

@hroncok
Copy link
Contributor Author

hroncok commented Feb 2, 2021

I'm investigating.

@hroncok
Copy link
Contributor Author

hroncok commented Feb 2, 2021

I don't understand the purpose of this assert:

assert venv.getcommandpath("easy_install", cwd=py.path.local())

Can I safely replace the string with pip and assert that? What are we actually asserting?

@gaborbernat
Copy link
Member

Yes 👍🏻 It just tests that a command specified as a path works 👍🏻

@hroncok
Copy link
Contributor Author

hroncok commented Feb 2, 2021

#1894

clrpackages pushed a commit to clearlinux-pkgs/tox that referenced this issue Feb 4, 2021
commit ff9990a2bf4e6540768b6371f2dd4c1d19014a30
Author: Bernát Gábor <bgabor8@bloomberg.net>
Date:   Tue Feb 2 19:14:39 2021 +0000

    release 3.21.4

commit 7355b6559801cff3a2249eb3865eaf6f6887c26c
Author: Miro Hrončok <miro@hroncok.cz>
Date:   Tue Feb 2 20:13:01 2021 +0100

    Adapt tests not to assume easy_install exists, it was removed from setuptools (#1894)

    Fixes tox-dev/tox#1893
ssbarnea pushed a commit to ssbarnea/tox that referenced this issue Apr 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug:normal affects many people or has quite an impact
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants