Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add click version options and update setup.py to include README.md info #5

Merged
merged 6 commits into from
Jan 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions {{cookiecutter.project_slug}}/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,17 @@ def get_version():
)
) as f:
return f.readline().strip()


def get_description():
with open("README.md", "r") as fh:
long_description = fh.read()
return long_description


def get_data_files():
data_files = [(".", ["README.md"])]
return data_files


CLASSIFIERS = [
Expand All @@ -33,9 +44,12 @@ def get_version():
url="{{cookiecutter.project_url}}",
python_requires="{{cookiecutter.min_python_version}}",
description="{{cookiecutter.project_description}}",
long_description=get_description(),
long_description_content_type="text/markdown",
version=get_version(),
author="{{cookiecutter.full_name}}",
author_email="{{cookiecutter.email}}",
data_files=get_data_files(),
py_modules=["{{cookiecutter.project_slug}}"],
install_requires=[
"snakemake{{cookiecutter.snakemake_version}}",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

from .util import (
snake_base,
print_version,
get_version,
default_to_output,
copy_config,
run_snakemake,
Expand Down Expand Up @@ -82,8 +82,11 @@ def common_options(func):
@click.group(
cls=OrderedCommands, context_settings=dict(help_option_names=["-h", "--help"])
)
@click.version_option(get_version(), "-v", "--version", is_flag=True)
def cli():
"""For more options, run:
"""{{cookiecutter.project_description}}
\b
For more options, run:
{{cookiecutter.project_slug}} command --help"""
pass

Expand Down Expand Up @@ -150,7 +153,6 @@ def citation(**kwargs):


def main():
print_version()
cli()


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ def snake_base(rel_path):
return os.path.join(os.path.dirname(os.path.realpath(__file__)), rel_path)


def print_version():
def get_version():
with open(snake_base("{{cookiecutter.project_slug}}.VERSION"), "r") as f:
version = f.readline()
echo_click("\n" + "{{cookiecutter.project_name}} version " + version + "\n")
return version


def echo_click(msg, log=None):
Expand Down