Skip to content

80.9.0 [testing] FileNotFoundError: [Errno 2] No such file or directory: 'foo.egg-info/SOURCES.txt' #5094

@mtelka

Description

@mtelka

The test_setup_cfg_license_file_license_files test is failing with:

_ TestEggInfo.test_setup_cfg_license_file_license_files[combined_glob_patterrns] _
[gw2] sunos5 -- Python 3.9.24 /tmp/test/setuptools-80.9.0/.tox/py39/bin/python

self = <setuptools.tests.test_egg_info.TestEggInfo object at 0x7fffab3e5d90>
tmpdir_cwd = local('/tmp/test/setuptools-80.9.0')
env = '/tmp/setuptools-test.go01gmik'
files = {'AUTHORS-ABC': 'ABC authors', 'LICENSE-ABC': 'ABC license', 'NOTICE-ABC': 'ABC notice', 'setup.cfg': '[metadata]\nlicense_file = LICENSE*\nlicense_
files =\n  NOTICE*\n'}
incl_licenses = ['LICENSE-ABC', 'NOTICE-ABC'], excl_licenses = ['AUTHORS-ABC']

    @pytest.mark.parametrize(
        ('files', 'incl_licenses', 'excl_licenses'),
        [
            (
                {
                    'setup.cfg': DALS(
                        """
                              [metadata]
                              license_file =
                              license_files =
                              """
                    ),
                    'LICENSE-ABC': "ABC license",
                    'LICENSE-XYZ': "XYZ license",
                },
                [],
                ['LICENSE-ABC', 'LICENSE-XYZ'],
            ),  # both empty
            (
                {
                    'setup.cfg': DALS(
                        """
                              [metadata]
                              license_file =
                                  LICENSE-ABC
                                  LICENSE-XYZ
                              """
                    ),
                    'LICENSE-ABC': "ABC license",
                    'LICENSE-XYZ': "XYZ license",
                    # license_file is still singular
                },
                [],
                ['LICENSE-ABC', 'LICENSE-XYZ'],
            ),
            (
                {
                    'setup.cfg': DALS(
                        """
                              [metadata]
                              license_file = LICENSE-ABC
                              license_files =
                                  LICENSE-XYZ
                                  LICENSE-PQR
                              """
                    ),
                    'LICENSE-ABC': "ABC license",
                    'LICENSE-PQR': "PQR license",
                    'LICENSE-XYZ': "XYZ license",
                },
                ['LICENSE-ABC', 'LICENSE-PQR', 'LICENSE-XYZ'],
                [],
            ),  # combined
            (
                {
                    'setup.cfg': DALS(
                        """
                              [metadata]
                              license_file = LICENSE-ABC
                              license_files =
                                  LICENSE-ABC
                                  LICENSE-XYZ
                                  LICENSE-PQR
                              """
                    ),
                    'LICENSE-ABC': "ABC license",
                    'LICENSE-PQR': "PQR license",
                    'LICENSE-XYZ': "XYZ license",
                    # duplicate license
                },
                ['LICENSE-ABC', 'LICENSE-PQR', 'LICENSE-XYZ'],
                [],
            ),
            (
                {
                    'setup.cfg': DALS(
                        """
                              [metadata]
                              license_file = LICENSE-ABC
                              license_files =
                                  LICENSE-XYZ
                              """
                    ),
                    'LICENSE-ABC': "ABC license",
                    'LICENSE-PQR': "PQR license",
                    'LICENSE-XYZ': "XYZ license",
                    # combined subset
                },
                ['LICENSE-ABC', 'LICENSE-XYZ'],
                ['LICENSE-PQR'],
            ),
            (
                {
                    'setup.cfg': DALS(
                        """
                              [metadata]
                              license_file = LICENSE-ABC
                              license_files =
                                  LICENSE-XYZ
                                  LICENSE-PQR
                              """
                    ),
                    'LICENSE-PQR': "Test license",
                    # with invalid licenses
                },
                ['LICENSE-PQR'],
                ['LICENSE-ABC', 'LICENSE-XYZ'],
            ),
            (
                {
                    'setup.cfg': DALS(
                        """
                              [metadata]
                              license_file = LICENSE-ABC
                              license_files =
                                LICENSE-PQR
                                LICENSE-XYZ
                              """
                    ),
                    'MANIFEST.in': "exclude LICENSE-ABC\nexclude LICENSE-PQR",
                    'LICENSE-ABC': "ABC license",
                    'LICENSE-PQR': "PQR license",
                    'LICENSE-XYZ': "XYZ license",
                    # manifest is overwritten
                },
                ['LICENSE-ABC', 'LICENSE-PQR', 'LICENSE-XYZ'],
                [],
            ),
            pytest.param(
                {
                    'setup.cfg': DALS(
                        """
                              [metadata]
                              license_file = LICENSE*
                              """
                    ),
                    'LICENSE-ABC': "ABC license",
                    'NOTICE-XYZ': "XYZ notice",
                },
                ['LICENSE-ABC'],
                ['NOTICE-XYZ'],
                id="no_default_glob_patterns",
            ),
            pytest.param(
                {
                    'setup.cfg': DALS(
                        """
                              [metadata]
                              license_file = LICENSE*
                              license_files =
                                NOTICE*
                              """
                    ),
                    'LICENSE-ABC': "ABC license",
                    'NOTICE-ABC': "ABC notice",
                    'AUTHORS-ABC': "ABC authors",
                },
                ['LICENSE-ABC', 'NOTICE-ABC'],
                ['AUTHORS-ABC'],
                id="combined_glob_patterrns",
            ),
        ],
    )
    def test_setup_cfg_license_file_license_files(
        self, tmpdir_cwd, env, files, incl_licenses, excl_licenses
    ):
        self._create_project()
        path.build(files)
    
        environment.run_setup_py(
            cmd=['egg_info'],
            pypath=os.pathsep.join([env.paths['lib'], str(tmpdir_cwd)]),
        )
        egg_info_dir = os.path.join('.', 'foo.egg-info')
    
>       sources_text = Path(egg_info_dir, "SOURCES.txt").read_text(encoding="utf-8")

/tmp/test/setuptools-80.9.0/setuptools/tests/test_egg_info.py:1032: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
/usr/lib/python3.9/pathlib.py:1194: in read_text
    with self.open(mode='r', encoding=encoding, errors=errors) as f:
/usr/lib/python3.9/pathlib.py:1180: in open
    return io.open(self, mode, buffering, encoding, errors, newline,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = PosixPath('foo.egg-info/SOURCES.txt'), name = 'foo.egg-info/SOURCES.txt'
flags = 8388608, mode = 438

    def _opener(self, name, flags, mode=0o666):
        # A stub for the opener argument to built-in open()
>       return self._accessor.open(self, flags, mode)
E       FileNotFoundError: [Errno 2] No such file or directory: 'foo.egg-info/SOURCES.txt'

/usr/lib/python3.9/pathlib.py:1038: FileNotFoundError

Steps to reproduce:

$ wget https://files.pythonhosted.org/packages/source/s/setuptools/setuptools-80.9.0.tar.gz
$ gtar xf setuptools-80.9.0.tar.gz
$ cd setuptools-80.9.0
$ sed -i -e '/check$/d' -e '/type$/d' -e '/^.cover$/d' tox.ini
$ tox -e py39

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions