Skip to content

Commit e3dfee5

Browse files
author
Konrad Cempura
committed
Python 2.7: Requirements for older python and patches for imports
1 parent b8c03d9 commit e3dfee5

File tree

4 files changed

+26
-1
lines changed

4 files changed

+26
-1
lines changed

openapi_core/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# -*- coding: utf-8 -*-
22

3+
"""Python 2.7 backward compatibility"""
4+
import openapi_core._python27_patch
5+
36
"""OpenAPI core module"""
47
from openapi_core.shortcuts import (
58
create_spec, validate_parameters, validate_body, validate_data,

openapi_core/_python27_patch.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import functools
2+
try:
3+
from functools import lru_cache
4+
5+
except ImportError:
6+
from backports.functools_lru_cache import lru_cache
7+
functools.lru_cache = lru_cache
8+
9+
try:
10+
from functools import partialmethod
11+
12+
except ImportError:
13+
from backports.functools_partialmethod import partialmethod
14+
functools.partialmethod = partialmethod

requirements_2.7.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
openapi-spec-validator
2+
six
3+
backports.functools-lru-cache
4+
backports.functools-partialmethod
5+
enum34

setup.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ def run_tests(self):
5353
init_py = read_file(init_path)
5454
metadata = get_metadata(init_py)
5555

56+
py27 = '_2.7' if sys.version_info < (3,) else ''
57+
5658

5759
setup(
5860
name='openapi-core',
@@ -69,11 +71,12 @@ def run_tests(self):
6971
"Topic :: Software Development :: Libraries :: Python Modules",
7072
"Operating System :: OS Independent",
7173
'Programming Language :: Python :: 3.4',
74+
'Programming Language :: Python :: 3.4',
7275
'Programming Language :: Python :: 3.5',
7376
'Programming Language :: Python :: 3.6',
7477
'Topic :: Software Development :: Libraries',
7578
],
76-
install_requires=read_requirements('requirements.txt'),
79+
install_requires=read_requirements('requirements{}.txt'.format(py27)),
7780
tests_require=read_requirements('requirements_dev.txt'),
7881
extras_require={
7982
'flask': ["werkzeug"],

0 commit comments

Comments
 (0)