├── .coveragerc
├── .github
└── workflows
│ └── ci.yml
├── .gitignore
├── .pre-commit-config.yaml
├── CHANGES.txt
├── LICENSE
├── MANIFEST.in
├── README.md
├── codecov.yml
├── python_seed
├── __init__.py
├── scripts
│ ├── __init__.py
│ └── cli.py
└── template
│ ├── ci
│ ├── .circleci
│ │ └── config.yml
│ └── .github
│ │ └── workflows
│ │ └── ci.yml
│ ├── cov
│ └── codecov.yml
│ └── module
│ ├── .pre-commit-config.yaml
│ ├── README.md
│ ├── pyseed
│ ├── __init__.py
│ ├── app.py
│ └── scripts
│ │ ├── __init__.py
│ │ └── cli.py
│ ├── requirements-dev.txt
│ ├── requirements.txt
│ ├── setup.cfg
│ ├── setup.py
│ ├── tests
│ ├── __init__.py
│ ├── test_function.py
│ └── test_mod.py
│ └── tox.ini
├── requirements.txt
├── setup.cfg
├── setup.py
├── tests
├── __init__.py
└── test_cli.py
└── tox.ini
/.coveragerc:
--------------------------------------------------------------------------------
1 | [report]
2 |
3 | show_missing = True
4 |
5 | exclude_lines =
6 | if __name__ == .__main__.:
7 |
--------------------------------------------------------------------------------
/.github/workflows/ci.yml:
--------------------------------------------------------------------------------
1 | name: CI
2 |
3 | on: [push]
4 |
5 | jobs:
6 | tests:
7 | runs-on: ubuntu-latest
8 | strategy:
9 | matrix:
10 | python-version: [3.6, 3.7, 3.8, 3.9]
11 |
12 | steps:
13 | - uses: actions/checkout@v2
14 | - name: Set up Python ${{ matrix.python-version }}
15 | uses: actions/setup-python@v2
16 | with:
17 | python-version: ${{ matrix.python-version }}
18 |
19 | - name: Install dependencies
20 | run: |
21 | python -m pip install --upgrade pip
22 | python -m pip install tox codecov pre-commit
23 |
24 | # Run tox using the version of Python in `PATH`
25 | - name: Run Tox
26 | run: tox -e py
27 |
28 | # Run pre-commit (only for python-3.7)
29 | - name: run pre-commit
30 | if: matrix.python-version == 3.7
31 | run: pre-commit run --all-files
32 |
33 | - name: Upload Results
34 | if: success()
35 | uses: codecov/codecov-action@v1
36 | with:
37 | file: ./coverage.xml
38 | flags: unittests
39 | name: ${{ matrix.platform }}-${{ matrix.tox-env }}
40 | fail_ci_if_error: false
41 |
42 | publish:
43 | needs: [tests]
44 | runs-on: ubuntu-latest
45 | if: contains(github.ref, 'tags')
46 | steps:
47 | - uses: actions/checkout@v2
48 | - name: Set up Python
49 | uses: actions/setup-python@v1
50 | with:
51 | python-version: "3.x"
52 |
53 | - name: Install dependencies
54 | run: |
55 | python -m pip install --upgrade pip
56 | python -m pip install tox
57 |
58 | - name: Set tag version
59 | id: tag
60 | # https://stackoverflow.com/questions/58177786/get-the-current-pushed-tag-in-github-actions
61 | run: echo ::set-output name=tag::${GITHUB_REF#refs/*/}
62 |
63 | - name: Set module version
64 | id: module
65 | # https://stackoverflow.com/questions/58177786/get-the-current-pushed-tag-in-github-actions
66 | run: echo ::set-output name=version::$(python setup.py --version)
67 |
68 | - name: Build and publish
69 | if: steps.tag.outputs.tag == steps.module.outputs.version
70 | env:
71 | TOXENV: release
72 | TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
73 | TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
74 | run: tox
75 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Byte-compiled / optimized / DLL files
2 | __pycache__/
3 | *.py[cod]
4 | *$py.class
5 |
6 | # C extensions
7 | *.so
8 |
9 | # Distribution / packaging
10 | .Python
11 | env/
12 | build/
13 | develop-eggs/
14 | dist/
15 | downloads/
16 | eggs/
17 | .eggs/
18 | lib/
19 | lib64/
20 | parts/
21 | sdist/
22 | var/
23 | wheels/
24 | *.egg-info/
25 | .installed.cfg
26 | *.egg
27 |
28 | # PyInstaller
29 | # Usually these files are written by a python script from a template
30 | # before PyInstaller builds the exe, so as to inject date/other infos into it.
31 | *.manifest
32 | *.spec
33 |
34 | # Installer logs
35 | pip-log.txt
36 | pip-delete-this-directory.txt
37 |
38 | # Unit test / coverage reports
39 | htmlcov/
40 | .tox/
41 | .coverage
42 | .coverage.*
43 | .cache
44 | nosetests.xml
45 | coverage.xml
46 | *.cover
47 | .hypothesis/
48 |
49 | # Translations
50 | *.mo
51 | *.pot
52 |
53 | # Django stuff:
54 | *.log
55 | local_settings.py
56 |
57 | # Flask stuff:
58 | instance/
59 | .webassets-cache
60 |
61 | # Scrapy stuff:
62 | .scrapy
63 |
64 | # Sphinx documentation
65 | docs/_build/
66 |
67 | # PyBuilder
68 | target/
69 |
70 | # Jupyter Notebook
71 | .ipynb_checkpoints
72 |
73 | # pyenv
74 | .python-version
75 |
76 | # celery beat schedule file
77 | celerybeat-schedule
78 |
79 | # SageMath parsed files
80 | *.sage.py
81 |
82 | # dotenv
83 | .env
84 |
85 | # virtualenv
86 | .venv
87 | venv/
88 | ENV/
89 |
90 | # Spyder project settings
91 | .spyderproject
92 | .spyproject
93 |
94 | # Rope project settings
95 | .ropeproject
96 |
97 | # mkdocs documentation
98 | /site
99 |
100 | # mypy
101 | .mypy_cache/
102 |
103 | .pytest_cache
104 |
--------------------------------------------------------------------------------
/.pre-commit-config.yaml:
--------------------------------------------------------------------------------
1 | repos:
2 | - repo: https://github.com/psf/black
3 | rev: 19.10b0
4 | hooks:
5 | - id: black
6 | language_version: python
7 |
8 | - repo: https://github.com/PyCQA/isort
9 | rev: 5.4.2
10 | hooks:
11 | - id: isort
12 | language_version: python
13 | args: [
14 | '--project=python_seed',
15 | '--thirdparty=click',
16 | '--section-default=THIRDPARTY']
17 |
18 | - repo: https://github.com/PyCQA/flake8
19 | rev: 3.8.3
20 | hooks:
21 | - id: flake8
22 | language_version: python
23 | args: [
24 | # E501 let black handle all line length decisions
25 | # W503 black conflicts with "line break before operator" rule
26 | # E203 black conflicts with "whitespace before ':'" rule
27 | '--ignore=E501,W503,E203',
28 | '--max-complexity=12',
29 | '--max-line-length=90']
30 |
31 | - repo: https://github.com/PyCQA/pydocstyle
32 | rev: 5.1.1
33 | hooks:
34 | - id: pydocstyle
35 | language_version: python
36 | args: [
37 | # Check for docstring presence only
38 | '--select=D1',
39 | # Don't require docstrings for tests
40 | '--match=(?!test).*\.py']
41 |
42 | - repo: https://github.com/pre-commit/mirrors-mypy
43 | rev: v0.812
44 | hooks:
45 | - id: mypy
46 | language_version: python
47 | exclude: ^python_seed/template
48 | args: [--no-strict-optional, --ignore-missing-imports]
49 |
--------------------------------------------------------------------------------
/CHANGES.txt:
--------------------------------------------------------------------------------
1 | 1.1.1 (2021-05-25)
2 | ------------------
3 | - remove useless `print`
4 |
5 | 1.1.0 (2021-05-07)
6 | ------------------
7 | - update pre-commit config
8 | - add python3.9 in CI
9 | - add `setup.cfg` for linters
10 | - remove `pkg_resources` usage
11 |
12 | 1.0.1 (2020-08-27)
13 | ------------------
14 | - add coverage.xml output from tox runs.
15 |
16 | 1.0.0.post2 (2020-08-21)
17 | ------------------------
18 | - fix pre-commit (#14)
19 |
20 | 1.0.0.post1 (2020-08-21)
21 | ------------------------
22 | - fix Manifest.in and add readme in pypi
23 |
24 | 1.0.0 (2020-08-21)
25 | ------------------
26 | Refactor
27 | - add CLI for project generator
28 | - add tox
29 | - add github CI
30 | - add pre-commit
31 |
32 | 0.1.0
33 | ------------------
34 | - initial release
35 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright (c) 2018 Development Seed
2 |
3 | Permission is hereby granted, free of charge, to any person obtaining a copy
4 | of this software and associated documentation files (the "Software"), to deal
5 | in the Software without restriction, including without limitation the rights
6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 | copies of the Software, and to permit persons to whom the Software is
8 | furnished to do so, subject to the following conditions:
9 |
10 | The above copyright notice and this permission notice shall be included in all
11 | copies or substantial portions of the Software.
12 |
13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19 | SOFTWARE.
20 |
--------------------------------------------------------------------------------
/MANIFEST.in:
--------------------------------------------------------------------------------
1 | include python_seed/template/ci/*
2 | include python_seed/template/ci/.github/workflows/*
3 | include python_seed/template/ci/.circleci/*
4 | include python_seed/template/cov/*
5 | include python_seed/template/module/pyseed/*
6 | include python_seed/template/module/tests/*
7 | include python_seed/template/module/*
8 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # python-seed
2 |
3 |
4 |
5 |
6 |
7 | Starter kit for creating a new python package.
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 | This is a starter repo for creating a new python package. Included are templates for standard files as well as best practices.
25 |
26 | ## Install
27 |
28 | You can install python-seed using pip
29 |
30 | ```bash
31 | $ pip install -U pip
32 | $ pip install python-seed
33 | ```
34 |
35 | or install from source:
36 |
37 | ```bash
38 | $ git clone https://github.com/developmentseed/python-seed.git
39 | $ cd python-seed
40 | $ pip install -U pip
41 | $ pip install -e .
42 | ```
43 |
44 | ## Usage
45 |
46 | ```bash
47 | $ pyseed --help
48 | Usage: pyseed [OPTIONS] COMMAND [ARGS]...
49 |
50 | python-seed subcommands.
51 |
52 | Options:
53 | --version Show the version and exit.
54 | --help Show this message and exit.
55 |
56 | Commands:
57 | create Create new python seed skeleton
58 | ```
59 |
60 | ```
61 | $ pyseed create --help
62 | Usage: pyseed create [OPTIONS] NAME
63 |
64 | Create new python seed skeleton.
65 |
66 | Options:
67 | --ci [circleci|github] Add CI configuration
68 | --help Show this message and exit.
69 | ```
70 |
71 | Create a new python project
72 |
73 | ```bash
74 | # Create a project without CI
75 | $ pyseed create awesomepythonproject
76 |
77 | # List files created
78 | $ ls -1 awesomepythonproject
79 | .pre-commit-config.yaml
80 | README.md
81 | awesomepythonproject/
82 | requirements-dev.txt
83 | requirements.txt
84 | setup.py
85 | tests/
86 | tox.ini
87 | ```
88 |
89 | With CI framework
90 |
91 | ```bash
92 | # Create a project github actions
93 | $ pyseed create awesomepythonproject --ci github
94 |
95 | # List files created
96 | $ ls -1 awesomepythonproject
97 | .github/workflows/ci.yml
98 | codecov.yml
99 | .pre-commit-config.yaml
100 | README.md
101 | awesomepythonproject/
102 | requirements-dev.txt
103 | requirements.txt
104 | setup.py
105 | tests/
106 | tox.ini
107 | ```
108 |
109 | # Project structure
110 |
111 | ```
112 | my-project/
113 | ├── .circleci/ or .github/ - CI configuration.
114 | ├── codecov.yml - codecov configuration (only if CI is added).
115 | ├── .pre-commit-config.yaml - pre-commit configuration.
116 | ├── README.md - project readme.
117 | ├── my_project/ - core python module.
118 | ├── tests/ - tests suite placeholder for your module.
119 | ├── requirements.txt - python requirements (!!! by default requirements are written in setup.py)
120 | ├── requirements-dev.txt - python dev requirements (!!! by default requirements are written in setup.py)
121 | └──tox.ini - TOX configuration.
122 | ```
123 |
124 |
125 | ## Contribution & Development
126 |
127 | Issues and pull requests are more than welcome.
128 |
129 | **dev install**
130 |
131 | ```bash
132 | $ git clone https://github.com/developmentseed/python-seed.git
133 | $ cd python-seed
134 | $ pip install -e .[dev]
135 | ```
136 |
137 | **Python3.7 only**
138 |
139 | This repo is set to use `pre-commit` to run *isort*, *flake8*, *pydocstring*, *black* ("uncompromising Python code formatter") and mypy when committing new code.
140 |
141 | ```bash
142 | $ pre-commit install
143 | ```
144 |
145 | ## About
146 | python-seed was created by [Development Seed]()
147 |
--------------------------------------------------------------------------------
/codecov.yml:
--------------------------------------------------------------------------------
1 | comment: off
2 |
3 | coverage:
4 | status:
5 | project:
6 | default:
7 | target: auto
8 | threshold: 5
9 |
--------------------------------------------------------------------------------
/python_seed/__init__.py:
--------------------------------------------------------------------------------
1 | """python_seed."""
2 |
3 | __version__ = "1.1.1"
4 |
--------------------------------------------------------------------------------
/python_seed/scripts/__init__.py:
--------------------------------------------------------------------------------
1 | """python_seed scripts."""
2 |
--------------------------------------------------------------------------------
/python_seed/scripts/cli.py:
--------------------------------------------------------------------------------
1 | """python_seed.scripts.cli."""
2 |
3 | import os
4 | import shutil
5 |
6 | import click
7 |
8 | from .. import __version__
9 |
10 | try:
11 | from importlib.resources import files as resources_files # type: ignore
12 | except ImportError:
13 | # Try backported to PY<39 `importlib_resources`.
14 | from importlib_resources import files as resources_files # type: ignore
15 |
16 |
17 | @click.group(short_help="python-seed CLI")
18 | @click.version_option(version=__version__, message="%(version)s")
19 | def pyseed():
20 | """python-seed subcommands."""
21 | pass
22 |
23 |
24 | @pyseed.command(short_help="Create new python seed skeleton")
25 | @click.argument("name", type=str, nargs=1)
26 | @click.option(
27 | "--ci", type=click.Choice(["circleci", "github"]), help="Add CI configuration"
28 | )
29 | def create(name, ci):
30 | """Create new python seed skeleton."""
31 | template_dir = str(resources_files("python_seed") / "template" / "module")
32 | shutil.copytree(template_dir, name)
33 |
34 | if ci:
35 | template_dir = str(
36 | resources_files("python_seed") / "template" / "ci" / f".{ci}"
37 | )
38 | shutil.copytree(template_dir, f"{name}/.{ci}")
39 |
40 | covconfig = str(
41 | resources_files("python_seed") / "template" / "cov" / "codecov.yml"
42 | )
43 | shutil.copy2(covconfig, f"{name}/codecov.yml")
44 |
45 | new_dir = name
46 | name = name.replace("-", "_")
47 | for root, _, files in os.walk(new_dir):
48 | if root.endswith("pyseed"):
49 | shutil.move(root, root.replace("pyseed", name))
50 |
51 | for root, _, files in os.walk(new_dir):
52 | for filename in files:
53 | if filename.endswith(".pyc"):
54 | continue
55 | with open(f"{root}/{filename}", "r", encoding="utf-8") as f:
56 | s = f.read().replace("pyseed", name)
57 |
58 | with open(f"{root}/{filename}", "w", encoding="utf-8") as f:
59 | f.write(s)
60 |
--------------------------------------------------------------------------------
/python_seed/template/ci/.circleci/config.yml:
--------------------------------------------------------------------------------
1 | # Python CircleCI 2.0 configuration file
2 | #
3 | # Check https://circleci.com/docs/2.0/language-python/ for more details
4 |
5 | # Environment variables required:
6 | # - TWINE_USERNAME / TWINE_PASSWORD: for publishing package to PyPi
7 |
8 | version: 2
9 |
10 | common: &common
11 | working_directory: ~/pyseed
12 | steps:
13 | # Get Code from github
14 | - checkout
15 |
16 | # Install deps
17 | - run:
18 | name: install dependencies
19 | command: pip install tox codecov pre-commit --user
20 |
21 | # Run tests using TOX
22 | - run:
23 | name: run tox
24 | command: ~/.local/bin/tox
25 |
26 | # Run pre-commit (only for python-3.7)
27 | - run:
28 | name: run pre-commit
29 | command: |
30 | if [[ "$CIRCLE_JOB" == "python-3.7" ]]; then
31 | ~/.local/bin/pre-commit run --all-files
32 | fi
33 |
34 | # Upload code coverage (only if env have UPLOAD_COVERAGE=1)
35 | - run:
36 | name: upload coverage report
37 | command: |
38 | if [[ "$UPLOAD_COVERAGE" == 1 ]]; then
39 | ~/.local/bin/coverage xml
40 | ~/.local/bin/codecov
41 | fi
42 | when: always
43 |
44 |
45 | jobs:
46 | "python-3.6":
47 | <<: *common
48 | docker:
49 | - image: cimg/python:3.6.13
50 | environment:
51 | - TOXENV=py36
52 |
53 | "python-3.7":
54 | <<: *common
55 | docker:
56 | - image: cimg/python:3.7.10
57 | environment:
58 | - TOXENV=py37
59 | - UPLOAD_COVERAGE=1
60 |
61 | "python-3.8":
62 | <<: *common
63 | docker:
64 | - image: cimg/python:3.8.10
65 | environment:
66 | - TOXENV=py38
67 |
68 | "python-3.9":
69 | <<: *common
70 | docker:
71 | - image: cimg/python:3.9.5
72 | environment:
73 | - TOXENV=py39
74 |
75 | deploy:
76 | docker:
77 | - image: cimg/python:3.7.10
78 | environment:
79 | - TOXENV=release
80 | working_directory: ~/pyseed
81 | steps:
82 | - checkout
83 |
84 | # We Only deploy to PyPi if github tag match the python version
85 | - run:
86 | name: verify git tag vs. version
87 | command: |
88 | VERSION=$(python setup.py --version)
89 | if [ "$VERSION" = "$CIRCLE_TAG" ]; then exit 0; else exit 3; fi
90 |
91 | - run:
92 | name: install dependencies
93 | command: pip install tox --user
94 |
95 | - run:
96 | name: run tox
97 | command: ~/.local/bin/tox
98 |
99 | workflows:
100 | version: 2
101 | build_and_deploy:
102 | jobs:
103 | - "python-3.6"
104 | - "python-3.7":
105 | filters: # required since `deploy` has tag filters AND requires `build`
106 | tags:
107 | only: /.*/
108 | - "python-3.8"
109 | - "python-3.9"
110 | - deploy:
111 | requires:
112 | - "python-3.7"
113 | filters:
114 | tags:
115 | only: /^[0-9]+.*/
116 | branches:
117 | ignore: /.*/
118 |
--------------------------------------------------------------------------------
/python_seed/template/ci/.github/workflows/ci.yml:
--------------------------------------------------------------------------------
1 | name: CI
2 |
3 | on: [push]
4 |
5 | jobs:
6 | tests:
7 | runs-on: ubuntu-latest
8 | strategy:
9 | matrix:
10 | python-version: [3.6, 3.7, 3.8, 3.9]
11 |
12 | steps:
13 | - uses: actions/checkout@v2
14 | - name: Set up Python ${{ matrix.python-version }}
15 | uses: actions/setup-python@v2
16 | with:
17 | python-version: ${{ matrix.python-version }}
18 |
19 | - name: Install dependencies
20 | run: |
21 | python -m pip install --upgrade pip
22 | python -m pip install tox codecov pre-commit
23 |
24 | # Run tox using the version of Python in `PATH`
25 | - name: Run Tox
26 | run: tox -e py
27 |
28 | # Run pre-commit (only for python-3.7)
29 | - name: run pre-commit
30 | if: matrix.python-version == 3.7
31 | run: pre-commit run --all-files
32 |
33 | - name: Upload Results
34 | if: success()
35 | uses: codecov/codecov-action@v1
36 | with:
37 | file: ./coverage.xml
38 | flags: unittests
39 | name: ${{ matrix.platform }}-${{ matrix.tox-env }}
40 | fail_ci_if_error: false
41 |
42 |
43 | publish:
44 | needs: [tests]
45 | runs-on: ubuntu-latest
46 | if: contains(github.ref, 'tags')
47 | steps:
48 | - uses: actions/checkout@v2
49 | - name: Set up Python
50 | uses: actions/setup-python@v1
51 | with:
52 | python-version: "3.x"
53 |
54 | - name: Install dependencies
55 | run: |
56 | python -m pip install --upgrade pip
57 | python -m pip install tox
58 |
59 | - name: Set tag version
60 | id: tag
61 | # https://stackoverflow.com/questions/58177786/get-the-current-pushed-tag-in-github-actions
62 | run: echo ::set-output name=tag::${GITHUB_REF#refs/*/}
63 |
64 | - name: Set module version
65 | id: module
66 | # https://stackoverflow.com/questions/58177786/get-the-current-pushed-tag-in-github-actions
67 | run: echo ::set-output name=version::$(python setup.py --version)
68 |
69 | - name: Build and publish
70 | if: steps.tag.outputs.tag == steps.module.outputs.version
71 | env:
72 | TOXENV: release
73 | TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
74 | TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
75 | run: tox
76 |
--------------------------------------------------------------------------------
/python_seed/template/cov/codecov.yml:
--------------------------------------------------------------------------------
1 | comment: off
2 |
3 | coverage:
4 | status:
5 | project:
6 | default:
7 | target: auto
8 | threshold: 5
9 |
--------------------------------------------------------------------------------
/python_seed/template/module/.pre-commit-config.yaml:
--------------------------------------------------------------------------------
1 | repos:
2 | - repo: https://github.com/psf/black
3 | rev: 19.10b0
4 | hooks:
5 | - id: black
6 | language_version: python
7 |
8 | - repo: https://github.com/PyCQA/isort
9 | rev: 5.4.2
10 | hooks:
11 | - id: isort
12 | language_version: python
13 |
14 | - repo: https://github.com/PyCQA/flake8
15 | rev: 3.8.3
16 | hooks:
17 | - id: flake8
18 | language_version: python
19 |
20 | - repo: https://github.com/PyCQA/pydocstyle
21 | rev: 5.1.1
22 | hooks:
23 | - id: pydocstyle
24 | language_version: python
25 |
26 | - repo: https://github.com/pre-commit/mirrors-mypy
27 | rev: v0.812
28 | hooks:
29 | - id: mypy
30 | language_version: python
31 |
--------------------------------------------------------------------------------
/python_seed/template/module/README.md:
--------------------------------------------------------------------------------
1 | # pyseed
2 |
--------------------------------------------------------------------------------
/python_seed/template/module/pyseed/__init__.py:
--------------------------------------------------------------------------------
1 | """pyseed."""
2 |
3 | __version__ = "0.0.1"
4 |
--------------------------------------------------------------------------------
/python_seed/template/module/pyseed/app.py:
--------------------------------------------------------------------------------
1 | """pyseed.app: Skeleton of a function."""
2 |
3 |
4 | def main(arg_one: str, arg_two: int):
5 | """Main function."""
6 | return arg_one * arg_two
7 |
--------------------------------------------------------------------------------
/python_seed/template/module/pyseed/scripts/__init__.py:
--------------------------------------------------------------------------------
1 | """pyseed.scripts"""
2 |
--------------------------------------------------------------------------------
/python_seed/template/module/pyseed/scripts/cli.py:
--------------------------------------------------------------------------------
1 | """pyseed.scripts.cli: pyseed CLI."""
2 |
3 | import click
4 |
5 | from .. import __version__
6 |
7 |
8 | @click.group(short_help="pyseed CLI")
9 | @click.version_option(version=__version__, message="%(version)s")
10 | def pyseed():
11 | """pyseed subcommands."""
12 | pass
13 |
14 |
15 | # @pyseed.command(short_help="Validate COGEO")
16 | # @click.option(...)
17 | # def cmd(...):
18 | # """Do Great Things."""
19 | # pass
20 |
--------------------------------------------------------------------------------
/python_seed/template/module/requirements-dev.txt:
--------------------------------------------------------------------------------
1 | pytest
2 | pytest-cov
3 | pre-commit
4 |
--------------------------------------------------------------------------------
/python_seed/template/module/requirements.txt:
--------------------------------------------------------------------------------
1 | click
2 |
--------------------------------------------------------------------------------
/python_seed/template/module/setup.cfg:
--------------------------------------------------------------------------------
1 | [bumpversion]
2 | current_version = 0.0.1
3 | commit = True
4 | tag = True
5 | tag_name = {new_version}
6 |
7 | [bumpversion:file:setup.py]
8 | search = version="{current_version}"
9 | replace = version="{new_version}"
10 |
11 | [bumpversion:file:pyseed/__init__.py]
12 | search = __version__ = "{current_version}"
13 | replace = __version__ = "{new_version}"
14 |
15 | [isort]
16 | profile = black
17 | known_first_party = pyseed
18 |
19 | [flake8]
20 | ignore = E501,W503,E203
21 | exclude = .git,__pycache__,docs/source/conf.py,old,build,dist
22 | max-complexity = 12
23 | max-line-length = 90
24 |
25 | [mypy]
26 | no_strict_optional = True
27 | ignore_missing_imports = True
28 |
29 | [pydocstyle]
30 | select = D1
31 | match = (?!test).*\.py
32 |
--------------------------------------------------------------------------------
/python_seed/template/module/setup.py:
--------------------------------------------------------------------------------
1 | """pyseed module."""
2 |
3 | from setuptools import find_packages, setup
4 |
5 | with open("README.md") as f:
6 | readme = f.read()
7 |
8 | # Runtime Requirements.
9 | inst_reqs = ["click"]
10 |
11 | # Dev Requirements
12 | extra_reqs = {
13 | "test": ["pytest", "pytest-cov"],
14 | "dev": ["pytest", "pytest-cov", "pre-commit"],
15 | }
16 |
17 |
18 | setup(
19 | name="pyseed",
20 | version="0.0.1",
21 | description=u"An Awesome python module",
22 | long_description=readme,
23 | long_description_content_type="text/markdown",
24 | python_requires=">=3",
25 | classifiers=[
26 | "Intended Audience :: Information Technology",
27 | "Intended Audience :: Science/Research",
28 | "License :: OSI Approved :: BSD License",
29 | "Programming Language :: Python :: 3.6",
30 | "Programming Language :: Python :: 3.7",
31 | "Programming Language :: Python :: 3.8",
32 | "Programming Language :: Python :: 3.9",
33 | ],
34 | keywords="An Awesome python module",
35 | author=u"",
36 | author_email="",
37 | url="",
38 | packages=find_packages(exclude=["tests"]),
39 | include_package_data=True,
40 | zip_safe=False,
41 | install_requires=inst_reqs,
42 | extras_require=extra_reqs,
43 | entry_points={"console_scripts": ["pyseed = pyseed.scripts.cli:pyseed"]},
44 | )
45 |
--------------------------------------------------------------------------------
/python_seed/template/module/tests/__init__.py:
--------------------------------------------------------------------------------
1 | """pyseed tests suite."""
2 |
--------------------------------------------------------------------------------
/python_seed/template/module/tests/test_function.py:
--------------------------------------------------------------------------------
1 | """Test pyseed functions."""
2 |
3 | from pyseed import app
4 |
5 |
6 | def test_app():
7 | """Test app.main function."""
8 | assert app.main("ah ", 3) == "ah ah ah "
9 |
--------------------------------------------------------------------------------
/python_seed/template/module/tests/test_mod.py:
--------------------------------------------------------------------------------
1 | """Test pyseed module."""
2 |
3 | import pyseed
4 |
5 |
6 | def test_version():
7 | """test version."""
8 | assert pyseed.version
9 |
--------------------------------------------------------------------------------
/python_seed/template/module/tox.ini:
--------------------------------------------------------------------------------
1 | [tox]
2 | envlist = py36,py37,py38,py39
3 |
4 | [testenv]
5 | extras = test
6 | commands=
7 | python -m pytest --cov pyseed --cov-report xml --cov-report term-missing --ignore=venv
8 |
9 | # Release tooling
10 | [testenv:build]
11 | basepython = python3
12 | skip_install = true
13 | deps =
14 | wheel
15 | setuptools
16 | commands =
17 | python setup.py sdist
18 |
19 | [testenv:release]
20 | basepython = python3
21 | skip_install = true
22 | setenv =
23 | TWINE_USERNAME = {env:TWINE_USERNAME}
24 | TWINE_PASSWORD = {env:TWINE_PASSWORD}
25 | deps =
26 | {[testenv:build]deps}
27 | twine >= 1.5.0
28 | commands =
29 | {[testenv:build]commands}
30 | twine upload --skip-existing dist/*
31 |
--------------------------------------------------------------------------------
/requirements.txt:
--------------------------------------------------------------------------------
1 | click
2 |
--------------------------------------------------------------------------------
/setup.cfg:
--------------------------------------------------------------------------------
1 | [bumpversion]
2 | current_version = 1.1.1
3 | commit = True
4 | tag = True
5 | tag_name = {new_version}
6 |
7 | [bumpversion:file:setup.py]
8 | search = version="{current_version}"
9 | replace = version="{new_version}"
10 |
11 | [bumpversion:file:python_seed/__init__.py]
12 | search = __version__ = "{current_version}"
13 | replace = __version__ = "{new_version}"
14 |
15 | [isort]
16 | profile = black
17 | known_first_party = python_seed
18 | known_third_party = click
19 | default_section = THIRDPARTY
20 |
21 | [flake8]
22 | ignore = E501,W503,E203
23 | exclude = .git,__pycache__,docs/source/conf.py,old,build,dist
24 | max-complexity = 12
25 | max-line-length = 90
26 |
27 | [mypy]
28 | no_strict_optional = True
29 | ignore_missing_imports = True
30 | exclude = ^python_seed/template
31 |
32 | [pydocstyle]
33 | select = D1
34 | match = (?!test).*\.py
35 |
--------------------------------------------------------------------------------
/setup.py:
--------------------------------------------------------------------------------
1 | """Setup python-seed"""
2 |
3 | from setuptools import find_packages, setup
4 |
5 | with open("README.md") as f:
6 | readme = f.read()
7 |
8 | # Runtime requirements.
9 | inst_reqs = [
10 | "click",
11 | "importlib_resources>=1.1.0;python_version<'3.9'",
12 | ]
13 |
14 | extra_reqs = {
15 | "test": ["pytest", "pytest-cov"],
16 | "dev": ["pytest", "pytest-cov", "pre-commit"],
17 | }
18 |
19 | setup(
20 | name="python-seed",
21 | version="1.1.1",
22 | description="Create skeleton of python project",
23 | long_description=readme,
24 | long_description_content_type="text/markdown",
25 | author=u"Vincent Sarago",
26 | author_email="vincent@developmentseed.com",
27 | url="https://github.com/developementseed/python-seed",
28 | license="MIT",
29 | classifiers=[
30 | "Intended Audience :: Developers",
31 | "Intended Audience :: Information Technology",
32 | "Intended Audience :: Science/Research",
33 | "License :: OSI Approved :: MIT License",
34 | "Programming Language :: Python :: 3.6",
35 | "Programming Language :: Python :: 3.7",
36 | "Programming Language :: Python :: 3.8",
37 | "Programming Language :: Python :: 3.9",
38 | ],
39 | keywords="Python Generator tox pre-commit",
40 | packages=find_packages(exclude=["tests"]),
41 | include_package_data=True,
42 | zip_safe=False,
43 | install_requires=inst_reqs,
44 | extras_require=extra_reqs,
45 | entry_points={"console_scripts": ["pyseed = python_seed.scripts.cli:pyseed"]},
46 | )
47 |
--------------------------------------------------------------------------------
/tests/__init__.py:
--------------------------------------------------------------------------------
1 | """python_seed tests suite."""
2 |
--------------------------------------------------------------------------------
/tests/test_cli.py:
--------------------------------------------------------------------------------
1 | """tests python_seed.cli."""
2 |
3 | import os
4 |
5 | from click.testing import CliRunner
6 |
7 | from python_seed.scripts.cli import pyseed
8 |
9 |
10 | def test_create():
11 | """Test the create function"""
12 | runner = CliRunner()
13 | with runner.isolated_filesystem():
14 | result = runner.invoke(pyseed, ["create", "myfunction"])
15 | assert not os.path.exists("myfunction/.github/workflows/ci.yml")
16 | assert not os.path.exists("myfunction/codecov.yml")
17 | with open("myfunction/README.md", "r") as f:
18 | assert f.read().splitlines()[0] == "# myfunction"
19 | assert not result.exception
20 | assert result.exit_code == 0
21 |
22 | with runner.isolated_filesystem():
23 | result = runner.invoke(pyseed, ["create", "myfunction", "--ci", "github"])
24 | assert os.path.exists("myfunction/.github/workflows/ci.yml")
25 | assert os.path.exists("myfunction/codecov.yml")
26 | with open("myfunction/README.md", "r") as f:
27 | assert f.read().splitlines()[0] == "# myfunction"
28 | assert not result.exception
29 | assert result.exit_code == 0
30 |
--------------------------------------------------------------------------------
/tox.ini:
--------------------------------------------------------------------------------
1 | [tox]
2 | envlist = py36,py37,py38,py39
3 |
4 | [testenv]
5 | extras = test
6 | commands=
7 | python -m pytest --cov python_seed --cov-report xml --cov-report term-missing --ignore=python_seed/template/
8 |
9 | # Release tooling
10 | [testenv:build]
11 | basepython = python3
12 | skip_install = true
13 | deps =
14 | wheel
15 | setuptools
16 | commands =
17 | python setup.py sdist
18 |
19 | [testenv:release]
20 | setenv =
21 | TWINE_USERNAME = {env:TWINE_USERNAME}
22 | TWINE_PASSWORD = {env:TWINE_PASSWORD}
23 | basepython = python3
24 | skip_install = true
25 | deps =
26 | {[testenv:build]deps}
27 | twine >= 1.5.0
28 | commands =
29 | {[testenv:build]commands}
30 | twine upload --skip-existing dist/*
31 |
--------------------------------------------------------------------------------