Skip to content

Commit

Permalink
cleanup ununsed code
Browse files Browse the repository at this point in the history
  • Loading branch information
romnn committed Feb 14, 2021
1 parent ada8a9e commit edb2367
Show file tree
Hide file tree
Showing 13 changed files with 68 additions and 136 deletions.
38 changes: 38 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: release

on:
push:
tags:
- '*'

jobs:
publish-pypi:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: 3.8
- id: query
uses: romnnn/query-git-action@master

- name: Install pypa/build
run: >-
python -m
pip install
build
--user
- name: Build a binary wheel and a source tarball
run: >-
python -m
build
--sdist
--wheel
--outdir dist/
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@master
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
12 changes: 1 addition & 11 deletions CONTRIBUTING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,6 @@ Implement Features
Look through the `GitHub issues`_ for features. Anything tagged with *"enhancement"*
and *"help wanted"* is open to whoever wants to implement it.

Write Documentation
~~~~~~~~~~~~~~~~~~~

cookiecutter-pypackage could always use more documentation, whether as part of the
official cookiecutter-pypackage docs, in docstrings, or even on the web in blog posts,
articles, and such.

Submit Feedback
~~~~~~~~~~~~~~~

Expand Down Expand Up @@ -92,10 +85,7 @@ Pull Request Guidelines
Before you submit a pull request, check that it meets these guidelines:

1. The pull request should include tests.
2. If the pull request adds functionality, the documentation (``docs/``) should be updated. Put
your new functionality into a function with a docstring and add the
feature to the list in ``README.rst``.
3. The pull request should work for python 3.6+. Check the
2. The pull request should work for python 3.6+. Check the
`build status of your pull request <https://travis-ci.org/{{ cookiecutter.github_username }}/{{ cookiecutter.project_slug }}/pull_requests>`_
and make sure that all tests pass for all supported python versions.

Expand Down
1 change: 0 additions & 1 deletion Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ pytest-sugar = "*"
# Coverage
coverage = "*"
# Tools
"ruamel.yaml" = "*"
invoke = "*"
pre-commit = "*"
cookiecutter = "*"
Expand Down
46 changes: 2 additions & 44 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ The key features of this template include:
* Automatic documentation from Google style docstrings with ``sphinx``
* All development tasks (``lint``, ``format``, ``test``, etc) wrapped up in a cli by ``invoke``
* Automatic deployment to PyPI_
* Automatic publishing of your documentation to `GitHub Pages`_


Features
--------
Expand All @@ -39,14 +37,13 @@ The following features have been **removed**:
* Optional Google docstrings are now default.
* Only ``flake8`` (no more ``pylint``) is used for linting
* No more ``HISTORY.rst`` file. Must be manually included for projects that require it.
* AppVeyor_ continuous integration. Only Travis-CI_ is used.
* AppVeyor_ continuous integration. Only GitHub Actions is used.

.. _AppVeyor: https://www.appveyor.com/

The following features have been **changed**:

* ``yapf`` was replaced by ``black`` for formatting python code
* TODO: use hugo for documentation

The following features have been **added**:

Expand All @@ -55,7 +52,6 @@ The following features have been **added**:
* good test coverage is a requirement
* Automatic initialization of a ``git`` repository post generation
* Automatic installation of development dependencies post generation
* Automatic deployment to `GitHub Pages`_ of the documentation.

Quickstart
----------
Expand Down Expand Up @@ -93,44 +89,11 @@ After your project was created:

.. warning:: When you are done working on this project, run ``deactivate`` to deactivate the environment.



* Make an initial release of your package to PyPI_. You will be asked for your credentials::

$ pip install twine
$ python setup.py sdist
$ twine upload dist/*

* Get a deployment token for your package on PyPI_ under ``Manage > Settings > Create token``.
It is good practice to use your package name as the token description and restrict access to only this package.
Make sure to copy to copy the token as we will use it in the next steps.
* Add the repo to your `Travis-CI`_ account. If you have connected travis with GitHub this is done automatically.
* `Install the Travis CLI`_ and run::

$ travis encrypt <your-token> --add deploy.password # When using travis.org
$ travis encrypt <your-token> --add deploy.password --com # When using travis.com

to automatically encrypt your PyPI token into your ``.travis.yml`` config.

Unfortunately, the travis cli tool appends the token outside of any build stage,
so you need to manually edit the ``.travis.yml`` config or run::

$ invoke fix-token

Now you can push the new ``.travis.yml`` to your remote repository::

$ git add .travis.yml
$ git commit -m "Add PyPI deployment token"
$ git push

* Add the repo to your ReadTheDocs_ account under ``My Projects > Import Project`` and enable the service hook
if you did not connect ReadTheDocs to your GitHub.
* If you wish to also publish your documentation on `GitHub Pages`_,
`generate a GitHub access token <https://github.com/settings/tokens>`_ for `repo:public_repo` and set this
token in your travis build settings at `<https://travis-ci.com/myusername/mypackage/settings>`_
as a secret environment variable ``GH_TOKEN``.

If you do not want to deploy to `GitHub Pages`_, remove the ``deploy pages`` build stage from ``.travis.yml``.
* Add the token you copied in the previous step as a GitHub secret with the name `PYPI_API_TOKEN` to that the action workflow can access it.

* Start coding! Add your package dependencies to your ``setup.py`` and ``Pipfile`` as you go,
and lock them into your virtual environment with::
Expand All @@ -140,11 +103,6 @@ After your project was created:
* Release new versions of your package by pushing a new tag to master::

$ bump2version (major | minor | patch)
$ git push
$ git push --tags

.. _Travis-CI: https://travis-ci.com
.. _PyPI: https://pypi.org
.. _Install the Travis CLI: https://github.com/travis-ci/travis.rb#installation
.. _ReadTheDocs: https://readthedocs.org/
.. _GitHub Pages: https://pages.github.com/
3 changes: 1 addition & 2 deletions cookiecutter.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,5 @@
"project_name": "Python Package Template",
"project_slug": "{{ cookiecutter.project_name.lower().replace(' ', '_').replace('-', '_') }}",
"pypi_username": "{{ cookiecutter.github_username }}",
"version": "0.1.0",
"travis_plan": ["com", "org"]
"version": "0.1.0"
}
3 changes: 1 addition & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,8 @@
"pytest-cookies",
"pytest-xdist",
"pytest-sugar",
"ruamel.yaml"
]
coverage_requirements = ["coverage", "codecov"]
coverage_requirements = ["coverage"]
dev_requirements = ["invoke", "pre-commit", "cookiecutter"]

setup(
Expand Down
19 changes: 19 additions & 0 deletions {{cookiecutter.project_slug}}/.github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: test

on: [push]

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
python: [3.6, 3.7, 3.8]
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python }}
- run: pip install tox wheel
- name: Test
run: tox
- uses: codecov/codecov-action@v1
12 changes: 1 addition & 11 deletions {{cookiecutter.project_slug}}/CONTRIBUTING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,6 @@ Implement Features
Look through the `GitHub issues`_ for features. Anything tagged with *"enhancement"*
and *"help wanted"* is open to whoever wants to implement it.

Write Documentation
~~~~~~~~~~~~~~~~~~~

{{ cookiecutter.project_name }} could always use more documentation, whether as part of the
official {{ cookiecutter.project_name }} docs, in docstrings, or even on the web in blog posts,
articles, and such.

Submit Feedback
~~~~~~~~~~~~~~~

Expand Down Expand Up @@ -97,10 +90,7 @@ Pull Request Guidelines
Before you submit a pull request, check that it meets these guidelines:

1. The pull request should include tests.
2. If the pull request adds functionality, the documentation (``docs/``) should be updated. Put
your new functionality into a function with a docstring and add the
feature to the list in ``README.rst``.
3. The pull request should work for python 3.5+. Check the
2. The pull request should work for python 3.5+. Check the
`build status of your pull request <https://travis-ci.{{ cookiecutter.travis_plan }}/{{ cookiecutter.github_username }}/{{ cookiecutter.project_slug }}/pull_requests>`_
and make sure that all tests pass for all supported python versions.

Expand Down
2 changes: 0 additions & 2 deletions {{cookiecutter.project_slug}}/Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@ coverage = "*"
# Tools
pre-commit = "*"
invoke = "*"
"ruamel.yaml" = "*"
m2r = "*"
twine = "*"
bump2version = "*"

[packages]
Expand Down
12 changes: 2 additions & 10 deletions {{cookiecutter.project_slug}}/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
{{ cookiecutter.project_name }}
===============================

.. image:: https://travis-ci.{{ cookiecutter.travis_plan }}/{{ cookiecutter.github_username }}/{{ cookiecutter.project_slug }}.svg?branch=master
:target: https://travis-ci.{{ cookiecutter.travis_plan }}/{{ cookiecutter.github_username }}/{{ cookiecutter.project_slug }}
.. image:: https://github.com/{{ cookiecutter.github_username }}/{{ cookiecutter.project_slug }}/workflows/test/badge.svg
:target: https://github.com/{{ cookiecutter.github_username }}/{{ cookiecutter.project_slug }}/actions
:alt: Build Status

.. image:: https://img.shields.io/pypi/v/{{ cookiecutter.project_slug }}.svg
Expand All @@ -14,10 +14,6 @@
:target: https://github.com/{{ cookiecutter.github_username }}/{{ cookiecutter.project_slug }}
:alt: License

.. image:: https://readthedocs.org/projects/{{ cookiecutter.project_slug | replace("_", "-") }}/badge/?version=latest
:target: https://{{ cookiecutter.project_slug | replace("_", "-") }}.readthedocs.io/en/latest/?badge=latest
:alt: Documentation Status

.. image:: https://codecov.io/gh/{{ cookiecutter.github_username }}/{{ cookiecutter.project_slug }}/branch/master/graph/badge.svg
:target: https://codecov.io/gh/{{ cookiecutter.github_username }}/{{ cookiecutter.project_slug }}
:alt: Test Coverage
Expand All @@ -30,10 +26,6 @@ Your short description here. `{{ cookiecutter.github_username }}.github.io/{{ co
$ pip install {{ cookiecutter.project_slug }}
See the `official documentation`_ for more information.

.. _official documentation: https://{{ cookiecutter.project_slug | replace("_", "-") }}.readthedocs.io

.. code-block:: python
import {{ cookiecutter.project_slug }}
Expand Down
8 changes: 2 additions & 6 deletions {{cookiecutter.project_slug}}/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,11 @@
"mypy",
"pyfakefs",
]
coverage_requirements = ["coverage", "codecov"]
docs_requirements = ["sphinx>=2.0", "romnn_sphinx_press_theme", "sphinxemoji"]
coverage_requirements = ["coverage"]
formatting_requirements = ["flake8", "black==19.10b0", "isort"]
tool_requirements = [
"m2r",
"twine",
"invoke",
"ruamel.yaml",
"pre-commit",
"cookiecutter",
"bump2version",
Expand All @@ -49,7 +46,6 @@
requirements
+ test_requirements
+ coverage_requirements
+ docs_requirements
+ formatting_requirements
+ tool_requirements
)
Expand Down Expand Up @@ -81,7 +77,7 @@
setup_requires=tool_requirements,
tests_require=test_requirements,
extras_require=dict(
dev=dev_requirements, docs=docs_requirements, test=test_requirements
dev=dev_requirements, test=test_requirements
),
license="MIT",
description=short_description,
Expand Down
33 changes: 1 addition & 32 deletions {{cookiecutter.project_slug}}/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,22 @@
Execute 'invoke --list' for guidance on using Invoke
"""
import shutil
from ruamel.yaml import YAML
import pprint

from invoke import task
import webbrowser
from pathlib import Path

Path().expanduser()
yaml = YAML()

ROOT_DIR = Path(__file__).parent
SETUP_FILE = ROOT_DIR.joinpath("setup.py")
TEST_DIR = ROOT_DIR.joinpath("tests")
SOURCE_DIR = ROOT_DIR.joinpath("{{ cookiecutter.project_slug }}")
TOX_DIR = ROOT_DIR.joinpath(".tox")
TRAVIS_CONFIG_FILE = ROOT_DIR.joinpath(".travis.yml")
COVERAGE_FILE = ROOT_DIR.joinpath(".coverage")
COVERAGE_DIR = ROOT_DIR.joinpath("htmlcov")
COVERAGE_REPORT = COVERAGE_DIR.joinpath("index.html")
DOCS_DIR = ROOT_DIR.joinpath("docs")
DOCS_BUILD_DIR = DOCS_DIR.joinpath("build")
DOCS_INDEX = DOCS_BUILD_DIR.joinpath("index.html")
PYTHON_DIRS = [str(d) for d in [SOURCE_DIR, TEST_DIR]]


Expand Down Expand Up @@ -83,17 +77,6 @@ def _create(d, *keys):
current = current[key]


@task(help=dict(
force="Force overriding the current travis configuration",
verify="Verify config changes by asking for the user's approval"
))
def fix_token(c, force=False, verify=True):
"""
Add the token generated by the travis cli script to the correct entry
"""
_fix_token(force=force, verify=verify)


@task
def install_hooks(c):
"""Install pre-commit hooks
Expand Down Expand Up @@ -127,20 +110,6 @@ def coverage(c, publish=False, provider="codecov"):
c.run("pipenv run coverage html -d {}".format(COVERAGE_DIR))
webbrowser.open(COVERAGE_REPORT.as_uri())


@task(help={"output": "Generated documentation output format (default is html)"})
def docs(c, output="html"):
"""Generate documentation
"""
pass

@task
def clean_docs(c):
"""Clean up files from documentation builds
"""
c.run("rm -fr {}".format(DOCS_BUILD_DIR))


@task
def clean_build(c):
"""Clean up files from package building
Expand Down Expand Up @@ -171,7 +140,7 @@ def clean_tests(c):
shutil.rmtree(COVERAGE_DIR, ignore_errors=True)


@task(pre=[clean_build, clean_python, clean_tests, clean_docs])
@task(pre=[clean_build, clean_python, clean_tests])
def clean(c):
"""Runs all clean sub-tasks
"""
Expand Down

0 comments on commit edb2367

Please sign in to comment.