forked from NixOS/nixpkgs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
certifi: Patch to work under Python 2.
certifi being only Python3 breaks a lot of Python 2 packages via the requests packages. Patch the library to work under Python 2.
- Loading branch information
Showing
3 changed files
with
57 additions
and
3 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
20 changes: 20 additions & 0 deletions
20
pkgs/development/python-modules/certifi/read-file-for-python2.diff
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,20 @@ | ||
diff --git a/certifi/core.py b/certifi/core.py | ||
index 5d2b8cd..3261f82 100644 | ||
--- a/certifi/core.py | ||
+++ b/certifi/core.py | ||
@@ -45,8 +45,13 @@ except ImportError: | ||
# so won't address issues with environments like PyOxidizer that don't set | ||
# __file__ on modules. | ||
def read_text(_module, _path, encoding="ascii"): | ||
- with open(where(), "r", encoding=encoding) as data: | ||
- return data.read() | ||
+ try: | ||
+ with open(where(), "r", encoding=encoding) as data: | ||
+ return data.read() | ||
+ except TypeError: | ||
+ # Read under Python2.7 | ||
+ with open(where(), "r") as data: | ||
+ return data.read() | ||
|
||
# If we don't have importlib.resources, then we will just do the old logic | ||
# of assuming we're on the filesystem and munge the path directly. |
33 changes: 33 additions & 0 deletions
33
pkgs/development/python-modules/certifi/reenable-python2.diff
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,33 @@ | ||
diff --git a/README.rst b/README.rst | ||
index 182b511..9704bcb 100644 | ||
--- a/README.rst | ||
+++ b/README.rst | ||
@@ -21,12 +21,12 @@ built-in function:: | ||
>>> import certifi | ||
|
||
>>> certifi.where() | ||
- '/usr/local/lib/python3.7/site-packages/certifi/cacert.pem' | ||
+ '/usr/local/lib/python2.7/site-packages/certifi/cacert.pem' | ||
|
||
Or from the command line:: | ||
|
||
$ python -m certifi | ||
- /usr/local/lib/python3.7/site-packages/certifi/cacert.pem | ||
+ /usr/local/lib/python2.7/site-packages/certifi/cacert.pem | ||
|
||
Enjoy! | ||
|
||
diff --git a/setup.py b/setup.py | ||
index 69ec098..cadf7ff 100755 | ||
--- a/setup.py | ||
+++ b/setup.py | ||
@@ -54,6 +54,9 @@ setup( | ||
'License :: OSI Approved :: Mozilla Public License 2.0 (MPL 2.0)', | ||
'Natural Language :: English', | ||
'Programming Language :: Python', | ||
+ 'Programming Language :: Python :: 2', | ||
+ 'Programming Language :: Python :: 2.6', | ||
+ 'Programming Language :: Python :: 2.7', | ||
'Programming Language :: Python :: 3', | ||
'Programming Language :: Python :: 3.3', | ||
'Programming Language :: Python :: 3.4', |