diff --git a/.gitattributes b/.gitattributes index fa194ec..c2f16f3 100644 --- a/.gitattributes +++ b/.gitattributes @@ -2,24 +2,29 @@ * text=auto # Known text files -*.xml text -*.yml text -*.md text -*.sh text -*.css text -*.txt text +*.css text diff=css +*.js text +*.json text +*.htm text diff=html +*.html text diff=html +*.properties text +*.sh text +*.md text +*.txt text +*.xml text +*.yml text # Known source files -*.pxd text -*.py text -*.py3 text -*.pyw text -*.pyx text +*.pxd text diff=python +*.py text diff=python +*.py3 text diff=python +*.pyw text diff=python +*.pyx text diff=python # Known binary files -*.db binary -*.p binary -*.pkl binary -*.pyc binary -*.pyd binary -*.pyo binary \ No newline at end of file +*.db binary +*.p binary +*.pkl binary +*.pyc binary +*.pyd binary +*.pyo binary \ No newline at end of file diff --git a/.travis.yml b/.travis.yml index 4406db6..eae0b73 100644 --- a/.travis.yml +++ b/.travis.yml @@ -26,7 +26,7 @@ addons: before_install: # Gets scripts - - git clone -b v1.1.3 --single-branch https://github.com/Bernardo-MG/ci-shell-scripts.git ~/.scripts + - git clone -b v1.2.0 --single-branch https://github.com/Bernardo-MG/ci-shell-scripts.git ~/.scripts # Sets scripts as executable - chmod -R +x ~/.scripts/* # Prepares CI environment diff --git a/requirements.txt b/requirements.txt index af5762f..8c83a77 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,10 +1,11 @@ # Installation and deployment -setuptools==26.1.1 -twine==1.8.1 +setuptools==38.2.5 +twine==1.9.1 # Cookiecutter -cookiecutter==1.5.1 +cookiecutter==1.6.0 # Documentation +Sphinx==1.6.5 sphinx-docs-theme==0.2.3 Pygments==2.2.0 \ No newline at end of file diff --git a/setup.py b/setup.py index 78b4683..92e44b4 100644 --- a/setup.py +++ b/setup.py @@ -27,12 +27,32 @@ def read(*names, **kwargs): ).read() -# For running tox tests class _ToxTester(test_command): + """ + Tox test command. + + Calls tox for running the tests. + """ + user_options = [ + ('test-module=', 'm', "Run 'test_suite' in specified module"), + ('test-suite=', 's', + "Run single test, case or suite (e.g. 'module.test_suite')"), + ('test-runner=', 'r', "Test runner to use"), + ('profile=', 'p', 'Test profile to use') + ] + + def initialize_options(self): + test_command.initialize_options(self) + self.profile = None + def finalize_options(self): test_command.finalize_options(self) self.test_args = [] - self.test_suite = True + + if self.profile is not None: + # Adds the profile argument + # For example: '-e=py36' + self.test_args.append('-e=' + self.profile) def run_tests(self): # import here, cause outside the eggs aren't loaded @@ -48,7 +68,7 @@ def run_tests(self): include_package_data=True, package_data={ }, - version='0.1.5', + version='0.1.6', description='Cookiecutter template for Python libraries.', author='Bernardo Martínez Garrido', author_email='programming@bernardomg.com', @@ -71,9 +91,7 @@ def run_tests(self): ], long_description=read('README.rst'), install_requires=[ - 'cookiecutter', - 'setuptools', - 'sphinx_docs_theme', + 'cookiecutter' ], tests_require=_tests_require, extras_require={'test': _tests_require}, diff --git a/tox.ini b/tox.ini index 00c27c6..af794fb 100644 --- a/tox.ini +++ b/tox.ini @@ -9,7 +9,6 @@ changedir = docs/source deps = -r{toxinidir}/requirements.txt - sphinx commands = sphinx-build -b linkcheck ./ {envtmpdir}/html sphinx-build -nW -b html -d {envtmpdir}/doctrees ./ {envtmpdir}/html \ No newline at end of file diff --git a/{{cookiecutter.package_name}}/.gitattributes b/{{cookiecutter.package_name}}/.gitattributes index fa194ec..c2f16f3 100644 --- a/{{cookiecutter.package_name}}/.gitattributes +++ b/{{cookiecutter.package_name}}/.gitattributes @@ -2,24 +2,29 @@ * text=auto # Known text files -*.xml text -*.yml text -*.md text -*.sh text -*.css text -*.txt text +*.css text diff=css +*.js text +*.json text +*.htm text diff=html +*.html text diff=html +*.properties text +*.sh text +*.md text +*.txt text +*.xml text +*.yml text # Known source files -*.pxd text -*.py text -*.py3 text -*.pyw text -*.pyx text +*.pxd text diff=python +*.py text diff=python +*.py3 text diff=python +*.pyw text diff=python +*.pyx text diff=python # Known binary files -*.db binary -*.p binary -*.pkl binary -*.pyc binary -*.pyd binary -*.pyo binary \ No newline at end of file +*.db binary +*.p binary +*.pkl binary +*.pyc binary +*.pyd binary +*.pyo binary \ No newline at end of file diff --git a/{{cookiecutter.package_name}}/.travis.yml b/{{cookiecutter.package_name}}/.travis.yml index d42d016..499e8c2 100644 --- a/{{cookiecutter.package_name}}/.travis.yml +++ b/{{cookiecutter.package_name}}/.travis.yml @@ -27,7 +27,7 @@ addons: before_install: # Gets scripts - - git clone -b v1.1.3 --single-branch https://github.com/Bernardo-MG/ci-shell-scripts.git ~/.scripts + - git clone -b v1.2.0 --single-branch https://github.com/Bernardo-MG/ci-shell-scripts.git ~/.scripts # Sets scripts as executable - chmod -R +x ~/.scripts/* # Prepares CI environment diff --git a/{{cookiecutter.package_name}}/README.rst b/{{cookiecutter.package_name}}/README.rst index e68d99d..bdc4722 100644 --- a/{{cookiecutter.package_name}}/README.rst +++ b/{{cookiecutter.package_name}}/README.rst @@ -75,11 +75,9 @@ to install it. For this use the following command; ``$ pip install {{ cookiecutter.package_name }}`` -If manual installation is required, the project includes a setup.py file, along -a makefile allowing direct installation of the library, which can be done with -the following command: +If needed, manual installation is possible: -``$ make install`` +``$ python setup.py install`` Usage ----- @@ -87,6 +85,19 @@ Usage The application has been coded in Python, and does not require any particular framework. +Testing +------- + +The tests included with the project can be run with: + +``$ python setup.py test`` + +This will delegate the execution to tox. + +It is possible to run just one of the test profiles, in this case the py36 profile: + +``$ python setup.py test -p "py36"`` + Collaborate ----------- diff --git a/{{cookiecutter.package_name}}/docs/source/usage.rst b/{{cookiecutter.package_name}}/docs/source/usage.rst index 643b547..d494e1f 100644 --- a/{{cookiecutter.package_name}}/docs/source/usage.rst +++ b/{{cookiecutter.package_name}}/docs/source/usage.rst @@ -4,4 +4,22 @@ Usage Describe here how to use the library with some general use examples. -Any detailed topic should go into it's own section. \ No newline at end of file +Any detailed topic should go into it's own section. + +------- +Testing +------- + +The tests included with the project can be run with: + +.. code:: + + $ python setup.py test + +This will delegate the execution to tox. + +It is possible to run just one of the test profiles, in this case the py36 profile: + +.. code:: + + $ python setup.py test -p "py36" \ No newline at end of file diff --git a/{{cookiecutter.package_name}}/requirements.txt b/{{cookiecutter.package_name}}/requirements.txt index d205e22..86d20cc 100644 --- a/{{cookiecutter.package_name}}/requirements.txt +++ b/{{cookiecutter.package_name}}/requirements.txt @@ -1,7 +1,11 @@ # Installation and deployment -setuptools==26.1.1 -twine==1.8.1 +setuptools==38.2.5 +twine==1.9.1 + +# Testing +tox==2.9.1 # Documentation +Sphinx==1.6.5 sphinx-docs-theme==0.2.3 -Pygments==2.1.3 \ No newline at end of file +Pygments==2.2.0 diff --git a/{{cookiecutter.package_name}}/setup.py b/{{cookiecutter.package_name}}/setup.py index 3121167..11d4d0b 100644 --- a/{{cookiecutter.package_name}}/setup.py +++ b/{{cookiecutter.package_name}}/setup.py @@ -18,6 +18,9 @@ __license__ = 'MIT' +# Source package +_source_package = '{{ cookiecutter.package_name }}' + # Regular expression for the version _version_re = re.compile(r'__version__\s+=\s+(.*)') @@ -32,8 +35,9 @@ def read(*names, **kwargs): encoding=kwargs.get('encoding', 'utf8') ).read() + # Gets the version for the source folder __init__.py file -with open('{{ cookiecutter.package_name }}/__init__.py', 'rb', +with open(_source_package + '/__init__.py', 'rb', encoding='utf-8') as f: version_lib = f.read() version_lib = _version_re.search(version_lib).group(1) @@ -41,10 +45,31 @@ def read(*names, **kwargs): class _ToxTester(test_command): + """ + Tox test command. + + Calls tox for running the tests. + """ + user_options = [ + ('test-module=', 'm', "Run 'test_suite' in specified module"), + ('test-suite=', 's', + "Run single test, case or suite (e.g. 'module.test_suite')"), + ('test-runner=', 'r', "Test runner to use"), + ('profile=', 'p', 'Test profile to use') + ] + + def initialize_options(self): + test_command.initialize_options(self) + self.profile = None + def finalize_options(self): test_command.finalize_options(self) self.test_args = [] - self.test_suite = True + + if self.profile is not None: + # Adds the profile argument + # For example: '-e=py36' + self.test_args.append('-e=' + self.profile) def run_tests(self): # import here, cause outside the eggs aren't loaded @@ -83,9 +108,6 @@ def run_tests(self): ], long_description=read('README.rst'), install_requires=[ - 'setuptools', - 'sphinx_docs_theme', - 'twine', ], tests_require=_tests_require, extras_require={'test': _tests_require}, diff --git a/{{cookiecutter.package_name}}/tox.ini b/{{cookiecutter.package_name}}/tox.ini index 5c78722..88ba973 100644 --- a/{{cookiecutter.package_name}}/tox.ini +++ b/{{cookiecutter.package_name}}/tox.ini @@ -47,7 +47,6 @@ changedir = docs/source deps = -r{toxinidir}/requirements.txt - sphinx commands = sphinx-build -b linkcheck ./ {envtmpdir}/html sphinx-build -nW -b html -d {envtmpdir}/doctrees ./ {envtmpdir}/html \ No newline at end of file