Skip to content

Commit

Permalink
Add seed packages
Browse files Browse the repository at this point in the history
  • Loading branch information
sylhare committed Mar 8, 2020
1 parent 4916e63 commit 76ae71b
Show file tree
Hide file tree
Showing 11 changed files with 161 additions and 0 deletions.
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -127,3 +127,11 @@ dmypy.json

# Pyre type checker
.pyre/

# IDE
.idea/*

# System
.DS_Store
MANIFEST
*.pyc
11 changes: 11 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FROM python:3.6-alpine

COPY requirements.txt ./

RUN pip install -r requirements.txt

Add /src /app

WORKDIR /app

CMD ["python", "app.py"]
52 changes: 52 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
Python Seed App
===============

Inspired by `MarshalJoe <https://github.com/MarshalJoe>`__

This is a simple skeleton for a generic Python (3.6) app. It comes
loaded with:

- Project automation with
`tox <https://tox.readthedocs.io/en/latest/>`__
- Test with `pytest <https://pytest.readthedocs.io/en/latest/>`__
- Style with `pylint <https://pylint.readthedocs.io/en/latest/>`__

As well a ``.gitignore``, ``.pylintrc`` config file, and simple
directory structure employing the ``src`` pattern.

Setup
-----

Using Docker:

.. code:: bash
# build the image:
docker build -t seed-app .
# Run image:
docker run -it seed-app
Testing
-------

To find out more info about the testing configuration, check out the
``tox.ini`` file.
Use the ``dev-requirements.txt`` for libraries only used for tests or dev.

.. code:: bash
# Run the test suite
tox
# Run the linter:
tox -e lint
# Runt the coverage on the src module
pytest -e coverage
Misc Notes
----------

- Make sure and edit the package title in ``setup.py`` to reflect your
app name
- If you have issue with tox and ``ModuleNotFoundError``, try set
``recreate`` to ``True`` in ``tox.ini``.
4 changes: 4 additions & 0 deletions dev-requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
tox
pytest
pytest-cov
pylint
Empty file added requirements.txt
Empty file.
24 changes: 24 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
from setuptools import setup, find_packages

with open('README.rst') as file:
long_description = file.read()

with open('requirements.txt') as file:
requirements = file.read().split("\n")

setup(
name='python_see_app',
version='0.1',
description='',
long_description=long_description,
keywords='',
url='',
author='',
author_email='',
classifiers=[
'Development Status :: 3 - Alpha',
'Programming Language :: Python :: 3.6',
],
packages=find_packages(),
install_requires=requirements,
)
3 changes: 3 additions & 0 deletions src/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import os

ROOT_PATH = os.path.abspath(os.path.dirname(os.path.dirname(__file__)))
13 changes: 13 additions & 0 deletions src/app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
from src import ROOT_PATH


def hello():
return "Hello World!"


def root_path():
return ROOT_PATH


if __name__ == "__main__":
print(hello())
Empty file added tests/__init__.py
Empty file.
22 changes: 22 additions & 0 deletions tests/test_example.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import unittest

from src.app import hello, root_path


class ParserTest(unittest.TestCase):

def setUp(self):
print("\nSet up - Before each test")

def test_hello_world(self):
self.assertEqual("Hello World!", hello())

def test_root_path(self):
self.assertTrue("python-seed-app" in root_path())

def tearDown(self):
print("Tear Down - After each Test\n")


if __name__ == "__main__":
unittest.main()
24 changes: 24 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
[tox]
minversion = 2.0
envlist = py36
skipsdist = True

[testenv]
commands = pytest {posargs}
deps = -r requirements.txt
-r dev-requirements.txt
recreate = False
passenv = *

[testenv:coverage]
commands = pytest --cov=src tests/
deps = -r requirements.txt
-r dev-requirements.txt
recreate = True # To put to False once your requirements stops changing
passenv = *

[testenv:lint]
basepython=python3.6
deps = -r requirements.txt
-r dev-requirements.txt
commands=pylint src

0 comments on commit 76ae71b

Please sign in to comment.