From 97b4f516a88f323f998d634247b6058a5da2dd68 Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Tue, 15 Dec 2020 23:10:31 +0100 Subject: [PATCH] Bugfixes and improved setup logic --- docs/install.md | 4 ++-- requirements.txt | 26 +++++++++++++++++++++++ src/MANIFEST.in | 2 ++ src/setup.py | 1 + src/sh_edraft/cli/cpl_cli/cli.py | 1 + src/sh_edraft/cli/cpl_cli/cli_commands.py | 13 ++++++++---- 6 files changed, 41 insertions(+), 6 deletions(-) create mode 100644 requirements.txt create mode 100644 src/MANIFEST.in diff --git a/docs/install.md b/docs/install.md index 1691ccfe..54c105b4 100644 --- a/docs/install.md +++ b/docs/install.md @@ -1,2 +1,2 @@ -python setup.py install # for install -python setup.py sdist bdist # for build \ No newline at end of file +python setup.py install # for install +python setup.py sdist bdist_wheel # for build \ No newline at end of file diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 00000000..742e4085 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,26 @@ +aiohttp==3.6.3 +async-timeout==3.0.1 +attrs==20.3.0 +certifi==2020.11.8 +chardet==3.0.4 +click==7.1.2 +dateutils==0.6.12 +discord==1.0.1 +discord.py==1.5.1 +Flask==1.1.2 +idna==2.10 +itsdangerous==1.1.0 +Jinja2==2.11.2 +keyboard==0.13.5 +MarkupSafe==1.1.1 +multidict==4.7.6 +mysql-connector==2.2.9 +overloading==0.5.0 +python-dateutil==2.8.1 +pytz==2020.4 +six==1.15.0 +SQLAlchemy==1.3.20 +termcolor==1.1.0 +urllib3==1.26.2 +Werkzeug==1.0.1 +yarl==1.5.1 diff --git a/src/MANIFEST.in b/src/MANIFEST.in new file mode 100644 index 00000000..cb32f474 --- /dev/null +++ b/src/MANIFEST.in @@ -0,0 +1,2 @@ +include ../ README +recursive-include sh_edraft *.txt \ No newline at end of file diff --git a/src/setup.py b/src/setup.py index b99cc603..71cc0e2b 100644 --- a/src/setup.py +++ b/src/setup.py @@ -8,6 +8,7 @@ setuptools.setup( license='MIT', author='Sven Heidemann', author_email='edraft.sh@gmail.com', + include_package_data=True, description='sh-edraft python common lib', python_requires='>=3.8', install_requires=[ diff --git a/src/sh_edraft/cli/cpl_cli/cli.py b/src/sh_edraft/cli/cpl_cli/cli.py index 49974db2..a8ff912b 100644 --- a/src/sh_edraft/cli/cpl_cli/cli.py +++ b/src/sh_edraft/cli/cpl_cli/cli.py @@ -10,6 +10,7 @@ class CLI: def setup(self): self._commands[CLICommands.new.__name__] = CLICommands.new + self._commands[CLICommands.help.__name__] = CLICommands.help def main(self): args = sys.argv[1:] diff --git a/src/sh_edraft/cli/cpl_cli/cli_commands.py b/src/sh_edraft/cli/cpl_cli/cli_commands.py index 53986d34..cd0b6c21 100644 --- a/src/sh_edraft/cli/cpl_cli/cli_commands.py +++ b/src/sh_edraft/cli/cpl_cli/cli_commands.py @@ -5,7 +5,8 @@ class CLICommands: @classmethod def new(cls, args: list[str]): - if not os.path.isdir(f'./templates/{args[0]}'): + rel_path = os.path.dirname(__file__) + if not os.path.isdir(f'{rel_path}/templates/{args[0]}'): cls.unexpected_command(args[0]) sub_args = args[1:] @@ -13,7 +14,11 @@ class CLICommands: if len(sub_args) != 1: cls.unexpected_argument(sub_args[1]) - full_path = sub_args[0] + if not (sub_args[0].startswith('.') or sub_args[0].startswith('/')): + full_path = f'./{sub_args[0]}' + else: + full_path = sub_args[0] + name = os.path.basename(full_path) path = os.path.dirname(full_path) @@ -24,7 +29,7 @@ class CLICommands: if not os.path.isdir(full_path): os.makedirs(full_path) - for r, d, f in os.walk(f'./templates/{args[0]}'): + for r, d, f in os.walk(f'{rel_path}/templates/{args[0]}'): for file in f: template_content = '' with open(f'{r}/{file}') as template: @@ -71,7 +76,7 @@ class CLICommands: pyfile.close() @staticmethod - def help(): + def help(*args): print('Commands:') @classmethod