get compiling with python 3.10 and remove pipenv for build

This commit is contained in:
Balakrishnan Balasubramanian 2023-06-14 11:00:09 -04:00
parent eacb03f84e
commit 0d4faa0859
4 changed files with 18 additions and 10 deletions

View File

@ -6,11 +6,14 @@ shell:
test: test:
pipenv run python -m unittest discover pipenv run python -m unittest discover
build: clean requirements.txt: Pipfile.lock
pipenv run python -m pip install -r <(pipenv requirements ) --target build pipenv requirements > requirements.txt
build: clean requirements.txt
python3 -m pip install -r requirements.txt --target build
cp -r mail4one/ build/ cp -r mail4one/ build/
pipenv run python -m compileall build/mail4one -f python3 -m compileall build/mail4one -f
pipenv run python -m zipapp \ python3 -m zipapp \
--output mail4one.pyz \ --output mail4one.pyz \
--python "/usr/bin/env python3" \ --python "/usr/bin/env python3" \
--main mail4one.server:main \ --main mail4one.server:main \

View File

@ -125,6 +125,6 @@ def get_mboxes(addr: str, checks: list[Checker]) -> list[str]:
return list(inner()) return list(inner())
def gen_addr_to_mboxes(cfg: Config) -> Callable[[str], [str]]: def gen_addr_to_mboxes(cfg: Config) -> Callable[[str], list[str]]:
checks = parse_checkers(cfg) checks = parse_checkers(cfg)
return lambda addr: get_mboxes(addr, checks) return lambda addr: get_mboxes(addr, checks)

View File

@ -23,7 +23,7 @@ from aiosmtpd.smtp import Session as SMTPSession
class MyHandler(AsyncMessage): class MyHandler(AsyncMessage):
def __init__(self, mails_path: Path, mbox_finder: Callable[[str], [str]]): def __init__(self, mails_path: Path, mbox_finder: Callable[[str], list[str]]):
super().__init__() super().__init__()
self.mails_path = mails_path self.mails_path = mails_path
self.mbox_finder = mbox_finder self.mbox_finder = mbox_finder
@ -54,7 +54,7 @@ class MyHandler(AsyncMessage):
def protocol_factory_starttls(mails_path: Path, def protocol_factory_starttls(mails_path: Path,
mbox_finder: Callable[[str], [str]], mbox_finder: Callable[[str], list[str]],
context: ssl.SSLContext): context: ssl.SSLContext):
logging.info("Got smtp client cb starttls") logging.info("Got smtp client cb starttls")
try: try:
@ -69,7 +69,7 @@ def protocol_factory_starttls(mails_path: Path,
return smtp return smtp
def protocol_factory(mails_path: Path, mbox_finder: Callable[[str], [str]]): def protocol_factory(mails_path: Path, mbox_finder: Callable[[str], list[str]]):
logging.info("Got smtp client cb") logging.info("Got smtp client cb")
try: try:
handler = MyHandler(mails_path, mbox_finder) handler = MyHandler(mails_path, mbox_finder)
@ -83,7 +83,7 @@ def protocol_factory(mails_path: Path, mbox_finder: Callable[[str], [str]]):
async def create_smtp_server_starttls(host: str, async def create_smtp_server_starttls(host: str,
port: int, port: int,
mails_path: Path, mails_path: Path,
mbox_finder: Callable[[str], [str]], mbox_finder: Callable[[str], list[str]],
ssl_context: ssl.SSLContext) -> asyncio.Server: ssl_context: ssl.SSLContext) -> asyncio.Server:
loop = asyncio.get_event_loop() loop = asyncio.get_event_loop()
return await loop.create_server(partial(protocol_factory_starttls, return await loop.create_server(partial(protocol_factory_starttls,
@ -96,7 +96,7 @@ async def create_smtp_server_starttls(host: str,
async def create_smtp_server(host: str, async def create_smtp_server(host: str,
port: int, port: int,
mails_path: Path, mails_path: Path,
mbox_finder: Callable[[str], [str]], mbox_finder: Callable[[str], list[str]],
ssl_context: ssl.SSLContext | None = None) -> asyncio.Server: ssl_context: ssl.SSLContext | None = None) -> asyncio.Server:
loop = asyncio.get_event_loop() loop = asyncio.get_event_loop()
return await loop.create_server(partial(protocol_factory, mails_path, mbox_finder), return await loop.create_server(partial(protocol_factory, mails_path, mbox_finder),

5
requirements.txt Normal file
View File

@ -0,0 +1,5 @@
-i https://pypi.org/simple
aiosmtpd==1.4.4.post2
atpublic==4.0 ; python_version >= '3.8'
attrs==23.1.0 ; python_version >= '3.7'
python-jata==1.2