From 3d43b98b9b505049eca8a4bafd01697eee3a83ff Mon Sep 17 00:00:00 2001 From: Egor Korovin Date: Fri, 19 Aug 2022 16:49:22 +0700 Subject: [PATCH] workaroud to skip validation on Windows platform --- setup.py | 2 +- yappa/packaging/common.py | 5 ++--- yappa/packaging/direct.py | 6 +++--- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/setup.py b/setup.py index 325d28c..39ebc44 100644 --- a/setup.py +++ b/setup.py @@ -5,7 +5,7 @@ setup( name="yappa", - version="0.4.26", + version="0.4.27", url="https://github.com/turokg/yappa", description="Easy serverless deploy of python web applications", long_description_content_type="text/markdown", diff --git a/yappa/packaging/common.py b/yappa/packaging/common.py index 7f00265..21d27fd 100644 --- a/yappa/packaging/common.py +++ b/yappa/packaging/common.py @@ -3,13 +3,12 @@ from click import ClickException REQUIRED_PACKAGES = ("httpx", "PyYAML") +ENCODING = "cp1252" if any(platform.win32_ver()) else "utf-8" def validate_requirements_file(requirements_filename): - if any(platform.win32_ver()): - return try: - with open(requirements_filename, encoding="utf-8") as f: + with open(requirements_filename, encoding=ENCODING) as f: requirements = f.read() except FileNotFoundError: raise ClickException( diff --git a/yappa/packaging/direct.py b/yappa/packaging/direct.py index a832cbc..5291324 100644 --- a/yappa/packaging/direct.py +++ b/yappa/packaging/direct.py @@ -8,7 +8,7 @@ from click import ClickException from yappa.handlers.common import DEFAULT_CONFIG_FILENAME -from yappa.packaging.common import validate_requirements_file +from yappa.packaging.common import validate_requirements_file, ENCODING from yappa.settings import ( DEFAULT_IGNORED_FILES, DEFAULT_PACKAGE_DIR, @@ -31,11 +31,11 @@ def clear_requirements(requirements_file): removes Yappa package from requirements """ buffer = [] - with open(requirements_file, "r", encoding="utf-8") as f: + with open(requirements_file, "r", encoding=ENCODING) as f: for line in f.readlines(): if "yappa" not in line: buffer.append(line) - with open(requirements_file, "w+", encoding="utf-8") as f: + with open(requirements_file, "w+", encoding=ENCODING) as f: f.write("".join(buffer))