From 0bd7d9211ce2eae7f267af31b4e3c7dc22eb4134 Mon Sep 17 00:00:00 2001 From: Euan Date: Tue, 21 May 2024 16:07:33 +1000 Subject: [PATCH] added poetry optional install and updated markdownlint error --- cookiecutter.json | 1 + hooks/post_gen_project.py | 27 ++++++++++++++++++++++++- {{cookiecutter.project_slug}}/README.md | 4 ++-- 3 files changed, 29 insertions(+), 3 deletions(-) diff --git a/cookiecutter.json b/cookiecutter.json index 431fd735..3fc3736f 100644 --- a/cookiecutter.json +++ b/cookiecutter.json @@ -12,5 +12,6 @@ "docstrings_style": ["google", "numpy", "pep257"], "use_mypy": "y", "install_precommit_hooks": "y", + "install_poetry": "y", "_copy_without_render": ["docs/changelog.md", "docs/contributing.md", "docs/index.md", ".github/workflows/*.yml"] } diff --git a/hooks/post_gen_project.py b/hooks/post_gen_project.py index 3e6d2370..28d22c9a 100644 --- a/hooks/post_gen_project.py +++ b/hooks/post_gen_project.py @@ -48,10 +48,26 @@ def init_git(): def install_pre_commit_hooks(): - execute(sys.executable, "-m", "pip", "install", "pre-commit==3.6.2") + execute(sys.executable, "-m", "pip", "install", "pre-commit", "--user") execute(sys.executable, "-m", "pre_commit", "install") +def install_poetry(): + execute(sys.executable, "-m", "pip", "install", "poetry", "--user") + execute( + sys.executable, + "-m", + "poetry", + "install", + "-E", + "doc", + "-E", + "dev", + "-E", + "test", + ) + + if __name__ == "__main__": if "no" in "{{ cookiecutter.command_line_interface|lower }}": @@ -74,3 +90,12 @@ def install_pre_commit_hooks(): print( "Failed to install pre-commit hooks. Please run `pre-commit install` by your self. For more on pre-commit, please refer to https://pre-commit.com" ) + + if "{{ cookiecutter.install_poetry }}" == "y": + try: + install_pre_commit_hooks() + except Exception as e: + print(str(e)) + print( + "Failed to install pre-commit hooks. Please run `pre-commit install` by your self. For more on pre-commit, please refer to https://pre-commit.com" + ) diff --git a/{{cookiecutter.project_slug}}/README.md b/{{cookiecutter.project_slug}}/README.md index 5c3780c7..b93d4442 100644 --- a/{{cookiecutter.project_slug}}/README.md +++ b/{{cookiecutter.project_slug}}/README.md @@ -16,8 +16,8 @@ {% if is_open_source %} * Documentation: -* GitHub: < cookiecutter.github_username }}/{{ cookiecutter.project_slug }}> -* PyPI: < cookiecutter.project_slug }}/> +* GitHub: {{< mdl-disable "" >}} +* PyPI: {{< mdl-disable "" >}} * Free software: {{ cookiecutter.open_source_license }} {% endif %}