diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..eea8121 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/pycountry-18.12.8.tar.gz diff --git a/00-use_system_iso-codes.patch b/00-use_system_iso-codes.patch new file mode 100644 index 0000000..23de9a7 --- /dev/null +++ b/00-use_system_iso-codes.patch @@ -0,0 +1,51 @@ +# HG changeset patch +# User David Paleino +# Date 1544770987 18000 +# Fri Dec 14 02:03:07 2018 -0500 +# Node ID a3985a161774c2edc1a971e855c95bba2b659bc9 +# Parent dbc5a081e509a0f099449d8e2367ea4826b20f76 +Use system iso-codes. + +diff --git a/src/pycountry/__init__.py b/src/pycountry/__init__.py +--- a/src/pycountry/__init__.py ++++ b/src/pycountry/__init__.py +@@ -12,8 +12,8 @@ except ImportError: + return os.path.join(os.path.dirname(__file__), resource_name) + + +-LOCALES_DIR = resource_filename('pycountry', 'locales') +-DATABASE_DIR = resource_filename('pycountry', 'databases') ++LOCALES_DIR = '/usr/share/locale' ++DATABASE_DIR = '/usr/share/iso-codes/json' + + + class ExistingCountries(pycountry.db.Database): +@@ -109,10 +109,10 @@ class Subdivisions(pycountry.db.Database + return subdivisions + + +-countries = ExistingCountries(os.path.join(DATABASE_DIR, 'iso3166-1.json')) ++countries = ExistingCountries(os.path.join(DATABASE_DIR, 'iso_3166-1.json')) + historic_countries = HistoricCountries( +- os.path.join(DATABASE_DIR, 'iso3166-3.json')) +-scripts = Scripts(os.path.join(DATABASE_DIR, 'iso15924.json')) +-currencies = Currencies(os.path.join(DATABASE_DIR, 'iso4217.json')) +-languages = Languages(os.path.join(DATABASE_DIR, 'iso639-3.json')) +-subdivisions = Subdivisions(os.path.join(DATABASE_DIR, 'iso3166-2.json')) ++ os.path.join(DATABASE_DIR, 'iso_3166-3.json')) ++scripts = Scripts(os.path.join(DATABASE_DIR, 'iso_15924.json')) ++currencies = Currencies(os.path.join(DATABASE_DIR, 'iso_4217.json')) ++languages = Languages(os.path.join(DATABASE_DIR, 'iso_639-3.json')) ++subdivisions = Subdivisions(os.path.join(DATABASE_DIR, 'iso_3166-2.json')) +diff --git a/src/pycountry/tests/test_general.py b/src/pycountry/tests/test_general.py +--- a/src/pycountry/tests/test_general.py ++++ b/src/pycountry/tests/test_general.py +@@ -89,7 +89,7 @@ def test_languages(): + + def test_locales(): + german = gettext.translation( +- 'iso3166', pycountry.LOCALES_DIR, languages=['de']) ++ 'iso_3166', pycountry.LOCALES_DIR, languages=['de']) + german.install() + assert __builtins__['_']('Germany') == 'Deutschland' + diff --git a/python-pycountry.spec b/python-pycountry.spec new file mode 100644 index 0000000..fe4a41c --- /dev/null +++ b/python-pycountry.spec @@ -0,0 +1,79 @@ +%global srcname pycountry + +Name: python-%{srcname} +Version: 18.12.8 +Release: 1%{?dist} +Summary: ISO country, subdivision, language, currency and script definitions and their translations + +License: LGPLv2 +URL: https://bitbucket.org/flyingcircus/pycountry +Source0: %pypi_source +# Rebased from Debian: +Patch0001: 00-use_system_iso-codes.patch + +BuildArch: noarch + +BuildRequires: iso-codes >= 4.1 +BuildRequires: python3-devel +BuildRequires: python3dist(setuptools) +BuildRequires: python3dist(pytest) + +%description +pycountry provides the ISO databases for the standards: +* 639-3 Languages +* 3166 Countries +* 3166-3 Deleted countries +* 3166-2 Subdivisions of countries +* 4217 Currencies +* 15924 Scripts + + +%package -n python3-%{srcname} +Summary: %{summary} +%{?python_provide:%python_provide python3-%{srcname}} + +Requires: iso-codes >= 4.1 + +%description -n python3-%{srcname} +pycountry provides the ISO databases for the standards: +* 639-3 Languages +* 3166 Countries +* 3166-3 Deleted countries +* 3166-2 Subdivisions of countries +* 4217 Currencies +* 15924 Scripts + + +%prep +%autosetup -n %{srcname}-%{version} -p1 + +# Remove bundled egg-info +rm -rf src/%{srcname}.egg-info + +# Remove bundled iso-codes data +rm -rf src/%{srcname}/{databases,locales} + + +%build +%py3_build + + +%install +%py3_install + + +%check +PYTHONPATH=%{buildroot}%{python3_sitelib} PYTHONDONTWRITEBYTECODE=1 \ + %{__python3} -m pytest --pyargs pycountry + + +%files -n python3-%{srcname} +%doc README HISTORY.txt +%license LICENSE.txt +%{python3_sitelib}/%{srcname} +%{python3_sitelib}/%{srcname}-%{version}-py?.?.egg-info + + +%changelog +* Thu Dec 13 2018 Elliott Sales de Andrade - 18.12.8-1 +- Initial package. diff --git a/sources b/sources new file mode 100644 index 0000000..30c4d82 --- /dev/null +++ b/sources @@ -0,0 +1 @@ +SHA512 (pycountry-18.12.8.tar.gz) = 9797688ada8ea54c1a56a2cf4d0ad765001816c822c40077953fa71e3af285114c4b5beaf739a24432b9c6ea794952ce347a40ae0bcd9a2c00d12ddc7b45261e