Skip to content

Commit

Permalink
Vendorization 2022-07-30
Browse files Browse the repository at this point in the history
Disable building MacOSX 3.7 on Homebrew
  • Loading branch information
arcivanov committed Jul 30, 2022
1 parent f4c50a2 commit 66fb125
Show file tree
Hide file tree
Showing 144 changed files with 2,320 additions and 2,931 deletions.
12 changes: 8 additions & 4 deletions .github/workflows/pybuilder.yml
Expand Up @@ -14,7 +14,7 @@ jobs:
os:
- ubuntu-latest
python-version:
- '3.11.0-beta.3'
- '3.11.0-beta.5'
- '3.10'
- '3.9'
- '3.8'
Expand Down Expand Up @@ -45,9 +45,9 @@ jobs:
matrix:
os:
- windows-latest
- macos-11
- macos-latest
python-version:
- '3.11.0-beta.3'
- '3.11.0-beta.5'
- '3.10'
- '3.9'
- '3.8'
Expand All @@ -58,6 +58,10 @@ jobs:
with-homebrew:
- 'true'
- 'false'
exclude:
- os: macos-latest
python-version: '3.7'
with-homebrew: 'true'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
Expand All @@ -80,7 +84,7 @@ jobs:
os:
- ubuntu-latest
- windows-latest
- macos-11
- macos-latest
python-version:
- 'pypy-3.7'
- 'pypy-3.8'
Expand Down
626 changes: 491 additions & 135 deletions src/main/python/pybuilder/_vendor/LICENSES

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/main/python/pybuilder/_vendor/__init__.py
@@ -1 +1 @@
__names__ = ['_distutils_hack', 'colorama', 'distlib', 'filelock', 'importlib_metadata', 'importlib_resources', 'pkg_resources', 'platformdirs', 'six', 'tailer', 'tblib', 'typing_extensions', 'virtualenv', 'zipp']
__names__ = ['_distutils_hack', 'colorama', 'distlib', 'filelock', 'importlib_metadata', 'importlib_resources', 'pkg_resources', 'platformdirs', 'tailer', 'tblib', 'typing_extensions', 'virtualenv', 'zipp']
47 changes: 41 additions & 6 deletions src/main/python/pybuilder/_vendor/_distutils_hack/__init__.py
Expand Up @@ -14,22 +14,26 @@ def warn_distutils_present():
# https://foss.heptapod.net/pypy/pypy/-/blob/be829135bc0d758997b3566062999ee8b23872b4/lib-python/3/site.py#L250
return
import warnings

warnings.warn(
"Distutils was imported before Setuptools, but importing Setuptools "
"also replaces the `distutils` module in `sys.modules`. This may lead "
"to undesirable behaviors or errors. To avoid these issues, avoid "
"using distutils directly, ensure that setuptools is installed in the "
"traditional way (e.g. not an editable install), and/or make sure "
"that setuptools is always imported before distutils.")
"that setuptools is always imported before distutils."
)


def clear_distutils():
if 'distutils' not in sys.modules:
return
import warnings

warnings.warn("Setuptools is replacing distutils.")
mods = [
name for name in sys.modules
name
for name in sys.modules
if name == "distutils" or name.startswith("distutils.")
]
for name in mods:
Expand All @@ -46,6 +50,7 @@ def enabled():

def ensure_local_distutils():
import importlib

clear_distutils()

# With the DistutilsMetaFinder in place,
Expand Down Expand Up @@ -82,7 +87,9 @@ def match(self, string):

class DistutilsMetaFinder:
def find_spec(self, fullname, path, target=None):
if path is not None:
# optimization: only consider top level modules and those
# found in the CPython test suite.
if path is not None and not fullname.startswith('test.'):
return

method_name = 'spec_for_{fullname}'.format(**locals())
Expand Down Expand Up @@ -111,7 +118,6 @@ def spec_for_distutils(self):
return

class DistutilsLoader(importlib.abc.Loader):

def create_module(self, spec):
mod.__name__ = 'distutils'
return mod
Expand Down Expand Up @@ -147,9 +153,9 @@ def pip_imported_during_build(cls):
Detect if pip is being imported in a build script. Ref #2355.
"""
import traceback

return any(
cls.frame_file_is_setup(frame)
for frame, line in traceback.walk_stack(None)
cls.frame_file_is_setup(frame) for frame, line in traceback.walk_stack(None)
)

@staticmethod
Expand All @@ -160,6 +166,35 @@ def frame_file_is_setup(frame):
# some frames may not have __file__ (#2940)
return frame.f_globals.get('__file__', '').endswith('setup.py')

def spec_for_sensitive_tests(self):
"""
Ensure stdlib distutils when running select tests under CPython.
python/cpython#91169
"""
clear_distutils()
self.spec_for_distutils = lambda: None

sensitive_tests = (
[
'test.test_distutils',
'test.test_peg_generator',
'test.test_importlib',
]
if sys.version_info < (3, 10)
else [
'test.test_distutils',
]
)


for name in DistutilsMetaFinder.sensitive_tests:
setattr(
DistutilsMetaFinder,
f'spec_for_{name}',
DistutilsMetaFinder.spec_for_sensitive_tests,
)


DISTUTILS_FINDER = DistutilsMetaFinder()

Expand Down
2 changes: 1 addition & 1 deletion src/main/python/pybuilder/_vendor/colorama/__init__.py
Expand Up @@ -3,4 +3,4 @@
from .ansi import Fore, Back, Style, Cursor
from .ansitowin32 import AnsiToWin32

__version__ = '0.4.4'
__version__ = '0.4.5'
10 changes: 9 additions & 1 deletion src/main/python/pybuilder/_vendor/colorama/ansitowin32.py
Expand Up @@ -37,6 +37,12 @@ def __enter__(self, *args, **kwargs):
def __exit__(self, *args, **kwargs):
return self.__wrapped.__exit__(*args, **kwargs)

def __setstate__(self, state):
self.__dict__ = state

def __getstate__(self):
return self.__dict__

def write(self, text):
self.__convertor.write(text)

Expand All @@ -57,7 +63,9 @@ def closed(self):
stream = self.__wrapped
try:
return stream.closed
except AttributeError:
# AttributeError in the case that the stream doesn't support being closed
# ValueError for the case that the stream has already been detached when atexit runs
except (AttributeError, ValueError):
return True


Expand Down
2 changes: 1 addition & 1 deletion src/main/python/pybuilder/_vendor/distlib/__init__.py
Expand Up @@ -6,7 +6,7 @@
#
import logging

__version__ = '0.3.4'
__version__ = '0.3.5'

class DistlibException(Exception):
pass
Expand Down
17 changes: 11 additions & 6 deletions src/main/python/pybuilder/_vendor/distlib/database.py
Expand Up @@ -385,8 +385,9 @@ def provides(self):

def _get_requirements(self, req_attr):
md = self.metadata
logger.debug('Getting requirements from metadata %r', md.todict())
reqts = getattr(md, req_attr)
logger.debug('%s: got requirements %r from metadata: %r', self.name, req_attr,
reqts)
return set(md.get_requirements(reqts, extras=self.extras,
env=self.context))

Expand Down Expand Up @@ -1314,22 +1315,26 @@ def get_required_dists(dists, dist):
:param dists: a list of distributions
:param dist: a distribution, member of *dists* for which we are interested
in finding the dependencies.
"""
if dist not in dists:
raise DistlibException('given distribution %r is not a member '
'of the list' % dist.name)
graph = make_graph(dists)

req = [] # required distributions
req = set() # required distributions
todo = graph.adjacency_list[dist] # list of nodes we should inspect
seen = set(t[0] for t in todo) # already added to todo

while todo:
d = todo.pop()[0]
req.append(d)
for pred in graph.adjacency_list[d]:
if pred not in req:
req.add(d)
pred_list = graph.adjacency_list[d]
for pred in pred_list:
d = pred[0]
if d not in req and d not in seen:
seen.add(d)
todo.append(pred)

return req


Expand Down
13 changes: 6 additions & 7 deletions src/main/python/pybuilder/_vendor/distlib/index.py
Expand Up @@ -12,7 +12,7 @@
import tempfile
try:
from threading import Thread
except ImportError:
except ImportError: # pragma: no cover
from dummy_threading import Thread

from . import DistlibException
Expand Down Expand Up @@ -104,7 +104,7 @@ def check_credentials(self):
pm.add_password(self.realm, netloc, self.username, self.password)
self.password_handler = HTTPBasicAuthHandler(pm)

def register(self, metadata):
def register(self, metadata): # pragma: no cover
"""
Register a distribution on PyPI, using the provided metadata.
Expand Down Expand Up @@ -142,8 +142,7 @@ def _reader(self, name, stream, outbuf):
logger.debug('%s: %s' % (name, s))
stream.close()

def get_sign_command(self, filename, signer, sign_password,
keystore=None):
def get_sign_command(self, filename, signer, sign_password, keystore=None): # pragma: no cover
"""
Return a suitable command for signing a file.
Expand Down Expand Up @@ -206,7 +205,7 @@ def run_command(self, cmd, input_data=None):
t2.join()
return p.returncode, stdout, stderr

def sign_file(self, filename, signer, sign_password, keystore=None):
def sign_file(self, filename, signer, sign_password, keystore=None): # pragma: no cover
"""
Sign a file.
Expand Down Expand Up @@ -286,7 +285,7 @@ def upload_file(self, metadata, filename, signer=None, sign_password=None,
request = self.encode_request(d.items(), files)
return self.send_request(request)

def upload_documentation(self, metadata, doc_dir):
def upload_documentation(self, metadata, doc_dir): # pragma: no cover
"""
Upload documentation to the index.
Expand Down Expand Up @@ -499,7 +498,7 @@ def encode_request(self, fields, files):
}
return Request(self.url, body, headers)

def search(self, terms, operator=None):
def search(self, terms, operator=None): # pragma: no cover
if isinstance(terms, string_types):
terms = {'name': terms}
rpc_proxy = ServerProxy(self.url, timeout=3.0)
Expand Down
4 changes: 2 additions & 2 deletions src/main/python/pybuilder/_vendor/distlib/locators.py
Expand Up @@ -1053,9 +1053,9 @@ def get_distribution_names(self):


# We use a legacy scheme simply because most of the dists on PyPI use legacy
# versions which don't conform to PEP 426 / PEP 440.
# versions which don't conform to PEP 440.
default_locator = AggregatingLocator(
JSONLocator(),
# JSONLocator(), # don't use as PEP 426 is withdrawn
SimpleScrapingLocator('https://pypi.org/simple/',
timeout=3.0),
scheme='legacy')
Expand Down

0 comments on commit 66fb125

Please sign in to comment.