Skip to content

Commit

Permalink
Use single setup.py for normal and lite packages
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
daviddrysdale committed Mar 19, 2014
1 parent 745682b commit 6686d64
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 54 deletions.
50 changes: 0 additions & 50 deletions python/setup-lite.py

This file was deleted.

29 changes: 26 additions & 3 deletions python/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,38 @@
# Discover version of phonenumbers package
from phonenumbers import __version__

distutils.core.setup(name='phonenumbers',
# Discover whether per-prefix data is available
if 'lite' in sys.argv:
lite = True
del sys.argv[sys.argv.index('lite')]
else:
lite = False
if not lite:
try:
import phonenumbers.tzdata
except ImportError:
lite = True

# Various parameters depend on whether we are the lite package or not
if lite:
pkgname = 'phonenumberslite'
pkgs = ['phonenumbers', 'phonenumbers.data', 'phonenumbers.shortdata']
pkgstatus = 'Development Status :: 4 - Beta'
lite = True
else:
pkgname = 'phonenumbers'
pkgs = ['phonenumbers', 'phonenumbers.data', 'phonenumbers.geodata', 'phonenumbers.shortdata',
'phonenumbers.carrierdata', 'phonenumbers.tzdata']
pkgstatus = 'Development Status :: 5 - Production/Stable'

distutils.core.setup(name=pkgname,
version=__version__,
description="Python version of Google's common library for parsing, formatting, storing and validating international phone numbers.",
author='David Drysdale',
author_email='[email protected]',
url='https://github.com/daviddrysdale/python-phonenumbers',
license='Apache License 2.0',
packages=['phonenumbers', 'phonenumbers.data', 'phonenumbers.geodata', 'phonenumbers.shortdata',
'phonenumbers.carrierdata', 'phonenumbers.tzdata'],
packages=pkgs,
test_suite="tests",
platforms='Posix; MacOS X; Windows',
classifiers=['Development Status :: 5 - Production/Stable',
Expand Down
2 changes: 1 addition & 1 deletion tools/python/README
Original file line number Diff line number Diff line change
Expand Up @@ -124,4 +124,4 @@ Release Procedure
- Push the package to PyPI with:
cd python && setup.py sdist upload
- Push the lite package to PyPI with:
cd python && setup-lite.py sdist upload
cd python && setup.py lite sdist upload

0 comments on commit 6686d64

Please sign in to comment.