From fd08dcf4536fc719e8ccaaf6e7e6a911090478cf Mon Sep 17 00:00:00 2001 From: Chris Fournier Date: Wed, 1 Mar 2017 17:44:39 -0500 Subject: [PATCH 1/4] Add Travis CI support --- .travis.yml | 13 +++++++++++++ setup.py | 16 ++++++++++++++-- shopify_python/__init__.py | 5 +++++ tests/shopify_python/test_package.py | 7 +++++++ 4 files changed, 39 insertions(+), 2 deletions(-) create mode 100644 .travis.yml create mode 100644 tests/shopify_python/test_package.py diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..aebdd7e --- /dev/null +++ b/.travis.yml @@ -0,0 +1,13 @@ +language: python +python: + - "2.7" + - "3.3" + - "3.4" + - "3.5" + - "3.6" +install: + - make setup_dev +script: + - make test +notifications: + email: false diff --git a/setup.py b/setup.py index f39881a..3f9d040 100644 --- a/setup.py +++ b/setup.py @@ -1,11 +1,23 @@ +#!/usr/bin/env python +# Copyright (c) 2017 "Shopify inc." All rights reserved. +# Use of this source code is governed by a MIT-style license that can be found in the LICENSE file. +import re + try: from setuptools import setup except: from distutils.core import setup +with open('shopify_python/__init__.py', 'r') as fd: + version = re.search(r'^__version__\s*=\s*[\'"]([^\'"]*)[\'"]', + fd.read(), re.MULTILINE).group(1) + +if not version: + raise RuntimeError('Cannot find version information') + setup( name='shopify_python', - version='0.1', + version=version, description='Python Standards Library for Shopify', url='http://github.com/shopify/shopify_python', author='Shopify Data Acceleration', @@ -31,7 +43,7 @@ 'autopep8', 'pytest', 'pytest-randomly', - 'mypy', + 'mypy; python_version > "3.3"', ] } ) diff --git a/shopify_python/__init__.py b/shopify_python/__init__.py index e69de29..29d0584 100644 --- a/shopify_python/__init__.py +++ b/shopify_python/__init__.py @@ -0,0 +1,5 @@ +# Copyright (c) 2017 "Shopify inc." All rights reserved. +# Use of this source code is governed by a MIT-style license that can be found in the LICENSE file. +from __future__ import unicode_literals + +__version__ = '0.0.0' diff --git a/tests/shopify_python/test_package.py b/tests/shopify_python/test_package.py new file mode 100644 index 0000000..8c054a7 --- /dev/null +++ b/tests/shopify_python/test_package.py @@ -0,0 +1,7 @@ +# Copyright (c) 2017 "Shopify inc." All rights reserved. +# Use of this source code is governed by a MIT-style license that can be found in the LICENSE file. +import shopify_python + + +def test_version(): + assert shopify_python.__version__ From f6108fd54fa35314adc76b3db47cdc87c798c3ed Mon Sep 17 00:00:00 2001 From: Chris Fournier Date: Wed, 1 Mar 2017 18:13:52 -0500 Subject: [PATCH 2/4] Add conditional mypi usage --- Makefile | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index e8685f0..fd869eb 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,6 @@ python_files := find . -path '*/.*' -prune -o -name '*.py' -print0 +python_version_full := $(wordlist 2,4,$(subst ., ,$(shell python --version 2>&1))) +python_version_major := $(word 1,${python_version_full}) all: test @@ -13,7 +15,10 @@ autopep8: lint: @echo 'Linting...' @pylint --rcfile=pylintrc shopify_python tests.shopify_python - @mypy shopify_python tests/shopify_python --ignore-missing-imports + @if [ "$(python_version_major)" == "3" ]; then \ + echo 'Checking type annotations...'; \ + mypy --py2 shopify_python tests/shopify_python --ignore-missing-imports; \ + fi autolint: autopep8 lint From 09b939d0d646e7d3f054dc541067305420e8c49b Mon Sep 17 00:00:00 2001 From: Chris Fournier Date: Thu, 2 Mar 2017 08:53:48 -0500 Subject: [PATCH 3/4] Upgrade pip and setuptools --- .travis.yml | 2 ++ setup.py | 7 ++++--- 2 files changed, 6 insertions(+), 3 deletions(-) mode change 100644 => 100755 setup.py diff --git a/.travis.yml b/.travis.yml index aebdd7e..f8969f2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,6 +5,8 @@ python: - "3.4" - "3.5" - "3.6" +before_install: + - pip install -U pip setuptools install: - make setup_dev script: diff --git a/setup.py b/setup.py old mode 100644 new mode 100755 index 3f9d040..088d383 --- a/setup.py +++ b/setup.py @@ -4,9 +4,10 @@ import re try: - from setuptools import setup + import setuptools as setuplib except: - from distutils.core import setup + import distutils.core as setuplib + with open('shopify_python/__init__.py', 'r') as fd: version = re.search(r'^__version__\s*=\s*[\'"]([^\'"]*)[\'"]', @@ -15,7 +16,7 @@ if not version: raise RuntimeError('Cannot find version information') -setup( +setuplib.setup( name='shopify_python', version=version, description='Python Standards Library for Shopify', From 7ad7111c2bec935e622360cc282853e908ac867a Mon Sep 17 00:00:00 2001 From: Chris Fournier Date: Thu, 2 Mar 2017 16:08:48 -0500 Subject: [PATCH 4/4] Add copyright header --- .travis.yml | 2 ++ Makefile | 2 ++ 2 files changed, 4 insertions(+) diff --git a/.travis.yml b/.travis.yml index f8969f2..65c2a65 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,3 +1,5 @@ +# Copyright (c) 2017 "Shopify inc." All rights reserved. +# Use of this source code is governed by a MIT-style license that can be found in the LICENSE file. language: python python: - "2.7" diff --git a/Makefile b/Makefile index fd869eb..cbef552 100644 --- a/Makefile +++ b/Makefile @@ -1,3 +1,5 @@ +# Copyright (c) 2017 "Shopify inc." All rights reserved. +# Use of this source code is governed by a MIT-style license that can be found in the LICENSE file. python_files := find . -path '*/.*' -prune -o -name '*.py' -print0 python_version_full := $(wordlist 2,4,$(subst ., ,$(shell python --version 2>&1))) python_version_major := $(word 1,${python_version_full})