Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
kvg committed Jan 27, 2021
0 parents commit 5d59eda
Show file tree
Hide file tree
Showing 30 changed files with 898 additions and 0 deletions.
17 changes: 17 additions & 0 deletions .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[bumpversion]
current_version = 0.0.1
commit = True
tag = False
tag_name = {new_version}

[bumpversion:file:setup.py]
search = version = "{current_version}"
replace = version = "{new_version}"

[bumpversion:file:README.md]
search = Current version: {current_version}
replace = Current version: {new_version}

[bumpversion:file:src/carrot_cli/__main__.py]
search = __version__ = "{current_version}"
replace = __version__ = "{new_version}"
18 changes: 18 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[run]
source = carrot_cli
branch = True

[report]
skip_covered = True
exclude_lines =
no cov
no qa
noqa
pragma: no cover

# Don't complain if tests don't hit defensive assertion code:
raise AssertionError
raise NotImplementedError

[html]
directory = coverage_html_report
107 changes: 107 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
.hypothesis/
.pytest_cache/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# Jupyter Notebook
.ipynb_checkpoints

# pyenv
.python-version

# celery beat schedule file
celerybeat-schedule

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/

# PyCharm
.idea
2 changes: 2 additions & 0 deletions .isort.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[settings]
known_first_party=carrot_cli
13 changes: 13 additions & 0 deletions .pylintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@

[TYPECHECK]
# List of members which are set dynamically and missed by pylint inference
# system, and so shouldn't trigger E1101 when accessed. Python regular
# expressions are accepted.
generated-members=pysam*

[MASTER]
disable=
C0330,
C0114,
C0116,
E1136, # known bug in pylint 2.4.4
23 changes: 23 additions & 0 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# .readthedocs.yml
# Read the Docs configuration file
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details

# Required
version: 2

# Build documentation in the docs/ directory with Sphinx
sphinx:
configuration: docs/conf.py

# Build documentation with MkDocs
#mkdocs:
# configuration: mkdocs.yml

# Optionally build your docs in additional formats such as PDF and ePub
formats: all

# Optionally set the version of Python and requirements required to build your docs
python:
version: 3.7
install:
- requirements: docs/requirements.txt
29 changes: 29 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
BSD 3-Clause License

Copyright (c) 2019, Broad Institute
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

3. Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
10 changes: 10 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
graft tests
graft src

include README.rst
include LICENSE.txt
include tox.ini .travis.yml

prune **/.hypothesis

global-exclude *.py[cod] __pycache__ *.so *.dylib .DS_Store
139 changes: 139 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
# Python CLI Project Template
This template was created so that a new python3 CLI program could be quickly whipped up with a nice infrastructure.

## Acknowledgements
This template is based on several projects that originated at or as part of collaborations involving The Broad Institute of MIT and Harvard.
In particular, the following people were instrumental in those projects:

- Kiran Garimella (@kvg)
- Winni Kretzschmar (@winni2k)
- Karl Johan Westrin (@karljohanw)

## Contents / Features
Included in this template are the following features:
- `click` for argument parsing with examples
- an over-engineered logging module (ensures that all log messages have correct leading whitespace to be column-aligned)
- `tox` setup (linting, black for code formatting, testing)
- examples of tests (already connected to tox for quick starting)
- `.gitignore` for most kinds of local files
- include sort ordering defaults
- a `readthedocs` template
- a `bumpversion` config file
- a `pylint` config file

If you check this out and run `tox` the tests will all pass.

## Make It Your Own
### Required Changes
To make this project-specific, several placeholder values need to be replaced with your content.

| FIELD | DESCRIPTION |
| ----- | ----------- |
| PROJECT\_NAME | The name of your new project / tool. |
| \_SHORT\_PROJECT\_DESCRIPTION\_ | A concise description of your new project / tool. |
| \_AUTHOR\_ | The name of the primary author / point of contact. |
| \_AUTHOR\_EMAIL\_ | The email address of the primary author / point of contact. |

This find/replace will be needed until github [implements template repo variables.](https://github.com/isaacs/github/issues/1716)

However, fear not! I have provided `initialize.sh` for this very purpose. Run it with the following parameters after creating your repo to initialize your specific repository info:

```
./initialize.sh PROJECT_NAME "SHORT PROJECT DESCRIPTION" "AUTHOR NAME" AUTHOR_EMAIL
```
I quoted the fields that are likely to contain spaces - this will be necessary.

### Optional Changes
You may also need to do the following:
- Update the LICENSE file - it defaults to the BSD 3-Clause License.

When you add development dependencies, add them to `dev-requirements.txt`.

When you add testing dependencies, add them to `test-requirements.txt`.

When you add runtime dependencies, add them to `setup.py` in the `install_requires` section.

## General Notes

When running `tox`, you'll notice that the linter runs before black8. This is intentional. Rather than have it blindly reformat your code, I wanted to make sure you knew what you were doing wrong (i.e. against PEP 8 standards). You can configure this order to suit your needs.

Notable projects already using this template are:
- [Cromshell 2.0](https://github.com/broadinstitute/cromshell/tree/cromshell_2.0)
- [CARROT CLI](https://github.com/broadinstitute/carrot_cli)

Lastly, it's worth double-checking everything to make sure you want what's included here.

Below this line begins the project-specific portion of the README that should be modified after creating a new project:

---

# PROJECT\_NAME
\_SHORT\_PROJECT\_DESCRIPTION\_

Current version: 0.0.1

## Installation

pip install .

## Development

To do development in this codebase, the python3 development package must
be installed.

After installation the development environment can be set up by
the following commands:

python3 -mvenv venv
. venv/bin/activate
pip install -r dev-requirements.txt
pip install -e .

### Linting files

# run all linting commands
tox -e lint

# reformat all project files
black src tests setup.py

# sort imports in project files
isort -rc src tests setup.py

# check pep8 against all project files
flake8 src tests setup.py

# lint python code for common errors and codestyle issues
pylint src

### Tests

# run all linting and test
tox

# run only (fast) unit tests
tox -e unit

# run only linting
tox -e lint

Note: If you run into "module not found" errors when running tox for testing, verify the modules are listed in test-requirements.txt and delete the .tox folder to force tox to refresh dependencies.

### Versioning

We use `bumpversion` to maintain version numbers.
*DO NOT MANUALLY EDIT ANY VERSION NUMBERS.*

Our versions are specified by a 3 number semantic version system (https://semver.org/):

major.minor.patch

To update the version with bumpversion do the following:

`bumpversion PART` where PART is one of:
- major
- minor
- patch

This will increase the corresponding version number by 1.

13 changes: 13 additions & 0 deletions dev-requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
isort==4.3.21
tox
wheel
bumpversion
twine
black
flake8
pylint
cython
sphinx
sphinx-rtd-theme
mypy==0.770
click
Loading

0 comments on commit 5d59eda

Please sign in to comment.