Skip to content

Commit 6686d64

Browse files
committed
Use single setup.py for normal and lite packages
At package generation time, add a 'lite' command line option that forces the light version of the package. At installation time, use absence of phonenumbers/tzdata to indicate light version being installed. This is somewhat experimental; dynamically messing with setup processing may well have unexpected side effects.
1 parent 745682b commit 6686d64

3 files changed

Lines changed: 27 additions & 54 deletions

File tree

python/setup-lite.py

Lines changed: 0 additions & 50 deletions
This file was deleted.

python/setup.py

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,38 @@
3232
# Discover version of phonenumbers package
3333
from phonenumbers import __version__
3434

35-
distutils.core.setup(name='phonenumbers',
35+
# Discover whether per-prefix data is available
36+
if 'lite' in sys.argv:
37+
lite = True
38+
del sys.argv[sys.argv.index('lite')]
39+
else:
40+
lite = False
41+
if not lite:
42+
try:
43+
import phonenumbers.tzdata
44+
except ImportError:
45+
lite = True
46+
47+
# Various parameters depend on whether we are the lite package or not
48+
if lite:
49+
pkgname = 'phonenumberslite'
50+
pkgs = ['phonenumbers', 'phonenumbers.data', 'phonenumbers.shortdata']
51+
pkgstatus = 'Development Status :: 4 - Beta'
52+
lite = True
53+
else:
54+
pkgname = 'phonenumbers'
55+
pkgs = ['phonenumbers', 'phonenumbers.data', 'phonenumbers.geodata', 'phonenumbers.shortdata',
56+
'phonenumbers.carrierdata', 'phonenumbers.tzdata']
57+
pkgstatus = 'Development Status :: 5 - Production/Stable'
58+
59+
distutils.core.setup(name=pkgname,
3660
version=__version__,
3761
description="Python version of Google's common library for parsing, formatting, storing and validating international phone numbers.",
3862
author='David Drysdale',
3963
author_email='dmd@lurklurk.org',
4064
url='https://github.com/daviddrysdale/python-phonenumbers',
4165
license='Apache License 2.0',
42-
packages=['phonenumbers', 'phonenumbers.data', 'phonenumbers.geodata', 'phonenumbers.shortdata',
43-
'phonenumbers.carrierdata', 'phonenumbers.tzdata'],
66+
packages=pkgs,
4467
test_suite="tests",
4568
platforms='Posix; MacOS X; Windows',
4669
classifiers=['Development Status :: 5 - Production/Stable',

tools/python/README

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,4 +124,4 @@ Release Procedure
124124
- Push the package to PyPI with:
125125
cd python && setup.py sdist upload
126126
- Push the lite package to PyPI with:
127-
cd python && setup-lite.py sdist upload
127+
cd python && setup.py lite sdist upload

0 commit comments

Comments
 (0)