Skip to content

Commit

Permalink
Merge branch 'master' into feature/remoce-lyrebird-raw-header
Browse files Browse the repository at this point in the history
  • Loading branch information
noO0ob committed Jan 21, 2025
2 parents 3c60da6 + 5498aa6 commit a5f0ded
Show file tree
Hide file tree
Showing 10 changed files with 59 additions and 21 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ jobs:
unittest:
strategy:
matrix:
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
runs-on: macos-13
name: Python ${{ matrix.python-version }} tests
steps:
Expand All @@ -27,7 +27,7 @@ jobs:
unittest-arm64:
strategy:
matrix:
python-version: ["3.8.10", "3.9.13", "3.10.11", "3.11.9"]
python-version: ["3.8.10", "3.9.13", "3.10.11", "3.11.9", "3.12.7"]
runs-on: macos-latest
name: Python ${{ matrix.python-version }} tests
steps:
Expand Down
2 changes: 1 addition & 1 deletion lyrebird/compatibility.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def decorator(func):
'''

PYTHON_MIN_VERSION = (3, 8, 0)
PYTHON_MAX_VERSION = (3, 11, float('inf'))
PYTHON_MAX_VERSION = (3, 13, float('inf'))


'''
Expand Down
6 changes: 4 additions & 2 deletions lyrebird/event.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
Run events handler and background task worker
"""
import os
import imp
import sys
import copy
import uuid
Expand Down Expand Up @@ -71,7 +70,10 @@ def import_func_module(path):
if pkg in sys.modules:
continue
sys.path.append(str(Path(path)/pkg))
imp.load_package(pkg, Path(path)/pkg)
spec = importlib.util.spec_from_file_location(pkg, str(Path(path)/pkg/'__init__.py'))
module = importlib.util.module_from_spec(spec)
sys.modules[pkg] = module
spec.loader.exec_module(module)


def import_func_from_file(filepath, func_name):
Expand Down
4 changes: 2 additions & 2 deletions lyrebird/mock/blueprints/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,13 @@ def index(path=''):
resp = Response(
gen(),
status=req_context.flow['response']['code'],
headers=req_context.flow['response']['headers']
headers=req_context.get_response_headers()
)
elif req_context.flow['response']:
resp = Response(
req_context.flow['response'].get('data', ''),
status=req_context.flow['response'].get('code', 200),
headers=req_context.flow['response'].get('headers', {})
headers=req_context.get_response_headers()
)
else:
path_not_found_handler.handle(req_context)
Expand Down
16 changes: 15 additions & 1 deletion lyrebird/mock/handlers/handler_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

logger = get_logger()
proxy_handler = ProxyHandler()
lyrebird_response_headers = None


class HandlerContext:
Expand Down Expand Up @@ -221,7 +222,20 @@ def get_request_headers(self):
continue
headers[name] = value
return headers


# Before response returns, remove the Lyrebird internal headers
def get_response_headers(self):
global lyrebird_response_headers
if not lyrebird_response_headers:
lyrebird_response_headers = application.config.get('proxy.response.delete_headers', [])

headers = self.flow['response'].get('headers', {})
lyrebird_response_headers = []
for key in lyrebird_response_headers:
if key in headers:
del headers[key]
return headers

def get_request_cookies(self, in_request_handler=True):
if in_request_handler:
return self.request.cookies
Expand Down
10 changes: 8 additions & 2 deletions lyrebird/plugins/plugin_loader.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import os
import imp
import inspect
import traceback
from pathlib import Path
from collections import namedtuple

import pkg_resources
import setuptools
import importlib


from ..log import get_logger
from .plugin import Plugin
Expand Down Expand Up @@ -141,7 +142,12 @@ def load_from_path(plugin_path):
sys.modules.pop(pkg)
if pkg+'.manifest' in sys.modules:
sys.modules.pop(pkg+'.manifest')
imp.load_package(pkg, Path(plugin_path)/pkg)

spec = importlib.util.spec_from_file_location(pkg, str(Path(plugin_path)/pkg/'__init__.py'))
module = importlib.util.module_from_spec(spec)
sys.modules[pkg] = module
spec.loader.exec_module(module)

__import__(pkg+'.manifest')

# There can only one manifest in each plugin
Expand Down
2 changes: 1 addition & 1 deletion lyrebird/version.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
IVERSION = (3, 1, 2)
IVERSION = (3, 2, 0)
VERSION = ".".join(str(i) for i in IVERSION)
LYREBIRD = "Lyrebird " + VERSION
2 changes: 2 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,5 @@ netifaces==0.11.0
jsonschema==4.17.0
Flask-Cors==4.0.0
redis==4.6.0
setuptools
sortedcontainers
31 changes: 22 additions & 9 deletions requirements.txt.lock
Original file line number Diff line number Diff line change
@@ -1,4 +1,25 @@
aiohttp==3.8.3
aiohttp==3.9; python_version > "3.11"
urllib3==1.26.20; python_version > "3.11"
Werkzeug==3.1.3; python_version > "3.11"
yarl==1.9.4; python_version > "3.11"
Flask==3.1.0; python_version > "3.11"
frozenlist==1.5; python_version > "3.11"
itsdangerous==2.2.0; python_version > "3.11"
multidict==6.1.0; python_version > "3.11"
Pillow==11.0.0; python_version > "3.11"
setuptools==75; python_version > "3.11"

aiohttp==3.8.3; python_version <= "3.11"
urllib3==1.24.3; python_version <= "3.11"
Werkzeug==2.2.2; python_version <= "3.11"
yarl==1.8.1; python_version <= "3.11"
Flask==2.2.2; python_version <= "3.11"
frozenlist==1.3.1; python_version <= "3.11"
itsdangerous==2.1.2; python_version <= "3.11"
multidict==6.0.2; python_version <= "3.11"
Pillow==9.4.0; python_version <= "3.11"
setuptools==70; python_version <= "3.11"

aiosignal==1.2.0
aniso8601==9.0.1
async-timeout==4.0.2
Expand All @@ -11,21 +32,16 @@ chardet==3.0.4
charset-normalizer==2.1.1
click==8.1.3
colorama==0.4.1
Flask==2.2.2
Flask-RESTful==0.3.9
Flask-SocketIO==5.3.0
Flask-Cors==4.0.0
frozenlist==1.3.1
idna==2.8
importlib-metadata==5.0.0
itsdangerous==2.1.2
Jinja2==3.1.2
jsonschema==4.17.0
MarkupSafe==2.1.1
multidict==6.0.2
netifaces==0.11.0
packaging==19.0
Pillow==9.4.0
portpicker==1.3.1
pycodestyle==2.9.1
pyparsing==3.0.9
Expand All @@ -39,8 +55,5 @@ six==1.16.0
soupsieve==2.3.2.post1
SQLAlchemy==1.3.22
toml==0.10.2
urllib3==1.24.3
Werkzeug==2.2.2
yarl==1.8.1
zipp==3.10.0
redis==4.6.0
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,12 @@ def read_requirements(name):
zip_safe=False,
classifiers=[
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"License :: OSI Approved :: MIT License",
"Operating System :: MacOS",
"Operating System :: Microsoft :: Windows",
Expand Down

0 comments on commit a5f0ded

Please sign in to comment.