Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
refactor: switch to vendoring
Use the vendoring package to install and patch v1.15.0 of wrapt.
  • Loading branch information
apotterri committed May 25, 2023
commit 646d1bc713a0238ea8bc84776fea23ddca947b17
3 changes: 0 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +0,0 @@
[submodule "extern/wrapt"]
path = vendor/wrapt
url = https://github.com/applandinc/wrapt.git
15 changes: 12 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
- [Getting the code](#getting-the-code)
- [Python version support](#python-version-support)
- [Dependency management](#dependency-management)
- [wrapt](#wrapt)
- [Linting](#linting)
- [Testing](#testing)
- [pytest](#pytest)
Expand Down Expand Up @@ -71,6 +72,14 @@ oldest version currently supported (see the
% poetry install
```

### wrapt
The one dependency that is not managed using `poetry` is `wrapt`. Because it's possible that
projects that use `appmap` may also need an unmodified version of `wrapt` (e.g. `pylint` depends on
`astroid`, which in turn depends on `wrapt`), we use
[vendoring](https://github.com/pradyunsg/vendoring) to vendor `wrapt`.

To update `wrapt`, use `tox` (described below) to run the `vendoring` environment.

## Linting
[pylint](https://www.pylint.org/) for linting:

Expand All @@ -83,9 +92,9 @@ Your code has been rated at 10.00/10 (previous run: 10.00/10, +0.00)

```

[Note that the current configuration requires a 10.0 for the Travis build to pass. To make
this easier to achieve, convention and refactoring checks have both been disabled. They
should be reenabled as soon as possible.]
[Note that the current configuration has a threshold set which must be met for the Travis build to
pass. To make this easier to achieve, a number of checks have both been disabled. They should be
reenabled as soon as possible.]


## Testing
Expand Down
2 changes: 1 addition & 1 deletion _appmap/wrapt
16 changes: 14 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ classifiers = [
'Topic :: Software Development :: Documentation'
]
include = ['appmap.pth']
exclude = ['_appmap/wrapt']

packages = [
{ include = "appmap"}, {include = "_appmap" },
{ include = "wrapt/*.py", from="vendor/wrapt/src" }
{ include = "appmap"}, {include = "_appmap" }, {include = "_appmap/wrapt", from = "vendor"}
]

[tool.poetry.dependencies]
Expand Down Expand Up @@ -98,3 +98,15 @@ extend_skip = [
"_appmap/wrapt"
]

[tool.vendoring]
destination = "vendor/_appmap/"
requirements = "vendor/vendor.txt"
namespace = ""

protected-files = ["vendor.txt"]
patches-dir = "vendor/patches"

[tool.vendoring.transformations]
drop = [
"**/*.so",
]
8 changes: 8 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,11 @@ commands =
web: poetry run {posargs:pytest -vv}
flask1: poetry run pytest _appmap/test/test_flask.py
django3: poetry run pytest _appmap/test/test_django.py

[testenv:vendoring]
skip_install = True
deps = vendoring
commands =
poetry run vendoring {posargs:sync}
# We don't need the .pyi files vendoring generates
python -c 'from pathlib import Path; all(map(Path.unlink, Path("vendor").rglob("*.pyi")))'
24 changes: 24 additions & 0 deletions vendor/_appmap/wrapt/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
Copyright (c) 2013-2023, Graham Dumpleton
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.

* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
27 changes: 27 additions & 0 deletions vendor/_appmap/wrapt/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
__version_info__ = ('1', '15', '0')
__version__ = '.'.join(__version_info__)

from .wrappers import (ObjectProxy, CallableObjectProxy, FunctionWrapper,
BoundFunctionWrapper, WeakFunctionProxy, PartialCallableObjectProxy,
resolve_path, apply_patch, wrap_object, wrap_object_attribute,
function_wrapper, wrap_function_wrapper, patch_function_wrapper,
transient_function_wrapper)

from .decorators import (adapter_factory, AdapterFactory, decorator,
synchronized)

from .importer import (register_post_import_hook, when_imported,
notify_module_loaded, discover_post_import_hooks)

# Import of inspect.getcallargs() included for backward compatibility. An
# implementation of this was previously bundled and made available here for
# Python <2.7. Avoid using this in future.

from inspect import getcallargs

# Variant of inspect.formatargspec() included here for forward compatibility.
# This is being done because Python 3.11 dropped inspect.formatargspec() but
# code for handling signature changing decorators relied on it. Exposing the
# bundled implementation here in case any user of wrapt was also needing it.

from .arguments import formatargspec
38 changes: 38 additions & 0 deletions vendor/_appmap/wrapt/arguments.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# The inspect.formatargspec() function was dropped in Python 3.11 but we need
# need it for when constructing signature changing decorators based on result of
# inspect.getargspec() or inspect.getfullargspec(). The code here implements
# inspect.formatargspec() base on Parameter and Signature from inspect module,
# which were added in Python 3.6. Thanks to Cyril Jouve for the implementation.

try:
from inspect import Parameter, Signature
except ImportError:
from inspect import formatargspec
else:
def formatargspec(args, varargs=None, varkw=None, defaults=None,
kwonlyargs=(), kwonlydefaults={}, annotations={}):
if kwonlydefaults is None:
kwonlydefaults = {}
ndefaults = len(defaults) if defaults else 0
parameters = [
Parameter(
arg,
Parameter.POSITIONAL_OR_KEYWORD,
default=defaults[i] if i >= 0 else Parameter.empty,
annotation=annotations.get(arg, Parameter.empty),
) for i, arg in enumerate(args, ndefaults - len(args))
]
if varargs:
parameters.append(Parameter(varargs, Parameter.VAR_POSITIONAL))
parameters.extend(
Parameter(
kwonlyarg,
Parameter.KEYWORD_ONLY,
default=kwonlydefaults.get(kwonlyarg, Parameter.empty),
annotation=annotations.get(kwonlyarg, Parameter.empty),
) for kwonlyarg in kwonlyargs
)
if varkw:
parameters.append(Parameter(varkw, Parameter.VAR_KEYWORD))
return_annotation = annotations.get('return', Signature.empty)
return str(Signature(parameters, return_annotation=return_annotation))
Loading