diff options
| author | wim glenn <hey@wimglenn.com> | 2022-04-29 21:49:51 -0500 |
|---|---|---|
| committer | wim glenn <hey@wimglenn.com> | 2022-04-29 21:49:51 -0500 |
| commit | 2c34a366b169d6bd4079b2758badde700d6bd119 (patch) | |
| tree | df4dc49eff8f95cd84cef336844684c51bd267a9 | |
| parent | caae0974044837c6884fe91b9b5413a743fc1b69 (diff) | |
| download | python-setuptools-git-2c34a366b169d6bd4079b2758badde700d6bd119.tar.gz | |
address review comments
| -rw-r--r-- | .github/workflows/main.yml | 6 | ||||
| -rw-r--r-- | distutils/dist.py | 37 | ||||
| -rw-r--r-- | distutils/tests/test_install.py | 15 |
3 files changed, 21 insertions, 37 deletions
diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 51816629..12b049c6 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -11,9 +11,9 @@ jobs: strategy: matrix: python: - - "3.7" - - "3.8" - - "3.9" + - 3.7 + - 3.8 + - 3.9 - "3.10" platform: - ubuntu-latest diff --git a/distutils/dist.py b/distutils/dist.py index 90e6f12f..45024975 100644 --- a/distutils/dist.py +++ b/distutils/dist.py @@ -1064,7 +1064,7 @@ class DistributionMetadata: def _read_field(name): value = msg[name] - if value: + if value and value != "UNKNOWN": return value def _read_list(name): @@ -1129,30 +1129,19 @@ class DistributionMetadata: file.write('Name: %s\n' % self.get_name()) file.write('Version: %s\n' % self.get_version()) + def maybe_write(header, val): + if val: + file.write("{}: {}\n".format(header, val)) + # optional fields - summary = self.get_description() - if summary: - file.write('Summary: %s\n' % summary) - home_page = self.get_url() - if home_page: - file.write('Home-page: %s\n' % home_page) - author = self.get_contact() - if author: - file.write('Author: %s\n' % author) - author_email = self.get_contact_email() - if author_email: - file.write('Author-email: %s\n' % author_email) - license = self.get_license() - if license: - file.write('License: %s\n' % license) - if self.download_url: - file.write('Download-URL: %s\n' % self.download_url) - long_desc = self.get_long_description() - if long_desc: - file.write('Description: %s\n' % rfc822_escape(long_desc)) - keywords = ','.join(self.get_keywords()) - if keywords: - file.write('Keywords: %s\n' % keywords) + maybe_write("Summary", self.get_description()) + maybe_write("Home-page", self.get_url()) + maybe_write("Author", self.get_contact()) + maybe_write("Author-email", self.get_contact_email()) + maybe_write("License", self.get_license()) + maybe_write("Download-URL", self.download_url) + maybe_write("Description", rfc822_escape(self.get_long_description() or "")) + maybe_write("Keywords", ",".join(self.get_keywords())) self._write_list(file, 'Platform', self.get_platforms()) self._write_list(file, 'Classifier', self.get_classifiers()) diff --git a/distutils/tests/test_install.py b/distutils/tests/test_install.py index e01d9793..3aef9e43 100644 --- a/distutils/tests/test_install.py +++ b/distutils/tests/test_install.py @@ -187,9 +187,7 @@ class InstallTestCase(support.TempdirManager, def test_record(self): install_dir = self.mkdtemp() - project_dir, dist = self.create_dist(name="testdist", - version="0.1", - py_modules=['hello'], + project_dir, dist = self.create_dist(py_modules=['hello'], scripts=['sayhi']) os.chdir(project_dir) self.write_file('hello.py', "def main(): print('o hai')") @@ -211,7 +209,7 @@ class InstallTestCase(support.TempdirManager, found = [os.path.basename(line) for line in content.splitlines()] expected = ['hello.py', 'hello.%s.pyc' % sys.implementation.cache_tag, 'sayhi', - 'testdist-0.1-py%s.%s.egg-info' % sys.version_info[:2]] + 'UNKNOWN-0.0.0-py%s.%s.egg-info' % sys.version_info[:2]] self.assertEqual(found, expected) def test_record_extensions(self): @@ -219,11 +217,8 @@ class InstallTestCase(support.TempdirManager, if cmd is not None: self.skipTest('The %r command is not found' % cmd) install_dir = self.mkdtemp() - project_dir, dist = self.create_dist( - name="testdist", - version="0.1", - ext_modules=[Extension('xx', ['xxmodule.c'])], - ) + project_dir, dist = self.create_dist(ext_modules=[ + Extension('xx', ['xxmodule.c'])]) os.chdir(project_dir) support.copy_xxmodule_c(project_dir) @@ -247,7 +242,7 @@ class InstallTestCase(support.TempdirManager, found = [os.path.basename(line) for line in content.splitlines()] expected = [_make_ext_name('xx'), - 'testdist-0.1-py%s.%s.egg-info' % sys.version_info[:2]] + 'UNKNOWN-0.0.0-py%s.%s.egg-info' % sys.version_info[:2]] self.assertEqual(found, expected) def test_debug_mode(self): |
