-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #177 from rtibbles/pycrypto_upgrade
Update supported Python versions and cryptography version
- Loading branch information
Showing
17 changed files
with
219 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,7 +15,7 @@ on: | |
jobs: | ||
deploy: | ||
|
||
runs-on: ubuntu-18.04 | ||
runs-on: ubuntu-20.04 | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
M2Crypto==0.37.1 | ||
cryptography==2.3.1 | ||
cryptography==3.3.2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
psycopg2==2.7.4 | ||
cryptography==2.3 | ||
psycopg2-binary==2.8.6 | ||
cryptography==3.3.2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
""" | ||
This script backports this Python 3.10 compatibility fix https://github.com/pytest-dev/pytest/pull/8540 | ||
in order to allow pytest to run in Python 3.10 without upgrading to version 6.2.5 which does not support 2.7 | ||
Copied from: | ||
https://github.com/learningequality/kolibri/blob/8f9e78572d140a8e70e4d790903fe5acaf4f1a9a/test/patch_pytest.py | ||
""" | ||
import os | ||
import subprocess | ||
import sys | ||
|
||
import pytest | ||
|
||
|
||
def patch(): | ||
site_packages_dir = os.path.dirname(pytest.__file__) | ||
|
||
patch_file = os.path.join(os.path.dirname(__file__), "pytest_3.10.patch") | ||
|
||
print("Applying patch: " + str(patch_file)) | ||
|
||
# -N: insist this is FORWARD patch, don't reverse apply | ||
# -p1: strip first path component | ||
# -t: batch mode, don't ask questions | ||
patch_command = [ | ||
"patch", | ||
"-N", | ||
"-p1", | ||
"-d", | ||
site_packages_dir, | ||
"-t", | ||
"-i", | ||
patch_file, | ||
] | ||
print(" ".join(patch_command)) | ||
try: | ||
# Use a dry run to establish whether the patch is already applied. | ||
# If we don't check this, the patch may be partially applied (which is bad!) | ||
subprocess.check_output(patch_command + ["--dry-run"]) | ||
except subprocess.CalledProcessError as e: | ||
if e.returncode == 1: | ||
# Return code 1 means not all hunks could be applied, this usually | ||
# means the patch is already applied. | ||
print( | ||
"Warning: failed to apply patch (exit code 1), " | ||
"assuming it is already applied: ", | ||
str(patch_file), | ||
) | ||
else: | ||
raise e | ||
else: | ||
# The dry run worked, so do the real thing | ||
subprocess.check_output(patch_command) | ||
|
||
|
||
if __name__ == "__main__": | ||
if sys.version_info >= (3, 10): | ||
patch() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
diff --git a/_pytest/assertion/rewrite.py b/_pytest/assertion/rewrite.py | ||
index 4f96b9e8c..1aa5b12de 100644 | ||
--- a/_pytest/assertion/rewrite.py | ||
+++ b/_pytest/assertion/rewrite.py | ||
@@ -587,10 +587,6 @@ class AssertionRewriter(ast.NodeVisitor): | ||
return | ||
# Insert some special imports at the top of the module but after any | ||
# docstrings and __future__ imports. | ||
- aliases = [ | ||
- ast.alias(py.builtin.builtins.__name__, "@py_builtins"), | ||
- ast.alias("_pytest.assertion.rewrite", "@pytest_ar"), | ||
- ] | ||
doc = getattr(mod, "docstring", None) | ||
expect_docstring = doc is None | ||
if doc is not None and self.is_rewrite_disabled(doc): | ||
@@ -617,6 +613,22 @@ class AssertionRewriter(ast.NodeVisitor): | ||
pos += 1 | ||
else: | ||
lineno = item.lineno | ||
+ # Now actually insert the special imports. | ||
+ if sys.version_info >= (3, 10): | ||
+ aliases = [ | ||
+ ast.alias("builtins", "@py_builtins", lineno=lineno, col_offset=0), | ||
+ ast.alias( | ||
+ "_pytest.assertion.rewrite", | ||
+ "@pytest_ar", | ||
+ lineno=lineno, | ||
+ col_offset=0, | ||
+ ), | ||
+ ] | ||
+ else: | ||
+ aliases = [ | ||
+ ast.alias("builtins", "@py_builtins"), | ||
+ ast.alias("_pytest.assertion.rewrite", "@pytest_ar"), | ||
+ ] | ||
imports = [ | ||
ast.Import([alias], lineno=lineno, col_offset=0) for alias in aliases | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
import sys | ||
|
||
|
||
def monkey_patch_collections(): | ||
""" | ||
Monkey-patching for the collections module is required for Python 3.10 | ||
and above. | ||
Prior to 3.10, the collections module still contained all the entities defined in | ||
collections.abc from Python 3.3 onwards. Here we patch those back into main | ||
collections module. | ||
This can be removed when we upgrade to a version of Django that is Python 3.10 compatible. | ||
Copied from: | ||
https://github.com/learningequality/kolibri/blob/589dd15aa79e8694aff8754bb34f12384315dbb6/kolibri/utils/compat.py#L90 | ||
""" | ||
if sys.version_info < (3, 10): | ||
return | ||
import collections | ||
from collections import abc | ||
|
||
for name in dir(abc): | ||
if not hasattr(collections, name): | ||
setattr(collections, name, getattr(abc, name)) | ||
|
||
|
||
monkey_patch_collections() | ||
|
||
|
||
def monkey_patch_translation(): | ||
""" | ||
Monkey-patching for the gettext module is required for Python 3.11 | ||
and above. | ||
Prior to 3.11, the gettext module classes still had the deprecated set_output_charset | ||
This can be removed when we upgrade to a version of Django that no longer relies | ||
on this deprecated Python 2.7 only call. | ||
Copied from: | ||
https://github.com/learningequality/kolibri/blob/589dd15aa79e8694aff8754bb34f12384315dbb6/kolibri/utils/compat.py#L109 | ||
""" | ||
if sys.version_info < (3, 11): | ||
return | ||
|
||
import gettext | ||
|
||
def set_output_charset(*args, **kwargs): | ||
pass | ||
|
||
gettext.NullTranslations.set_output_charset = set_output_charset | ||
|
||
original_translation = gettext.translation | ||
|
||
def translation( | ||
domain, | ||
localedir=None, | ||
languages=None, | ||
class_=None, | ||
fallback=False, | ||
codeset=None, | ||
): | ||
return original_translation( | ||
domain, | ||
localedir=localedir, | ||
languages=languages, | ||
class_=class_, | ||
fallback=fallback, | ||
) | ||
|
||
gettext.translation = translation | ||
|
||
original_install = gettext.install | ||
|
||
def install(domain, localedir=None, codeset=None, names=None): | ||
return original_install(domain, localedir=localedir, names=names) | ||
|
||
gettext.install = install | ||
|
||
|
||
monkey_patch_translation() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
try: | ||
from test.support import EnvironmentVarGuard # noqa F401 | ||
except ImportError: | ||
# In Python 3.10, this has been moved to test.support.os_helper | ||
from test.support.os_helper import EnvironmentVarGuard # noqa F401 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.