Skip to content

Commit

Permalink
Merge pull request #243 from bobleesj/entry-pt-create-update
Browse files Browse the repository at this point in the history
feat: allow running commands with `package create` and `package update` with an entry point of `package` to `app.py`
  • Loading branch information
sbillinge authored Jan 5, 2025
2 parents 035b31e + c7f7b8c commit df439a6
Show file tree
Hide file tree
Showing 6 changed files with 87 additions and 1 deletion.
23 changes: 23 additions & 0 deletions news/entry-pt-create-update.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
**Added:**

* Add `package create` and `package update` commands once `scikit-package` is installed.

**Changed:**

* <news item>

**Deprecated:**

* <news item>

**Removed:**

* <news item>

**Fixed:**

* <news item>

**Security:**

* <news item>
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 1 addition & 0 deletions requirements/conda.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
cookiecutter
1 change: 1 addition & 0 deletions requirements/pip.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
cookiecutter
58 changes: 58 additions & 0 deletions src/scikit_package/app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import subprocess
from argparse import ArgumentParser


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()
2 changes: 1 addition & 1 deletion {{ cookiecutter.github_repo_name }}/AUTHORS.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Authors
=======

Billinge Group and community contributors.
{{ cookiecutter.contributors }}

Contributors
------------
Expand Down

0 comments on commit df439a6

Please sign in to comment.