Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions python/MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ recursive-include tests *.py
include HISTORY.md
include LICENSE
include testwrapper.py
recursive-exclude phonenumberslite *
1 change: 1 addition & 0 deletions python/phonenumberslite/HISTORY.md
1 change: 1 addition & 0 deletions python/phonenumberslite/LICENSE
1 change: 1 addition & 0 deletions python/phonenumberslite/MANIFEST.in
1 change: 1 addition & 0 deletions python/phonenumberslite/README.md
1 change: 1 addition & 0 deletions python/phonenumberslite/phonenumbers
44 changes: 44 additions & 0 deletions python/phonenumberslite/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
[project]
name = "phonenumberslite"

authors = [{name = "David Drysdale", email = "[email protected]"}]
classifiers = [
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Developers",
"Operating System :: OS Independent",
"Topic :: Communications :: Telephony",
"Programming Language :: Python :: 2",
"Programming Language :: Python :: 2.5",
"Programming Language :: Python :: 2.6",
"Programming Language :: Python :: 2.7",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.3",
"Programming Language :: Python :: 3.4",
"Programming Language :: Python :: 3.5",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: Implementation :: PyPy",
]
description = "Python version of Google's common library for parsing, formatting, storing and validating international phone numbers."
dynamic = ["version"]
license = "Apache-2.0"
readme = "README.md"
requires-python = ">=2.5"
urls = {homepage = "https://github.com/daviddrysdale/python-phonenumbers"}

[build-system]
requires = ["setuptools"]
build-backend = "setuptools.build_meta"

[tool.setuptools.dynamic]
version = {attr = "phonenumbers.__version__"}

[tool.setuptools.packages.find]
where = ["."]
include = ["phonenumbers", "phonenumbers.data", "phonenumbers.shortdata"]
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, if include is recursive, why doesn't the "phonenumbers" here pull in geodata etc?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right, it's not recursive.
I was fooled by the *.egg-info directory that seems to be caching some build data from previous builds. Maybe that's what caused the difference of behavior on your system.
I added rm -rf *.egg-info to the build procedure, and fixed the package detection directive to ["phonenumbers*"]

1 change: 1 addition & 0 deletions python/phonenumberslite/setup.cfg
1 change: 1 addition & 0 deletions python/phonenumberslite/setup.py
1 change: 1 addition & 0 deletions python/phonenumberslite/tests
1 change: 1 addition & 0 deletions python/phonenumberslite/testwrapper.py
44 changes: 44 additions & 0 deletions python/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
[project]
name = "phonenumbers"

authors = [{name = "David Drysdale", email = "[email protected]"}]
classifiers = [
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Developers",
"Operating System :: OS Independent",
"Topic :: Communications :: Telephony",
"Programming Language :: Python :: 2",
"Programming Language :: Python :: 2.5",
"Programming Language :: Python :: 2.6",
"Programming Language :: Python :: 2.7",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.3",
"Programming Language :: Python :: 3.4",
"Programming Language :: Python :: 3.5",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: Implementation :: PyPy",
]
description = "Python version of Google's common library for parsing, formatting, storing and validating international phone numbers."
dynamic = ["version"]
license = "Apache-2.0"
readme = "README.md"
requires-python = ">=2.5"
urls = {homepage = "https://github.com/daviddrysdale/python-phonenumbers"}

[build-system]
requires = ["setuptools"]
build-backend = "setuptools.build_meta"

[tool.setuptools.dynamic]
version = {attr = "phonenumbers.__version__"}

[tool.setuptools.packages.find]
where = ["."]
include = ["phonenumbers*"]
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This pulls in the files under phonenumbers/pb2/, which weren't previously included in the phonenumbers package.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right. I fixed the package directives to only allow the packages explicitly listed, like in the previous packaging.

81 changes: 2 additions & 79 deletions python/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,82 +15,5 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import distutils.core
import io
import sys
# Importing setuptools adds some features like "setup.py test", but
# it's optional so swallow the error if it's not there.
try:
import setuptools
except ImportError:
pass

major, minor = sys.version_info[:2]
python_25 = (major > 2 or (major == 2 and minor >= 5))
if not python_25:
raise RuntimeError("Python 2.5 or newer is required")

# Discover version of phonenumbers package
from phonenumbers import __version__

# 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

with io.open("README.md", mode="r", encoding="utf-8") as readme:
long_description = readme.read()

# Various parameters depend on whether we are the lite package or not
if lite:
pkgname = 'phonenumberslite'
pkgs = ['phonenumbers', 'phonenumbers.data', 'phonenumbers.shortdata']
else:
pkgname = 'phonenumbers'
pkgs = ['phonenumbers', 'phonenumbers.data', 'phonenumbers.geodata', 'phonenumbers.shortdata',
'phonenumbers.carrierdata', 'phonenumbers.tzdata']

distutils.core.setup(name=pkgname,
version=__version__,
description="Python version of Google's common library for parsing, formatting, storing and validating international phone numbers.",
long_description=long_description,
long_description_content_type="text/markdown",
author='David Drysdale',
author_email='[email protected]',
url='https://github.com/daviddrysdale/python-phonenumbers',
license='Apache License 2.0',
packages=pkgs,
test_suite="tests.examplenumberstest",
platforms='Posix; MacOS X; Windows',
package_data={"": ["*.pyi", "py.typed"]},
classifiers=['Development Status :: 5 - Production/Stable',
'Intended Audience :: Developers',
'License :: OSI Approved :: Apache Software License',
'Operating System :: OS Independent',
'Topic :: Communications :: Telephony',
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.5',
'Programming Language :: Python :: 2.6',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: 3.11',
'Programming Language :: Python :: 3.12',
'Programming Language :: Python :: Implementation :: CPython',
'Programming Language :: Python :: Implementation :: PyPy',
],
)
import setuptools
setuptools.setup()
9 changes: 5 additions & 4 deletions tools/python/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ Install using `setup.py`:
```console
tar xfz phonenumbers-<version>.tar.gz
cd phonenumbers-<version>
python setup.py build
sudo python setup.py install # or su first
sudo python -m pip install . # or su first
```

Running Tests
Expand Down Expand Up @@ -134,15 +133,17 @@ Release Procedure
`git tag vX.Y.Z`
- Push the tag to Github with:
`git push <github-remote> vX.Y.Z`
- Ensure you have the requirements to build:
`pip install build twine`
- Push the lite package to PyPI with:
```
cd python && rm -rf build dist && ./setup.py lite sdist bdist_wheel
cd python/phonenumberslite && rm -rf build dist phonenumberslite.egg-info && python -m build
twine check dist/*
twine upload dist/*
```
- Push the package to PyPI with:
```
cd python && rm -rf build dist && ./setup.py sdist bdist_wheel
cd python && rm -rf build dist phonenumbers.egg-info && python -m build
twine check dist/*
twine upload dist/*
```
Loading