diff --git a/README.rst b/README.rst index a46097c..8a2c750 100644 --- a/README.rst +++ b/README.rst @@ -5,8 +5,8 @@ Cookiecutter Python Library `Cookiecutter`_ template for creating general-purpose Python libraries. While it mostly follows my personal tastes, it offers a series of good -practices which include deployment files, makefile, testing, and the use of -various free services, such as Github, Travis and Pypi. +practices which include deployment files, testing, and the use of various +free services, such as Github, Travis and Pypi. .. image:: https://img.shields.io/badge/docs-release-blue.svg :target: http://docs.bernardomg.com/cookiecutter-python-library @@ -66,10 +66,10 @@ Of course, a Python interpreter is also required. To find the valid versions check the Cookiecutter page. All other dependencies are indicated on the requirements.txt file. -These can be installed with the included makefile by using the following -command: -``$ make requirements`` +These can be installed with: + +``$ pip install --upgrade -r requirements.txt`` Installing and creating a new project ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/cookiecutter.json b/cookiecutter.json index a9752cc..f3a4b17 100644 --- a/cookiecutter.json +++ b/cookiecutter.json @@ -1,13 +1,13 @@ { - "developer_name": "Bernardo Martínez Garrido", + "developer_name": "Bernardo Mart\u00EDnez Garrido", "developer_email": "programming@bernardomg.com", "developer_url": "https://github.com/Bernardo-MG", "github_username": "Bernardo-MG", "project_name": "Python Library", "package_name": "python-library", "project_short_description": "A library for Python", - "year": "2016", - "version": "0.1.2", + "year": "2018", + "version": "0.1.0", "docs_release_url": "docs.bernardomg.com", "docs_development_url": "docs.bernardomg.com/development" } diff --git a/docs/source/conf.py b/docs/source/conf.py index 47128e2..c6f7c2b 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -80,8 +80,6 @@ ('Usage', './usage.html'), ('Tests', './tests.html'), - ('Makefile', - './makefile.html'), ('Doc site', './doc_site.html')])], } diff --git a/docs/source/doc_site.rst b/docs/source/doc_site.rst index 0c37a72..b10a7c7 100644 --- a/docs/source/doc_site.rst +++ b/docs/source/doc_site.rst @@ -3,13 +3,10 @@ Documentation site ================== The `Sphinx`_ folder contains basic files to generate a Sphinx documentation -site. Of course, Sphinx can be used to create other kinds of docs, but combined -with `ReadTheDocs`_ it is possible to have an always accessible documentation -site, which will look similar to this one. +site. There is little to add which can't be found on the Sphinx site, apart from the fact that the `Sphinx Docs Theme`_ template has been used for the UI look. -.. _ReadTheDocs: https://readthedocs.org/ .. _Sphinx: http://sphinx-doc.org/ .. _Sphinx Docs Theme: https://github.com/Bernardo-MG/sphinx-docs-theme diff --git a/docs/source/index.rst b/docs/source/index.rst index 16bb325..48f9258 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -26,7 +26,6 @@ Features acquire usage doc_site - makefile tests diff --git a/docs/source/makefile.rst b/docs/source/makefile.rst deleted file mode 100644 index f4b6589..0000000 --- a/docs/source/makefile.rst +++ /dev/null @@ -1,63 +0,0 @@ -============ -The makefile -============ - -A makefile, and an equivalent make.bat file for windows, is offered as an easy -way to control the project's flow. - -It is possible to get all the available tasks with the command: - -.. code-block:: sh - - $ make help - -But there is a small summary: - -============ =========== -Command Description -============ =========== -clean Removes all the generated and distribution files -build Creates the source distribution -install Installs the project in the local repository -requirements Installs the project requirements -register Registers the project into Pypi -deploy Deploys the project into Pypi -test Runs the tox tests suite -============ =========== - -------------- -Pypi commands -------------- - -`Pypi`_ requires access information. Otherwise the commands making use of this -service won't work. - -For this a '.pypirc' file should be on the user folder, with the following data: - -.. code-block:: text - - [distutils] - index-servers = - pypi - pypitest - - [pypi] - username: username_pypi - password: password_pypi - - [pypitest] - repository: https://testpypi.python.org/pypi - username: username_pypitest - password: password_pypitest - -Where the usernames and passwords should be changed for the correct ones. - ----------- -Deployment ----------- - -Deployment is made with `Twine`_, to make sure old versions of Python use HTTPS -when deploying. - -.. _Pypi: https://pypi.python.org -.. _Twine: https://pypi.python.org/pypi/twine diff --git a/requirements.txt b/requirements.txt index 8c83a77..b990127 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,7 @@ # Installation and deployment setuptools==38.2.5 twine==1.9.1 +bernardomg.tox-test-command==1.0.2 # Cookiecutter cookiecutter==1.6.0 diff --git a/setup.py b/setup.py index 92e44b4..e791a4a 100644 --- a/setup.py +++ b/setup.py @@ -1,11 +1,10 @@ # -*- coding: utf-8 -*- -import sys import io from os.path import dirname from os.path import join from setuptools import find_packages, setup -from setuptools.command.test import test as test_command +from bernardomg.tox_test_command import ToxTestCommand """ PyPI configuration module. @@ -27,41 +26,6 @@ def read(*names, **kwargs): ).read() -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 = [] - - 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 - import tox - - errcode = tox.cmdline(self.test_args) - sys.exit(errcode) - - setup( name='cookiecutter-python-library', packages=find_packages(), @@ -95,5 +59,5 @@ def run_tests(self): ], tests_require=_tests_require, extras_require={'test': _tests_require}, - cmdclass={'test': _ToxTester}, + cmdclass={'test': ToxTestCommand}, ) diff --git a/{{cookiecutter.package_name}}/MANIFEST.in b/{{cookiecutter.package_name}}/MANIFEST.in index 82f5a80..6043298 100644 --- a/{{cookiecutter.package_name}}/MANIFEST.in +++ b/{{cookiecutter.package_name}}/MANIFEST.in @@ -1,8 +1,6 @@ # Miscellany files include LICENSE include README.rst -include Makefile -include make.bat include tox.ini include requirements.txt include .coveragerc diff --git a/{{cookiecutter.package_name}}/Makefile b/{{cookiecutter.package_name}}/Makefile deleted file mode 100644 index 68114e6..0000000 --- a/{{cookiecutter.package_name}}/Makefile +++ /dev/null @@ -1,89 +0,0 @@ -# Makefile for the Python project -# -# It supports creating distribution files, and deploying them to Pypi and Pypitest or installing them locally -# -# A Python interpreter is required, and it should be accessible from the command line. - -# Sets the variables. - -# Sets the Python executable. -# It will be the executable for the interpreter set up for the command line. -PYTHON = python - -# Sets the distribution folder. -# It will be the 'dist' folder. -DISTDIR = dist - -# Sets the .egg file path. -# The file will be located at the project's root. -EGGDIR = {{ cookiecutter.package_name }}.egg-info - -# Sets the tox folder path. -# It will be the '.tox' folder. -TOXDIR = .tox - -# Sets the docs output folder path. -# It will be in the 'docs' folder. -DOCBUILDDIR = docs\\build - -# User-friendly check for sphinx-build -ifeq ($(shell which $(PYTHON) >/dev/null 2>&1; echo $$?), 1) -$(error The '$(PYTHON)' command was not found. Make sure you have a version of the python interpreter installed, then add the directory where it was installed to the PATH.) -endif - -.PHONY: help clean - -# Help option -# Shows the allowed commands to be received as parameters -help: - @echo "Please use 'make ' where is one of" - @echo " clean to remove the distribution folders" - @echo " build to build the distribution" - @echo " install to install the project" - @echo " requirements to install the project requirements" - @echo " register to register on pypi" - @echo " register-test to register on testpypi" - @echo " deploy to upload to pypi" - @echo " deploy-test to upload to testpypi" - @echo " test to run tests" - -# Clean option -# Removes the distribution folder and the .egg file -clean: - rm -r -f $(DISTDIR) - rm -r -f $(EGGDIR) - rm -r -f $(TOXDIR) - rm -r -f $(DOCBUILDDIR) - -# Distribution. -build: - $(PYTHON) setup.py sdist - -# Install in local libraries repository -install: - $(PYTHON) setup.py install - -# Install the project requirements -requirements: - pip install --upgrade -r requirements.txt - -# Pypi registration. -register: - $(PYTHON) setup.py register -r pypi - -# Pypitest registration. -register-test: - $(PYTHON) setup.py register -r testpypi - -# Pypi deployment. -deploy: - $(PYTHON) setup.py sdist - twine upload dist/* - -# Pypitest deployment. -deploy-test: - $(PYTHON) setup.py sdist upload -r testpypi - -# Tests suite. -test: - tox diff --git a/{{cookiecutter.package_name}}/README.rst b/{{cookiecutter.package_name}}/README.rst index bdc4722..3873f26 100644 --- a/{{cookiecutter.package_name}}/README.rst +++ b/{{cookiecutter.package_name}}/README.rst @@ -16,18 +16,16 @@ project according to a few pieces of data it will ask for. :target: https://pypi.python.org/pypi/{{ cookiecutter.package_name }} :alt: {{ cookiecutter.project_name }} Pypi package page -.. image:: https://readthedocs.org/projects/{{ cookiecutter.package_name }}/badge/?version=latest +.. image:: https://img.shields.io/badge/docs-release-blue.svg :target: http://{{ cookiecutter.docs_release_url }}/{{ cookiecutter.package_name }} :alt: {{ cookiecutter.project_name }} latest documentation Status -.. image:: https://readthedocs.org/projects/{{ cookiecutter.package_name }}/badge/?version=develop +.. image:: https://img.shields.io/badge/docs-develop-blue.svg :target: http://{{ cookiecutter.docs_development_url }}/{{ cookiecutter.package_name }} :alt: {{ cookiecutter.project_name }} development documentation Status Features -------- -By default the project comes with the following features: - - Travis configuration file - Customized setup.py module to minimize configuration, and using tox for the tests - Docs using `Sphinx`_ and the `Sphinx Docs Theme `_ @@ -63,9 +61,10 @@ The project has been tested in the following versions of the interpreter: - Pypy 3 All other dependencies are indicated on the requirements.txt file. -The included makefile can install them with the command: -``$ make requirements`` +These can be installed with: + +``$ pip install --upgrade -r requirements.txt`` Installing ~~~~~~~~~~ diff --git a/{{cookiecutter.package_name}}/make.bat b/{{cookiecutter.package_name}}/make.bat deleted file mode 100644 index 30eefb6..0000000 --- a/{{cookiecutter.package_name}}/make.bat +++ /dev/null @@ -1,169 +0,0 @@ -@ECHO OFF - -REM Makefile-like batch file for the Python project. -REM It supports creating distribution files, and deploying them to Pypi and Pypitest or installing them locally -REM -REM A Python interpreter is required, and it should be accessible from the command line. -REM This file should be run from the project's root folder. -REM -REM To deploy or register to Pypi or Pypitest a valid .pypirc file should be accessible on the default location. - -REM Sets the variables -REM Sets the Python executable. -REM It will be the executable for the interpreter set up for the command line. -if "%PYTHON%" == "" ( - set PYTHON=python -) - -REM Sets the distribution folder. -REM It will be the 'dist' folder. -if "%DISTDIR%" == "" ( - set DISTDIR=dist -) - -REM Sets the .egg file path. -REM The file will be located at the project's root. -if "%EGGDIR%" == "" ( - set EGGDIR={{ cookiecutter.package_name }}.egg-info -) - -REM Sets the tox folder path. -REM It will be the '.tox' folder. -if "%TOXDIR%" == "" ( - set TOXDIR=.tox -) - -REM Sets the docs output folder path. -REM It will be in the 'docs' folder. -if "%DOCBUILDDIR%" == "" ( - set DOCDIR="docs" - set DOCBUILDDIR="build" -) - -REM If no parameters are received, the help is shown -if "%1" == "" goto help - -REM Help option -REM Shows the allowed commands to be received as parameters -if "%1" == "help" ( - :help - echo.Please use `make ^` where ^ is one of - echo. clean to remove the distribution folders - echo. build to build the distribution - echo. install to install the project - echo. requirements to install the project requirements - echo. register to register on pypi - echo. register-test to register on pypi-test - echo. deploy to deploy to pypi - echo. deploy-test to upload to pypi-test - echo. test to run tests - goto end -) - -REM Clean option -REM Removes the distribution folder and the .egg file -if "%1" == "clean" ( - if exist %DISTDIR% ( - rd /S /Q %DISTDIR% - ) - if exist %EGGDIR% ( - rd /S /Q %EGGDIR% - ) - if exist %TOXDIR% ( - rd /S /Q %TOXDIR% - ) - if exist "%DOCDIR%/%DOCBUILDDIR%" ( - cd %DOCDIR% - rd /S /Q %DOCBUILDDIR% - cd .. - ) - goto end -) - - -REM Checks if the interpreter is available. -%PYTHON% -V> nul -if errorlevel 9009 goto missing_interpreter -goto interpreter_ok - -REM Missing interpreter. -REM The process will end and a warning will be shown. -:missing_interpreter - -echo. -echo.The '%PYTHON%' command was not found. Make sure you have a -echo.version of the python interpreter installed, then add the -echo.directory where it was installed to the PATH. -echo. -exit /b 1 - -:interpreter_ok - - -REM Distribution. -if "%1" == "build" ( - %PYTHON% setup.py sdist - if errorlevel 1 exit /b 1 - echo. - echo.Generated source distribution. It can be found in the - echo.%DISTDIR% folder. - goto end -) - -REM Install in local libraries repository. -if "%1" == "install" ( - %PYTHON% setup.py install - if errorlevel 1 exit /b 1 - echo. - echo.Installed the project into the local repository. - goto end -) - -REM Install the project requirements -if "%1" == "requirements" ( - pip install --upgrade -r requirements.txt -) - -REM Pypi registration. -if "%1" == "register" ( - %PYTHON% setup.py register -r pypi - if errorlevel 1 exit /b 1 - echo. - echo.Registered project on pypi. - goto end -) - -REM Pypitest registration. -if "%1" == "register-test" ( - %PYTHON% setup.py register -r pypitest - if errorlevel 1 exit /b 1 - echo. - echo.Registered project on pypitest. - goto end -) - -REM Pypi deployment. -if "%1" == "deploy" ( - %PYTHON% setup.py sdist - twine upload dist/* - if errorlevel 1 exit /b 1 - echo. - echo.Uploaded project to pypi. - goto end -) - -REM Pypitest deployment. -if "%1" == "deploy-test" ( - %PYTHON% setup.py sdist upload -r pypitest - if errorlevel 1 exit /b 1 - echo. - echo.Uploaded project to pypitest. - goto end -) - -REM Tests suite. -if "%1" == "test" ( - tox -) - -:end diff --git a/{{cookiecutter.package_name}}/requirements.txt b/{{cookiecutter.package_name}}/requirements.txt index 86d20cc..5e377dc 100644 --- a/{{cookiecutter.package_name}}/requirements.txt +++ b/{{cookiecutter.package_name}}/requirements.txt @@ -1,6 +1,7 @@ # Installation and deployment setuptools==38.2.5 twine==1.9.1 +bernardomg.tox-test-command==1.0.2 # Testing tox==2.9.1 diff --git a/{{cookiecutter.package_name}}/setup.py b/{{cookiecutter.package_name}}/setup.py index 11d4d0b..afe91c8 100644 --- a/{{cookiecutter.package_name}}/setup.py +++ b/{{cookiecutter.package_name}}/setup.py @@ -1,14 +1,13 @@ # -*- coding: utf-8 -*- import ast import re -import sys import io from os.path import dirname from os.path import join from codecs import open from setuptools import find_packages, setup -from setuptools.command.test import test as test_command +from bernardomg.tox_test_command import ToxTestCommand """ PyPI configuration module. @@ -19,7 +18,7 @@ __license__ = 'MIT' # Source package -_source_package = '{{ cookiecutter.package_name }}' +_source_package = '{{ cookiecutter.package_name }}/' # Regular expression for the version _version_re = re.compile(r'__version__\s+=\s+(.*)') @@ -37,48 +36,13 @@ def read(*names, **kwargs): # Gets the version for the source folder __init__.py file -with open(_source_package + '/__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) version_lib = str(ast.literal_eval(version_lib.rstrip())) -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 = [] - - 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 - import tox - - errcode = tox.cmdline(self.test_args) - sys.exit(errcode) - - setup( name='{{ cookiecutter.package_name }}', packages=find_packages(), @@ -111,5 +75,5 @@ def run_tests(self): ], tests_require=_tests_require, extras_require={'test': _tests_require}, - cmdclass={'test': _ToxTester}, + cmdclass={'test': ToxTestCommand}, )