From e8e91eba8029066619c270d8be06484304f0344f Mon Sep 17 00:00:00 2001 From: Patrick Kanzler Date: Mon, 20 Jun 2016 16:26:25 +0200 Subject: [PATCH 1/2] SETUP add pyusb>=1.0 as dependency pyusb 1.0.0 is now released so it can now be regularely installed with pip --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 371c677..0fb79f1 100755 --- a/setup.py +++ b/setup.py @@ -84,7 +84,7 @@ setup( 'Topic :: Office/Business :: Financial :: Point-Of-Sale', ], install_requires=[ - 'pyusb', + 'pyusb>=1.0.0', 'Pillow>=2.0', 'qrcode>=4.0', 'pyserial', From 87438f9efae785c5025189bbeda29ddd62a14db8 Mon Sep 17 00:00:00 2001 From: Patrick Kanzler Date: Mon, 20 Jun 2016 16:41:46 +0200 Subject: [PATCH 2/2] SETUP move code to src This way we can ensure that the packaged code is tested. See https://hynek.me/articles/testing-packaging/ or https://github.com/pyca/cryptography/commit/c62a78c015cf7aeb0c05bce82ef14cd86fe0b0fc + DOC adapt doc to new structure and test doc with travis --- .travis.yml | 6 ++++++ doc/conf.py | 7 ++++++- doc/dev/contributing.rst | 2 +- setup.py | 15 +++++++++++---- {escpos => src/escpos}/__init__.py | 0 {escpos => src/escpos}/cli.py | 0 {escpos => src/escpos}/config.py | 0 {escpos => src/escpos}/constants.py | 0 {escpos => src/escpos}/escpos.py | 0 {escpos => src/escpos}/exceptions.py | 0 {escpos => src/escpos}/image.py | 0 {escpos => src/escpos}/printer.py | 0 tox.ini | 9 ++++++++- 13 files changed, 32 insertions(+), 7 deletions(-) rename {escpos => src/escpos}/__init__.py (100%) rename {escpos => src/escpos}/cli.py (100%) rename {escpos => src/escpos}/config.py (100%) rename {escpos => src/escpos}/constants.py (100%) rename {escpos => src/escpos}/escpos.py (100%) rename {escpos => src/escpos}/exceptions.py (100%) rename {escpos => src/escpos}/image.py (100%) rename {escpos => src/escpos}/printer.py (100%) diff --git a/.travis.yml b/.travis.yml index 3c2f563..e4d4f6e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,10 @@ language: python sudo: false cache: pip +addons: + apt: + packages: + - graphviz matrix: include: - python: 2.7 @@ -19,6 +23,8 @@ matrix: env: TOXENV=pypy - python: pypy3 env: TOXENV=pypy3 + - python: 2.7 + env: TOXENV=docs allow_failures: - python: 3.5-dev - python: nightly diff --git a/doc/conf.py b/doc/conf.py index fe25835..0c9568a 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -20,7 +20,7 @@ from setuptools_scm import get_version # If extensions (or modules to document with autodoc) are in another directory, # add these directories to sys.path here. If the directory is relative to the # documentation root, use os.path.abspath to make it absolute, like shown here. -sys.path.insert(0, os.path.abspath('..')) +sys.path.insert(0, os.path.abspath('../src')) root = os.path.relpath(os.path.join(os.path.dirname(__file__), '..')) # -- General configuration ------------------------------------------------ @@ -42,6 +42,11 @@ extensions = [ 'sphinx.ext.inheritance_diagram', ] +# supress warnings for external images +suppress_warnings = [ + 'image.nonlocal_uri', +] + # enable todos todo_include_todos = True diff --git a/doc/dev/contributing.rst b/doc/dev/contributing.rst index ac7b6bc..8cb3146 100644 --- a/doc/dev/contributing.rst +++ b/doc/dev/contributing.rst @@ -1 +1 @@ -.. include:: ../../CONTRIBUTING.rst +.. include:: ../../CONTRIBUTING.rst \ No newline at end of file diff --git a/setup.py b/setup.py index 0fb79f1..fcc469c 100755 --- a/setup.py +++ b/setup.py @@ -2,10 +2,18 @@ import os import sys -from setuptools import setup +from setuptools import find_packages, setup from setuptools.command.test import test as test_command +base_dir = os.path.dirname(__file__) +src_dir = os.path.join(base_dir, "src") + +# When executing the setup.py, we need to be able to import ourselves, this +# means that we need to add the src/ directory to the sys.path. +sys.path.insert(0, src_dir) + + def read(fname): """read file from same path as setup.py""" return open(os.path.join(os.path.dirname(__file__), fname)).read() @@ -58,9 +66,8 @@ setup( 'receipt,', ], platforms='any', - packages=[ - 'escpos', - ], + package_dir={"": "src"}, + packages=find_packages(where="src", exclude=["tests", "tests.*"]), package_data={'': ['COPYING']}, classifiers=[ 'Development Status :: 4 - Beta', diff --git a/escpos/__init__.py b/src/escpos/__init__.py similarity index 100% rename from escpos/__init__.py rename to src/escpos/__init__.py diff --git a/escpos/cli.py b/src/escpos/cli.py similarity index 100% rename from escpos/cli.py rename to src/escpos/cli.py diff --git a/escpos/config.py b/src/escpos/config.py similarity index 100% rename from escpos/config.py rename to src/escpos/config.py diff --git a/escpos/constants.py b/src/escpos/constants.py similarity index 100% rename from escpos/constants.py rename to src/escpos/constants.py diff --git a/escpos/escpos.py b/src/escpos/escpos.py similarity index 100% rename from escpos/escpos.py rename to src/escpos/escpos.py diff --git a/escpos/exceptions.py b/src/escpos/exceptions.py similarity index 100% rename from escpos/exceptions.py rename to src/escpos/exceptions.py diff --git a/escpos/image.py b/src/escpos/image.py similarity index 100% rename from escpos/image.py rename to src/escpos/image.py diff --git a/escpos/printer.py b/src/escpos/printer.py similarity index 100% rename from escpos/printer.py rename to src/escpos/printer.py diff --git a/tox.ini b/tox.ini index 6c1b7bc..b1dee64 100644 --- a/tox.ini +++ b/tox.ini @@ -1,8 +1,15 @@ [tox] -envlist = py27, py34, py35 +envlist = py27, py34, py35, docs [testenv] deps = nose coverage scripttest commands = nosetests --with-coverage --cover-erase --cover-branches + +[testenv:docs] +basepython = python +changedir = doc +deps = sphinx + setuptools_scm +commands = sphinx-build -W -b html -d {envtmpdir}/doctrees . {envtmpdir}/html