diff --git a/Dockerfile_37_111 b/Dockerfile_37_111 new file mode 100644 index 0000000..e813eba --- /dev/null +++ b/Dockerfile_37_111 @@ -0,0 +1,38 @@ +FROM python:3.7-slim-bullseye AS base + +ENV PYTHONUNBUFFERED=1 \ + PYTHONDONTWRITEBYTECODE=1 \ + DEBIAN_FRONTEND=noninteractive + +WORKDIR /code + +ARG REQUIREMENTS_FILE=requirements/python3_django111/test.txt + +# Install system dependencies (native libs needed to compile Python packages) +RUN apt-get update && apt-get install -y --no-install-recommends \ + build-essential \ + libffi-dev \ + libssl-dev \ + libpq-dev \ + libjpeg-dev \ + zlib1g-dev \ + libfreetype6-dev \ + ca-certificates \ + && rm -rf /var/lib/apt/lists/* + +# Lock pip/setuptools/wheel to last Python 3.7 compatible versions +RUN pip install --no-cache-dir --upgrade \ + pip==23.2.1 \ + setuptools==68.0.0 \ + wheel==0.41.2 + +# ---------- Application layer ---------- +FROM base AS python-fitbit + +COPY requirements/ /code/requirements/ + +RUN pip install --no-cache-dir -r /code/${REQUIREMENTS_FILE} + +COPY . /code/ + +CMD ["make", "test_with_coverage"] diff --git a/Makefile b/Makefile index 262fc56..618e554 100644 --- a/Makefile +++ b/Makefile @@ -21,4 +21,10 @@ build_with_django_18: build_with_django_111: @echo "Starting Docker build..." docker build -t python-fitbit111 --build-arg REQUIREMENTS_FILE=requirements/django111/test.txt . - docker run -it --rm python-fitbit111 \ No newline at end of file + docker run -it --rm python-fitbit111 + +# Start build with django version 1.8 and python 3.7 +build_with_django_111_37: + @echo "Starting Docker build..." + docker build -f Dockerfile_37_111 -t python-fitbit111-37 --build-arg REQUIREMENTS_FILE=requirements/python3_django111/test.txt . + docker run -it --rm python-fitbit111-37 diff --git a/README.rst b/README.rst index d3ee04b..f121fed 100644 --- a/README.rst +++ b/README.rst @@ -61,4 +61,7 @@ make build_with_django_18 Build and run docker image with django 1.8 make build_with_django_111 - Build and run docker image with django 1.11 \ No newline at end of file + Build and run docker image with django 1.11 + +make build_with_django_111_37 + Build and run docker image with django 1.11 and python 3.7 diff --git a/fitbit_tests/test_gather_keys_cli.py b/fitbit_tests/test_gather_keys_cli.py index e09d1b2..0ca6753 100644 --- a/fitbit_tests/test_gather_keys_cli.py +++ b/fitbit_tests/test_gather_keys_cli.py @@ -1,14 +1,19 @@ +import sys import unittest import mock import gather_keys_cli +if sys.version_info[0] == 2: + input_patch = '__builtin__.raw_input' +else: + input_patch = 'builtins.input' class TestGatherKeysCLI(unittest.TestCase): @mock.patch('gather_keys_cli.webbrowser.open') @mock.patch('gather_keys_cli.FitbitOauthClient') - @mock.patch('__builtin__.raw_input') # Python 2.7 input + @mock.patch(input_patch) def test_gather_keys_success(self, mock_raw_input, mock_client_cls, mock_browser): """ Test successful OAuth flow in gather_keys() diff --git a/requirements/python3_django111/base.txt b/requirements/python3_django111/base.txt new file mode 100644 index 0000000..ed68e63 --- /dev/null +++ b/requirements/python3_django111/base.txt @@ -0,0 +1,2 @@ +python-dateutil>2.6 +requests-oauthlib==2.0.0 diff --git a/requirements/python3_django111/dev.txt b/requirements/python3_django111/dev.txt new file mode 100644 index 0000000..a52017d --- /dev/null +++ b/requirements/python3_django111/dev.txt @@ -0,0 +1,5 @@ +-r base.txt +-r test.txt + +cherrypy==18.10.0 +tox diff --git a/requirements/python3_django111/test.txt b/requirements/python3_django111/test.txt new file mode 100644 index 0000000..596380d --- /dev/null +++ b/requirements/python3_django111/test.txt @@ -0,0 +1,7 @@ +mock==5.2.0 +coverage==7.2.7 +Sphinx<5 +tox +requests==2.31.0 +requests-oauthlib==2.0.0 +cherrypy==18.10.0 \ No newline at end of file diff --git a/setup.py b/setup.py index af18704..822382a 100644 --- a/setup.py +++ b/setup.py @@ -1,12 +1,17 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- +import sys import re from setuptools import setup -required = [line for line in open('requirements/django18/base.txt').read().split("\n") if line != ''] -required_test = [line for line in open('requirements/django18/test.txt').read().split("\n") if not line.startswith("-r") and line != ''] +if sys.version_info[0] < 3: + required = [line for line in open('requirements/django18/base.txt').read().split("\n") if line != ''] + required_test = [line for line in open('requirements/django18/test.txt').read().split("\n") if not line.startswith("-r") and line != ''] +else: + required = [line for line in open('requirements/python3_django111/base.txt').read().split("\n") if line != ''] + required_test = [line for line in open('requirements/python3_django111/test.txt').read().split("\n") if not line.startswith("-r") and line != ''] fbinit = open('fitbit/__init__.py').read() author = re.search("__author__ = '([^']+)'", fbinit).group(1)