diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..65c2a65 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,17 @@ +# 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" + - "3.3" + - "3.4" + - "3.5" + - "3.6" +before_install: + - pip install -U pip setuptools +install: + - make setup_dev +script: + - make test +notifications: + email: false diff --git a/Makefile b/Makefile index e8685f0..cbef552 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,8 @@ +# 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}) all: test @@ -13,7 +17,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 diff --git a/setup.py b/setup.py old mode 100644 new mode 100755 index f39881a..088d383 --- a/setup.py +++ b/setup.py @@ -1,11 +1,24 @@ +#!/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 + 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*[\'"]([^\'"]*)[\'"]', + fd.read(), re.MULTILINE).group(1) + +if not version: + raise RuntimeError('Cannot find version information') -setup( +setuplib.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 +44,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__