update
This commit is contained in:
@@ -1,22 +1,24 @@
|
||||
from distutils import log
|
||||
import distutils.command.sdist as orig
|
||||
import os
|
||||
import sys
|
||||
import io
|
||||
from __future__ import annotations
|
||||
|
||||
import contextlib
|
||||
import os
|
||||
import re
|
||||
from itertools import chain
|
||||
|
||||
from .._importlib import metadata
|
||||
from ..dist import Distribution
|
||||
from .build import _ORIGINAL_SUBCOMMANDS
|
||||
|
||||
import distutils.command.sdist as orig
|
||||
from distutils import log
|
||||
|
||||
_default_revctrl = list
|
||||
|
||||
|
||||
def walk_revctrl(dirname=''):
|
||||
"""Find all files under revision control"""
|
||||
for ep in metadata.entry_points(group='setuptools.file_finders'):
|
||||
for item in ep.load()(dirname):
|
||||
yield item
|
||||
yield from ep.load()(dirname)
|
||||
|
||||
|
||||
class sdist(orig.sdist):
|
||||
@@ -32,7 +34,7 @@ class sdist(orig.sdist):
|
||||
(
|
||||
'dist-dir=',
|
||||
'd',
|
||||
"directory to put the source distribution archive(s) in " "[default: dist]",
|
||||
"directory to put the source distribution archive(s) in [default: dist]",
|
||||
),
|
||||
(
|
||||
'owner=',
|
||||
@@ -46,7 +48,8 @@ class sdist(orig.sdist):
|
||||
),
|
||||
]
|
||||
|
||||
negative_opt = {}
|
||||
distribution: Distribution # override distutils.dist.Distribution with setuptools.dist.Distribution
|
||||
negative_opt: dict[str, str] = {}
|
||||
|
||||
README_EXTENSIONS = ['', '.rst', '.txt', '.md']
|
||||
READMES = tuple('README{0}'.format(ext) for ext in README_EXTENSIONS)
|
||||
@@ -73,14 +76,6 @@ class sdist(orig.sdist):
|
||||
def initialize_options(self):
|
||||
orig.sdist.initialize_options(self)
|
||||
|
||||
self._default_to_gztar()
|
||||
|
||||
def _default_to_gztar(self):
|
||||
# only needed on Python prior to 3.6.
|
||||
if sys.version_info >= (3, 6, 0, 'beta', 1):
|
||||
return
|
||||
self.formats = ['gztar']
|
||||
|
||||
def make_distribution(self):
|
||||
"""
|
||||
Workaround for #516
|
||||
@@ -107,7 +102,7 @@ class sdist(orig.sdist):
|
||||
yield
|
||||
finally:
|
||||
if orig_val is not NoValue:
|
||||
setattr(os, 'link', orig_val)
|
||||
os.link = orig_val
|
||||
|
||||
def add_defaults(self):
|
||||
super().add_defaults()
|
||||
@@ -162,6 +157,12 @@ class sdist(orig.sdist):
|
||||
except TypeError:
|
||||
log.warn("data_files contains unexpected objects")
|
||||
|
||||
def prune_file_list(self):
|
||||
super().prune_file_list()
|
||||
# Prevent accidental inclusion of test-related cache dirs at the project root
|
||||
sep = re.escape(os.sep)
|
||||
self.filelist.exclude_pattern(r"^(\.tox|\.nox|\.venv)" + sep, is_regex=True)
|
||||
|
||||
def check_readme(self):
|
||||
for f in self.READMES:
|
||||
if os.path.exists(f):
|
||||
@@ -189,9 +190,9 @@ class sdist(orig.sdist):
|
||||
if not os.path.isfile(self.manifest):
|
||||
return False
|
||||
|
||||
with io.open(self.manifest, 'rb') as fp:
|
||||
with open(self.manifest, 'rb') as fp:
|
||||
first_line = fp.readline()
|
||||
return first_line != '# file GENERATED by distutils, do NOT edit\n'.encode()
|
||||
return first_line != b'# file GENERATED by distutils, do NOT edit\n'
|
||||
|
||||
def read_manifest(self):
|
||||
"""Read the manifest file (named by 'self.manifest') and use it to
|
||||
|
||||
Reference in New Issue
Block a user