From 5717d2750331cd3f1503586537c881f43a3b19ec9cb423edc6e2c8a9d0c39002 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Chv=C3=A1tal?= Date: Tue, 12 Mar 2019 09:24:25 +0000 Subject: [PATCH] - Add patch to fix 32bit builds: * faker-32bit.patch OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-Faker?expand=0&rev=19 --- faker-32bit.patch | 102 +++++++++++++++++++++++++++++++++++++++++++ python-Faker.changes | 6 +++ python-Faker.spec | 2 + 3 files changed, 110 insertions(+) create mode 100644 faker-32bit.patch diff --git a/faker-32bit.patch b/faker-32bit.patch new file mode 100644 index 0000000..e41fc4b --- /dev/null +++ b/faker-32bit.patch @@ -0,0 +1,102 @@ +From 26260b97bee18e2b1ace7cd0f450215f35fd667e Mon Sep 17 00:00:00 2001 +From: Flavio Curella <89607+fcurella@users.noreply.github.com> +Date: Mon, 11 Mar 2019 13:38:18 -0500 +Subject: [PATCH] Close #912. Skip tests on 32bit systems (#922) + +--- + .dockerignore | 16 ++++++++++++++++ + .travis.yml | 9 ++++++--- + MANIFEST.in | 3 ++- + build32bit.sh | 10 ++++++++++ + faker/providers/date_time/__init__.py | 18 ++++++++++++------ + setup.py | 4 ++-- + tests/providers/test_date_time.py | 8 ++++++++ + tox.ini | 8 ++++++-- + 8 files changed, 62 insertions(+), 14 deletions(-) + create mode 100644 .dockerignore + create mode 100755 build32bit.sh + +diff --git a/faker/providers/date_time/__init__.py b/faker/providers/date_time/__init__.py +index ed27c9f4..7158307a 100644 +--- a/faker/providers/date_time/__init__.py ++++ b/faker/providers/date_time/__init__.py +@@ -11,8 +11,8 @@ + from dateutil import relativedelta + from dateutil.tz import tzlocal, tzutc + +-from faker.utils.datetime_safe import date, datetime, real_date, real_datetime + from faker.utils import is_string ++from faker.utils.datetime_safe import date, datetime, real_date, real_datetime + + from .. import BaseProvider + +@@ -1664,11 +1664,17 @@ def date_time_between_dates( + datetime_to_timestamp(datetime_start), + datetime_to_timestamp(datetime_end), + ) +- if tzinfo is None: +- pick = datetime.fromtimestamp(timestamp, tzlocal()) +- pick = pick.astimezone(tzutc()).replace(tzinfo=None) +- else: +- pick = datetime.fromtimestamp(timestamp, tzinfo) ++ try: ++ if tzinfo is None: ++ pick = datetime.fromtimestamp(timestamp, tzlocal()) ++ pick = pick.astimezone(tzutc()).replace(tzinfo=None) ++ else: ++ pick = datetime.fromtimestamp(timestamp, tzinfo) ++ except OverflowError: ++ raise OverflowError( ++ "You specified an end date with a timestamp bigger than the maximum allowed on this" ++ " system. Please specify an earlier date.", ++ ) + return pick + + def date_between_dates(self, date_start=None, date_end=None): +diff --git a/tests/providers/test_date_time.py b/tests/providers/test_date_time.py +index 6f80ed54..67c974cb 100644 +--- a/tests/providers/test_date_time.py ++++ b/tests/providers/test_date_time.py +@@ -6,6 +6,7 @@ + import time + import unittest + import random ++import sys + + import six + +@@ -18,6 +19,10 @@ + import pytest + + ++def is64bit(): ++ return sys.maxsize > 2**32 ++ ++ + class UTC(tzinfo): + """ + UTC implementation taken from Python's docs. +@@ -225,6 +230,7 @@ def test_date_between_dates(self): + def _datetime_to_time(self, value): + return int(time.mktime(value.timetuple())) + ++ @unittest.skipUnless(is64bit(), "requires 64bit") + def test_date_time_this_period(self): + # test century + this_century_start = self._datetime_to_time( +@@ -292,6 +298,7 @@ def test_date_time_this_period(self): + self._datetime_to_time(datetime.now()) + ) + ++ @unittest.skipUnless(is64bit(), "requires 64bit") + def test_date_time_this_period_with_tzinfo(self): + # ensure all methods provide timezone aware datetimes + with pytest.raises(TypeError): +@@ -329,6 +336,7 @@ def test_date_time_this_period_with_tzinfo(self): + replace(second=0, microsecond=0) == datetime.now(utc).replace(second=0, microsecond=0) + ) + ++ @unittest.skipUnless(is64bit(), "requires 64bit") + def test_date_this_period(self): + # test century + assert self.factory.date_this_century(after_today=False) <= date.today() diff --git a/python-Faker.changes b/python-Faker.changes index 7744f4f..eb07fbe 100644 --- a/python-Faker.changes +++ b/python-Faker.changes @@ -1,3 +1,9 @@ +------------------------------------------------------------------- +Tue Mar 12 09:24:13 UTC 2019 - Tomáš Chvátal + +- Add patch to fix 32bit builds: + * faker-32bit.patch + ------------------------------------------------------------------- Sun Mar 10 10:15:00 UTC 2019 - John Vandenberg diff --git a/python-Faker.spec b/python-Faker.spec index d596e2b..779a2de 100644 --- a/python-Faker.spec +++ b/python-Faker.spec @@ -26,6 +26,7 @@ License: MIT Group: Development/Languages/Python URL: https://github.com/joke2k/faker Source: https://files.pythonhosted.org/packages/source/F/Faker/Faker-%{version}.tar.gz +Patch0: faker-32bit.patch BuildRequires: %{python_module UkPostcodeParser >= 1.1.1} BuildRequires: %{python_module email_validator >= 1.0.2} BuildRequires: %{python_module mock} @@ -67,6 +68,7 @@ testing, and data anonymization from production services. find . -name '*.py[co]' -delete # do not hardcode pytest version sed -i -e 's:"pytest>=3.8.0,<3.9":"pytest>=3.8.0":g' setup.py +%patch0 -p1 %build %python_build