Skip to content

testing/cffi1/test_cffi_gen_src_meson.py::test_meson_python_build don't work offline #255

Description

@mgorny

The tests added in #241 try to install meson-python directly from the Internet, even when it's installed on the system. This causes the tests to fail when run offline, and poses an unnecessary security danger:

__________________________________________________ test_meson_python_build[project0] __________________________________________________

tmp_path = PosixPath('/tmp/portage/dev-python/cffi-2.1.0/temp/pytest-of-portage/pytest-0/test_meson_python_build_projec0')
project = PosixPath('/tmp/portage/dev-python/cffi-2.1.0/work/cffi-2.1.0/testing/cffi1/cffi_gen_src_examples/exec_python_example')

    @pytest.mark.parametrize("project", [EXAMPLE_PROJECT, EXAMPLE_PROJECT2])
    def test_meson_python_build(tmp_path, project):
        venv_dir = tmp_path / "venv"
        subprocess.check_call([sys.executable, "-m", "venv", str(venv_dir)])
        venv_python = _venv_python(venv_dir)
        assert venv_python.exists(), venv_python
    
        # Upgrade pip so --no-build-isolation behaves consistently with recent
        # resolver behaviour on older base images.
        subprocess.check_call([
            str(venv_python), "-m", "pip", "install", "--upgrade", "pip",
        ])
    
        # Install build-time deps into the nested venv.
>       subprocess.check_call([
            str(venv_python), "-m", "pip", "install", "meson-python", CFFI_DIR
        ])

project    = PosixPath('/tmp/portage/dev-python/cffi-2.1.0/work/cffi-2.1.0/testing/cffi1/cffi_gen_src_examples/exec_python_example')
tmp_path   = PosixPath('/tmp/portage/dev-python/cffi-2.1.0/temp/pytest-of-portage/pytest-0/test_meson_python_build_projec0')
venv_dir   = PosixPath('/tmp/portage/dev-python/cffi-2.1.0/temp/pytest-of-portage/pytest-0/test_meson_python_build_projec0/venv')
venv_python = PosixPath('/tmp/portage/dev-python/cffi-2.1.0/temp/pytest-of-portage/pytest-0/test_meson_python_build_projec0/venv/bin/python')

testing/cffi1/test_cffi_gen_src_meson.py:58: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

popenargs = (['/tmp/portage/dev-python/cffi-2.1.0/temp/pytest-of-portage/pytest-0/test_meson_python_build_projec0/venv/bin/python', '-m', 'pip', 'install', 'meson-python', PosixPath('/tmp/portage/dev-python/cffi-2.1.0/work/cffi-2.1.0')],)
kwargs = {}

    def check_call(*popenargs, **kwargs):
        """Run command with arguments.  Wait for command to complete.  If
        the exit code was zero then return, otherwise raise
        CalledProcessError.  The CalledProcessError object will have the
        return code in the returncode attribute.
    
        The arguments are the same as for the call function.  Example:
    
        check_call(["ls", "-l"])
        """
        retcode = call(*popenargs, **kwargs)
        if retcode:
            cmd = kwargs.get("args")
            if cmd is None:
                cmd = popenargs[0]
>           raise CalledProcessError(retcode, cmd)
E           subprocess.CalledProcessError: Command '['/tmp/portage/dev-python/cffi-2.1.0/temp/pytest-of-portage/pytest-0/test_meson_python_build_projec0/venv/bin/python', '-m', 'pip', 'install', 'meson-python', PosixPath('/tmp/portage/dev-python/cffi-2.1.0/work/cffi-2.1.0')]' returned non-zero exit status 1.

cmd        = ['/tmp/portage/dev-python/cffi-2.1.0/temp/pytest-of-portage/pytest-0/test_meson_python_build_projec0/venv/bin/python',
 '-m',
 'pip',
 'install',
 'meson-python',
 PosixPath('/tmp/portage/dev-python/cffi-2.1.0/work/cffi-2.1.0')]
kwargs     = {}
popenargs  = (['/tmp/portage/dev-python/cffi-2.1.0/temp/pytest-of-portage/pytest-0/test_meson_python_build_projec0/venv/bin/python',
  '-m',
  'pip',
  'install',
  'meson-python',
  PosixPath('/tmp/portage/dev-python/cffi-2.1.0/work/cffi-2.1.0')],)
retcode    = 1

/usr/lib/python3.15/subprocess.py:534: CalledProcessError
-------------------------------------------------------- Captured stdout call ---------------------------------------------------------
Requirement already satisfied: pip in /tmp/portage/dev-python/cffi-2.1.0/temp/pytest-of-portage/pytest-0/test_meson_python_build_projec0/venv/lib/python3.15/site-packages (26.1.2)
Processing ./.
  Installing build dependencies: started
  Installing build dependencies: finished with status 'error'
-------------------------------------------------------- Captured stderr call ---------------------------------------------------------
WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NameResolutionError("HTTPSConnection(host='pypi.org', port=443): Failed to resolve 'pypi.org' ([Errno -3] Temporary failure in name resolution)")': /simple/pip/
WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NameResolutionError("HTTPSConnection(host='pypi.org', port=443): Failed to resolve 'pypi.org' ([Errno -3] Temporary failure in name resolution)")': /simple/pip/
WARNING: Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NameResolutionError("HTTPSConnection(host='pypi.org', port=443): Failed to resolve 'pypi.org' ([Errno -3] Temporary failure in name resolution)")': /simple/pip/
WARNING: Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NameResolutionError("HTTPSConnection(host='pypi.org', port=443): Failed to resolve 'pypi.org' ([Errno -3] Temporary failure in name resolution)")': /simple/pip/
WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NameResolutionError("HTTPSConnection(host='pypi.org', port=443): Failed to resolve 'pypi.org' ([Errno -3] Temporary failure in name resolution)")': /simple/pip/
  error: subprocess-exited-with-error
  
  × installing build dependencies did not run successfully.
  │ exit code: 1
  ╰─> [7 lines of output]
      WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NameResolutionError("HTTPSConnection(host='pypi.org', port=443): Failed to resolve 'pypi.org' ([Errno -3] Temporary failure in name resolution)")': /simple/setuptools/
      WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NameResolutionError("HTTPSConnection(host='pypi.org', port=443): Failed to resolve 'pypi.org' ([Errno -3] Temporary failure in name resolution)")': /simple/setuptools/
      WARNING: Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NameResolutionError("HTTPSConnection(host='pypi.org', port=443): Failed to resolve 'pypi.org' ([Errno -3] Temporary failure in name resolution)")': /simple/setuptools/
      WARNING: Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NameResolutionError("HTTPSConnection(host='pypi.org', port=443): Failed to resolve 'pypi.org' ([Errno -3] Temporary failure in name resolution)")': /simple/setuptools/
      WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NameResolutionError("HTTPSConnection(host='pypi.org', port=443): Failed to resolve 'pypi.org' ([Errno -3] Temporary failure in name resolution)")': /simple/setuptools/
      ERROR: Could not find a version that satisfies the requirement setuptools>=77.0.3 (from versions: none)
      ERROR: No matching distribution found for setuptools>=77.0.3
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
ERROR: Failed to build 'file:///tmp/portage/dev-python/cffi-2.1.0/work/cffi-2.1.0' when installing build dependencies

CC @ngoldbaum

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions