Skip to content

Commit 6bb9e2c

Browse files
committed
Try building a phonenumbers-lite package variant
1 parent 5b58318 commit 6bb9e2c

4 files changed

Lines changed: 61 additions & 1 deletion

File tree

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,9 @@ load of metadata will not cause a pause or memory exhaustion):
192192
* Force-load the timezone metadata by invoking `import phonenumbers.timezone`.
193193
* Force-load the normal metadata by calling `phonenumbers.PhoneMetadata.load_all()`.
194194

195+
The `phonenumbers-lite` version of the package does not include the geocoding, carrier and timezone metadata,
196+
which can be useful if you have problems installing the main `phonenumbers` package due to space/memory limitations.
197+
195198
Project Layout
196199
--------------
197200
* The `python/` directory holds the Python code.

python/.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@
44
dist
55
deb_dist
66
MANIFEST
7-
phonenumbers.egg-info
7+
phonenumbers*.egg-info
88
build
99
phonenumbers.pstats

python/setup-lite.py

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
#!/usr/bin/env python
2+
3+
# Original libphonenumber Java code:
4+
# Copyright (C) 2009-2011 The Libphonenumber Authors
5+
#
6+
# Licensed under the Apache License, Version 2.0 (the "License");
7+
# you may not use this file except in compliance with the License.
8+
# You may obtain a copy of the License at
9+
#
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing, software
13+
# distributed under the License is distributed on an "AS IS" BASIS,
14+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
# See the License for the specific language governing permissions and
16+
# limitations under the License.
17+
18+
import distutils.core
19+
import sys
20+
# Importing setuptools adds some features like "setup.py test", but
21+
# it's optional so swallow the error if it's not there.
22+
try:
23+
import setuptools
24+
except ImportError:
25+
pass
26+
27+
major, minor = sys.version_info[:2]
28+
python_25 = (major > 2 or (major == 2 and minor >= 5))
29+
if not python_25:
30+
raise RuntimeError("Python 2.5 or newer is required")
31+
32+
# Discover version of phonenumbers package
33+
from phonenumbers import __version__
34+
35+
distutils.core.setup(name='phonenumbers-lite',
36+
version=__version__,
37+
description="Python version of Google's common library for parsing, formatting, storing and validating international phone numbers, without (large) per-prefix metadata for geocoding, timezones and carrier info",
38+
author='David Drysdale',
39+
author_email='dmd@lurklurk.org',
40+
url='https://github.com/daviddrysdale/python-phonenumbers',
41+
license='Apache License 2.0',
42+
packages=['phonenumbers', 'phonenumbers.data', 'phonenumbers.shortdata'],
43+
platforms='Posix; MacOS X; Windows',
44+
classifiers=['Development Status :: 4 - Beta',
45+
'Intended Audience :: Developers',
46+
'License :: OSI Approved :: Apache Software License',
47+
'Operating System :: OS Independent',
48+
'Topic :: Communications :: Telephony',
49+
],
50+
)

tools/python/README

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,11 @@ The script tools/buildprefixdata.py performs the latter 3 sets of autogeneration
4242
This approach results in a large set of Python files, but makes it easy
4343
to apply local fixes to the formatting metadata.
4444

45+
The phonenumbers-lite version of the package does not include the prefix-based
46+
metadata (in order to reduce package size), so phonenumbers.geodata,
47+
phonenumbers.carrierdata and phonenumbers.tzdata are all unavailable with this
48+
version.
49+
4550

4651
===========================
4752
Library Developer Internals
@@ -118,3 +123,5 @@ Release Procedure
118123
git push <github-remote> release-<version>
119124
- Push the package to PyPI with:
120125
cd python && setup.py sdist upload
126+
- Push the -lite package to PyPI with:
127+
cd python && setup-lite.py sdist upload

0 commit comments

Comments
 (0)