From e96b07fe73345fbdd0ea5b662022ffedc01c1dd4 Mon Sep 17 00:00:00 2001 From: Sangjoon Bob Lee Date: Sat, 4 Jan 2025 13:01:41 -0500 Subject: [PATCH 1/9] chore: add new pip, conda requirements --- requirements/conda.txt | 3 +++ requirements/pip.txt | 3 +++ 2 files changed, 6 insertions(+) diff --git a/requirements/conda.txt b/requirements/conda.txt index e69de29b..8c884b13 100644 --- a/requirements/conda.txt +++ b/requirements/conda.txt @@ -0,0 +1,3 @@ +cookiecutter +black +pre-commit diff --git a/requirements/pip.txt b/requirements/pip.txt index e69de29b..8c884b13 100644 --- a/requirements/pip.txt +++ b/requirements/pip.txt @@ -0,0 +1,3 @@ +cookiecutter +black +pre-commit From 0ba8f9309f0744b6559161c34c258b3c553fdf09 Mon Sep 17 00:00:00 2001 From: Sangjoon Bob Lee Date: Sat, 4 Jan 2025 13:01:57 -0500 Subject: [PATCH 2/9] feat: add entry points of package create and update --- news/entry-pt-create-update.rst | 23 ++++++++++ pyproject.toml | 3 ++ src/scikit_package/app.py | 46 +++++++++++++++++++ .../AUTHORS.rst | 2 +- 4 files changed, 73 insertions(+), 1 deletion(-) create mode 100644 news/entry-pt-create-update.rst create mode 100644 src/scikit_package/app.py diff --git a/news/entry-pt-create-update.rst b/news/entry-pt-create-update.rst new file mode 100644 index 00000000..3de688db --- /dev/null +++ b/news/entry-pt-create-update.rst @@ -0,0 +1,23 @@ +**Added:** + +* Add `package create` and `package update` commands once `scikit-package` is installed. + +**Changed:** + +* + +**Deprecated:** + +* + +**Removed:** + +* + +**Fixed:** + +* + +**Security:** + +* diff --git a/pyproject.toml b/pyproject.toml index 903de4e3..1c9e0802 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -51,6 +51,9 @@ namespaces = false # to disable scanning PEP 420 namespaces (true by default) [tool.setuptools.dynamic] dependencies = {file = ["requirements/pip.txt"]} +[project.scripts] +package = "scikit_package.app:main" + [tool.codespell] exclude-file = ".codespell/ignore_lines.txt" ignore-words = ".codespell/ignore_words.txt" diff --git a/src/scikit_package/app.py b/src/scikit_package/app.py new file mode 100644 index 00000000..b4db6237 --- /dev/null +++ b/src/scikit_package/app.py @@ -0,0 +1,46 @@ +from argparse import ArgumentParser +import subprocess + +def create(): + run_cookiecutter() + + +def update(): + # FIXME: Implement the update command. As of now it does the same as the create command. + run_cookiecutter() + + +def run_cookiecutter(): + try: + subprocess.run(["cookiecutter", "https://github.com/Billingegroup/scikit-package"], check=True) + except subprocess.CalledProcessError as e: + print(f"Failed to run scikit-package for the following reason: {e}") + + +def setup_subparsers(parser): + # Create "create" subparser + parser_create = parser.add_parser("create", help="Create a new package") + parser_create.set_defaults(func=create) + # Create "update" subparser + parser_update = parser.add_parser("update", help="Update an existing package") + parser_update.set_defaults(func=update) + + +def main(): + """Entry point for the scikit-package CLI. + + Examples + -------- + >>> package create + >>> package update + """ + + parser = ArgumentParser(description="Manage package operations with scikit-package.") + subparsers = parser.add_subparsers(dest="command", required=True) + setup_subparsers(subparsers) + args = parser.parse_args() + args.func() + + +if __name__ == "__main__": + main() diff --git a/{{ cookiecutter.github_repo_name }}/AUTHORS.rst b/{{ cookiecutter.github_repo_name }}/AUTHORS.rst index 9104143f..478e20da 100644 --- a/{{ cookiecutter.github_repo_name }}/AUTHORS.rst +++ b/{{ cookiecutter.github_repo_name }}/AUTHORS.rst @@ -1,7 +1,7 @@ Authors ======= -Billinge Group and community contributors. +{{ cookiecutter.contributors }} Contributors ------------ From 4f40037af9e0c1d4ed82b9de13b53ddbfebd44e9 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sat, 4 Jan 2025 18:03:45 +0000 Subject: [PATCH 3/9] [pre-commit.ci] auto fixes from pre-commit hooks --- src/scikit_package/app.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/scikit_package/app.py b/src/scikit_package/app.py index b4db6237..db582d8a 100644 --- a/src/scikit_package/app.py +++ b/src/scikit_package/app.py @@ -1,5 +1,6 @@ -from argparse import ArgumentParser import subprocess +from argparse import ArgumentParser + def create(): run_cookiecutter() From e3e68b5fdad228ccb1b724458f2e0bcf6301f67e Mon Sep 17 00:00:00 2001 From: Sangjoon Bob Lee Date: Sat, 4 Jan 2025 23:09:38 -0500 Subject: [PATCH 4/9] ci: rerun for codecov From 01d1e677eef9811a2e37fe3af233daac8078b452 Mon Sep 17 00:00:00 2001 From: Sangjoon Bob Lee Date: Sun, 5 Jan 2025 15:34:08 -0500 Subject: [PATCH 5/9] fix: remove pre-commit, black requirements under conda.txt and pip.txt --- requirements/conda.txt | 2 -- requirements/pip.txt | 2 -- src/scikit_package/app.py | 3 ++- 3 files changed, 2 insertions(+), 5 deletions(-) diff --git a/requirements/conda.txt b/requirements/conda.txt index 8c884b13..c8e988bc 100644 --- a/requirements/conda.txt +++ b/requirements/conda.txt @@ -1,3 +1 @@ cookiecutter -black -pre-commit diff --git a/requirements/pip.txt b/requirements/pip.txt index 8c884b13..c8e988bc 100644 --- a/requirements/pip.txt +++ b/requirements/pip.txt @@ -1,3 +1 @@ cookiecutter -black -pre-commit diff --git a/src/scikit_package/app.py b/src/scikit_package/app.py index b4db6237..db582d8a 100644 --- a/src/scikit_package/app.py +++ b/src/scikit_package/app.py @@ -1,5 +1,6 @@ -from argparse import ArgumentParser import subprocess +from argparse import ArgumentParser + def create(): run_cookiecutter() From d94d8660ba135d185f0026b1670fe3613d8e568a Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sun, 5 Jan 2025 20:36:14 +0000 Subject: [PATCH 6/9] [pre-commit.ci] auto fixes from pre-commit hooks --- src/scikit_package/app.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/scikit_package/app.py b/src/scikit_package/app.py index db582d8a..0e64858e 100644 --- a/src/scikit_package/app.py +++ b/src/scikit_package/app.py @@ -13,7 +13,13 @@ def update(): def run_cookiecutter(): try: - subprocess.run(["cookiecutter", "https://github.com/Billingegroup/scikit-package"], check=True) + subprocess.run( + [ + "cookiecutter", + "https://github.com/Billingegroup/scikit-package", + ], + check=True, + ) except subprocess.CalledProcessError as e: print(f"Failed to run scikit-package for the following reason: {e}") @@ -23,7 +29,9 @@ def setup_subparsers(parser): parser_create = parser.add_parser("create", help="Create a new package") parser_create.set_defaults(func=create) # Create "update" subparser - parser_update = parser.add_parser("update", help="Update an existing package") + parser_update = parser.add_parser( + "update", help="Update an existing package" + ) parser_update.set_defaults(func=update) @@ -36,7 +44,9 @@ def main(): >>> package update """ - parser = ArgumentParser(description="Manage package operations with scikit-package.") + parser = ArgumentParser( + description="Manage package operations with scikit-package." + ) subparsers = parser.add_subparsers(dest="command", required=True) setup_subparsers(subparsers) args = parser.parse_args() From 0578ebb022a6132b36d37a851b3543006941e426 Mon Sep 17 00:00:00 2001 From: Sangjoon Bob Lee Date: Sun, 5 Jan 2025 15:38:00 -0500 Subject: [PATCH 7/9] fix: re-run pre-commit --- src/scikit_package/app.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/scikit_package/app.py b/src/scikit_package/app.py index 0e64858e..97cfaed1 100644 --- a/src/scikit_package/app.py +++ b/src/scikit_package/app.py @@ -29,9 +29,7 @@ def setup_subparsers(parser): parser_create = parser.add_parser("create", help="Create a new package") parser_create.set_defaults(func=create) # Create "update" subparser - parser_update = parser.add_parser( - "update", help="Update an existing package" - ) + parser_update = parser.add_parser("update", help="Update an existing package") parser_update.set_defaults(func=update) @@ -44,9 +42,7 @@ def main(): >>> package update """ - parser = ArgumentParser( - description="Manage package operations with scikit-package." - ) + parser = ArgumentParser(description="Manage package operations with scikit-package.") subparsers = parser.add_subparsers(dest="command", required=True) setup_subparsers(subparsers) args = parser.parse_args() From 9c3b5eee18bc1ec325f027bbfb385fbe1f70ecd0 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sun, 5 Jan 2025 20:38:10 +0000 Subject: [PATCH 8/9] [pre-commit.ci] auto fixes from pre-commit hooks --- src/scikit_package/app.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/scikit_package/app.py b/src/scikit_package/app.py index 97cfaed1..0e64858e 100644 --- a/src/scikit_package/app.py +++ b/src/scikit_package/app.py @@ -29,7 +29,9 @@ def setup_subparsers(parser): parser_create = parser.add_parser("create", help="Create a new package") parser_create.set_defaults(func=create) # Create "update" subparser - parser_update = parser.add_parser("update", help="Update an existing package") + parser_update = parser.add_parser( + "update", help="Update an existing package" + ) parser_update.set_defaults(func=update) @@ -42,7 +44,9 @@ def main(): >>> package update """ - parser = ArgumentParser(description="Manage package operations with scikit-package.") + parser = ArgumentParser( + description="Manage package operations with scikit-package." + ) subparsers = parser.add_subparsers(dest="command", required=True) setup_subparsers(subparsers) args = parser.parse_args() From 9849b7ce0e670e512c33f1807e82bdf7448f2a02 Mon Sep 17 00:00:00 2001 From: Sangjoon Bob Lee Date: Sun, 5 Jan 2025 15:39:45 -0500 Subject: [PATCH 9/9] fix: git pull usptream main to use line length of 79 --- src/scikit_package/app.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/scikit_package/app.py b/src/scikit_package/app.py index 97cfaed1..9d454f56 100644 --- a/src/scikit_package/app.py +++ b/src/scikit_package/app.py @@ -7,7 +7,8 @@ def create(): def update(): - # FIXME: Implement the update command. As of now it does the same as the create command. + # FIXME: Implement the update command. + # As of now it does the same as the create command. run_cookiecutter() @@ -29,7 +30,9 @@ def setup_subparsers(parser): parser_create = parser.add_parser("create", help="Create a new package") parser_create.set_defaults(func=create) # Create "update" subparser - parser_update = parser.add_parser("update", help="Update an existing package") + parser_update = parser.add_parser( + "update", help="Update an existing package" + ) parser_update.set_defaults(func=update) @@ -42,7 +45,9 @@ def main(): >>> package update """ - parser = ArgumentParser(description="Manage package operations with scikit-package.") + parser = ArgumentParser( + description="Manage package operations with scikit-package." + ) subparsers = parser.add_subparsers(dest="command", required=True) setup_subparsers(subparsers) args = parser.parse_args()