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

Always use latest metadata version for PKG-INFO #2641

Merged
merged 1 commit into from May 9, 2021
Merged

Conversation

cdce8p
Copy link
Contributor

@cdce8p cdce8p commented Apr 16, 2021

Summary of changes

setuptools should always try to use the latest supported metadata version when writing the PKG-INFO file.

Pull Request Checklist

@jaraco jaraco merged commit fb37758 into pypa:main May 9, 2021
@jaraco
Copy link
Member

jaraco commented May 9, 2021

Looks like by merging this after some of the other recent merges, the tests now fail.

________________________________________________________________ TestEggInfo.test_license_escape ________________________________________________________________
[gw1] darwin -- Python 3.9.2 /Users/jaraco/code/public/pypa/setuptools/.tox/python/bin/python

self = <setuptools.tests.test_egg_info.TestEggInfo object at 0x7fba8cf10cd0>, tmpdir_cwd = local('/Users/jaraco/code/public/pypa/setuptools')
env = '/var/folders/c6/v7hnmq453xb6p2dbz1gqc6rr0000gn/T/setuptools-test.q73dhcvo'

    def test_license_escape(self, tmpdir_cwd, env):
        """Test license is escaped correctly if longer than one line."""
        self._setup_script_with_requires(
            "license='This is a long license text \\nover multiple lines',"
        )
        code, data = environment.run_setup_py(
            cmd=['egg_info'],
            pypath=os.pathsep.join([env.paths['lib'], str(tmpdir_cwd)]),
            data_stream=1,
        )
        egg_info_dir = os.path.join('.', 'foo.egg-info')
        with open(os.path.join(egg_info_dir, 'PKG-INFO')) as pkginfo_file:
            pkg_info_lines = pkginfo_file.read().split('\n')
>       assert 'License: This is a long license text ' == pkg_info_lines[7]
E       AssertionError: assert 'License: Thi...license text ' == 'Description: UNKNOWN'
E         - Description: UNKNOWN
E         + License: This is a long license text

/Users/jaraco/code/public/pypa/setuptools/setuptools/tests/test_egg_info.py:937: AssertionError
___________________________________________________________________ TestEggInfo.test_license ____________________________________________________________________
[gw0] darwin -- Python 3.9.2 /Users/jaraco/code/public/pypa/setuptools/.tox/python/bin/python

self = <setuptools.tests.test_egg_info.TestEggInfo object at 0x7ffd477167c0>, tmpdir_cwd = local('/Users/jaraco/code/public/pypa/setuptools')
env = '/var/folders/c6/v7hnmq453xb6p2dbz1gqc6rr0000gn/T/setuptools-test.x_ms62t7'

    def test_license(self, tmpdir_cwd, env):
        """Test single line license."""
        self._setup_script_with_requires(
            "license='MIT',"
        )
        code, data = environment.run_setup_py(
            cmd=['egg_info'],
            pypath=os.pathsep.join([env.paths['lib'], str(tmpdir_cwd)]),
            data_stream=1,
        )
        egg_info_dir = os.path.join('.', 'foo.egg-info')
        with open(os.path.join(egg_info_dir, 'PKG-INFO')) as pkginfo_file:
            pkg_info_lines = pkginfo_file.read().split('\n')
>       assert 'License: MIT' == pkg_info_lines[7]
E       AssertionError: assert 'License: MIT' == 'Platform: UNKNOWN'
E         - Platform: UNKNOWN
E         + License: MIT

/Users/jaraco/code/public/pypa/setuptools/setuptools/tests/test_egg_info.py:922: AssertionError

@jaraco
Copy link
Member

jaraco commented May 9, 2021

I hadn't noticed it before, but pkg_info_lines[7] (or any use of a specific index) is a red flag for brittle behavior.

@cdce8p cdce8p deleted the mv-version branch May 9, 2021 17:47
@cdce8p
Copy link
Contributor Author

cdce8p commented May 9, 2021

I hadn't noticed it before, but pkg_info_lines[7] (or any use of a specific index) is a red flag for brittle behavior.

Makes sense, will remember that. I originally switched to it after I got the feedback to do so: #2628 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants