Skip to content

Commit 9a6ee31

Browse files
committed
Add vendored dependencies
1 parent 6c23933 commit 9a6ee31

20 files changed

+5956
-0
lines changed

action.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ runs:
3737

3838
- shell: bash
3939
run: |
40+
export PYTHONPATH=${{ github.action_path }}:${{ github.action_path }}/vendor
4041
"${{ github.action_path }}/codeql-summarize" \
4142
--input "${{ inputs.projects }}" \
4243
--output "${{ inputs.output }}" \

vendor/_yaml/__init__.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# This is a stub package designed to roughly emulate the _yaml
2+
# extension module, which previously existed as a standalone module
3+
# and has been moved into the `yaml` package namespace.
4+
# It does not perfectly mimic its old counterpart, but should get
5+
# close enough for anyone who's relying on it even when they shouldn't.
6+
import yaml
7+
8+
# in some circumstances, the yaml module we imoprted may be from a different version, so we need
9+
# to tread carefully when poking at it here (it may not have the attributes we expect)
10+
if not getattr(yaml, '__with_libyaml__', False):
11+
from sys import version_info
12+
13+
exc = ModuleNotFoundError if version_info >= (3, 6) else ImportError
14+
raise exc("No module named '_yaml'")
15+
else:
16+
from yaml._yaml import *
17+
import warnings
18+
warnings.warn(
19+
'The _yaml extension module is now located at yaml._yaml'
20+
' and its location is subject to change. To use the'
21+
' LibYAML-based parser and emitter, import from `yaml`:'
22+
' `from yaml import CLoader as Loader, CDumper as Dumper`.',
23+
DeprecationWarning
24+
)
25+
del warnings
26+
# Don't `del yaml` here because yaml is actually an existing
27+
# namespace member of _yaml.
28+
29+
__name__ = '_yaml'
30+
# If the module is top-level (i.e. not a part of any specific package)
31+
# then the attribute should be set to ''.
32+
# https://docs.python.org/3.8/library/types.html
33+
__package__ = ''

vendor/update.sh

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/bin/bash
2+
set -e
3+
4+
export VENDOR="$(pwd)/vendor"
5+
echo "[+] Vendor path: $VENDOR"
6+
7+
echo "[+] Delete all folders in vendor"
8+
rm -rf "$VENDOR/*/"
9+
10+
if [ -f $PWD/Pipfile ]; then
11+
echo "[+] Install all dependencies (pipenv)"
12+
pipenv run pip freeze > "$VENDOR/requirements.txt"
13+
pip install -r "$VENDOR/requirements.txt" --target=$VENDOR
14+
15+
echo "[+] Clean up vendor folder"
16+
rm -rf $VENDOR/*dist-info && \
17+
rm -rf $VENDOR/requirements.txt
18+
19+
elif [ -f $PWD/requirements.txt ]; then
20+
echo "[+] Install all dependencies (pip -> requirements)"
21+
pip install -r $PWD/requirements.txt --target=$VENDOR
22+
23+
echo "[+] Clean up vendor folder"
24+
rm -rf $VENDOR/*dist-info && \
25+
rm -rf $VENDOR/requirements.txt
26+
27+
else
28+
echo "[!] Unsupported Python installer, please update the 'vendor/update.sh' script"
29+
exit 1
30+
fi
31+
32+
echo "[+] Completed vendor update"

0 commit comments

Comments
 (0)