closeio-phonenumbers 9.0.34.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- closeio_phonenumbers-9.0.34.1/.github/workflows/ci.yml +127 -0
- closeio_phonenumbers-9.0.34.1/.gitignore +87 -0
- closeio_phonenumbers-9.0.34.1/CMakeLists.txt +113 -0
- closeio_phonenumbers-9.0.34.1/COMPATIBILITY.md +85 -0
- closeio_phonenumbers-9.0.34.1/CONTRIBUTING.md +52 -0
- closeio_phonenumbers-9.0.34.1/LICENSE +190 -0
- closeio_phonenumbers-9.0.34.1/NOTICE +14 -0
- closeio_phonenumbers-9.0.34.1/PKG-INFO +359 -0
- closeio_phonenumbers-9.0.34.1/README.md +137 -0
- closeio_phonenumbers-9.0.34.1/SECURITY.md +13 -0
- closeio_phonenumbers-9.0.34.1/pyproject.toml +97 -0
- closeio_phonenumbers-9.0.34.1/src/native.cpp +564 -0
- closeio_phonenumbers-9.0.34.1/src/phonenumbers/__init__.py +45 -0
- closeio_phonenumbers-9.0.34.1/src/phonenumbers/_data/timezones.txt +3312 -0
- closeio_phonenumbers-9.0.34.1/src/phonenumbers/_native.pyi +52 -0
- closeio_phonenumbers-9.0.34.1/src/phonenumbers/geocoder.py +50 -0
- closeio_phonenumbers-9.0.34.1/src/phonenumbers/phonenumber.py +5 -0
- closeio_phonenumbers-9.0.34.1/src/phonenumbers/phonenumberutil.py +206 -0
- closeio_phonenumbers-9.0.34.1/src/phonenumbers/py.typed +0 -0
- closeio_phonenumbers-9.0.34.1/src/phonenumbers/timezone.py +69 -0
- closeio_phonenumbers-9.0.34.1/tests/test_core.py +248 -0
- closeio_phonenumbers-9.0.34.1/tests/test_geocoder.py +47 -0
- closeio_phonenumbers-9.0.34.1/tests/test_timezone.py +30 -0
- closeio_phonenumbers-9.0.34.1/tools/fetch_libphonenumber.py +68 -0
- closeio_phonenumbers-9.0.34.1/vendor/abseil-cpp-273292d.tar.gz +0 -0
- closeio_phonenumbers-9.0.34.1/vendor/libphonenumber-9.0.34.tar.gz +0 -0
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
name: Build and test
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
pull_request:
|
|
5
|
+
push:
|
|
6
|
+
branches: [master]
|
|
7
|
+
tags: ["v*"]
|
|
8
|
+
workflow_dispatch:
|
|
9
|
+
|
|
10
|
+
permissions:
|
|
11
|
+
contents: read
|
|
12
|
+
|
|
13
|
+
jobs:
|
|
14
|
+
lint:
|
|
15
|
+
runs-on: ubuntu-24.04
|
|
16
|
+
steps:
|
|
17
|
+
- uses: actions/checkout@v6
|
|
18
|
+
- uses: actions/setup-python@v6
|
|
19
|
+
with:
|
|
20
|
+
python-version: "3.12"
|
|
21
|
+
- run: python -m pip install mypy==2.3.0 ruff==0.15.17
|
|
22
|
+
- run: ruff check src/phonenumbers tests tools
|
|
23
|
+
- run: ruff format --check src/phonenumbers tests tools
|
|
24
|
+
- run: mypy --strict src/phonenumbers
|
|
25
|
+
|
|
26
|
+
linux-wheels:
|
|
27
|
+
name: CPython 3.${{ matrix.minor }} / Linux ${{ matrix.arch }}
|
|
28
|
+
runs-on: ubuntu-24.04
|
|
29
|
+
strategy:
|
|
30
|
+
fail-fast: false
|
|
31
|
+
matrix:
|
|
32
|
+
minor: ["12", "13", "14"]
|
|
33
|
+
arch: [x86_64, aarch64]
|
|
34
|
+
steps:
|
|
35
|
+
- uses: actions/checkout@v6
|
|
36
|
+
|
|
37
|
+
- name: Set up QEMU
|
|
38
|
+
if: matrix.arch == 'aarch64'
|
|
39
|
+
uses: docker/setup-qemu-action@v4
|
|
40
|
+
with:
|
|
41
|
+
platforms: arm64
|
|
42
|
+
|
|
43
|
+
- name: Fetch pinned libphonenumber source
|
|
44
|
+
run: python tools/fetch_libphonenumber.py
|
|
45
|
+
|
|
46
|
+
- uses: pypa/cibuildwheel@v4.1.1
|
|
47
|
+
env:
|
|
48
|
+
CIBW_ARCHS_LINUX: ${{ matrix.arch }}
|
|
49
|
+
CIBW_BUILD: cp3${{ matrix.minor }}-manylinux*
|
|
50
|
+
|
|
51
|
+
- uses: actions/upload-artifact@v7
|
|
52
|
+
with:
|
|
53
|
+
name: wheels-linux-cp3${{ matrix.minor }}-${{ matrix.arch }}
|
|
54
|
+
path: wheelhouse/*.whl
|
|
55
|
+
if-no-files-found: error
|
|
56
|
+
|
|
57
|
+
macos-wheels:
|
|
58
|
+
name: CPython 3.${{ matrix.minor }} / macOS ${{ matrix.target.arch }}
|
|
59
|
+
runs-on: ${{ matrix.target.runner }}
|
|
60
|
+
strategy:
|
|
61
|
+
fail-fast: false
|
|
62
|
+
matrix:
|
|
63
|
+
minor: ["12", "13", "14"]
|
|
64
|
+
target:
|
|
65
|
+
- arch: x86_64
|
|
66
|
+
runner: macos-15-intel
|
|
67
|
+
- arch: arm64
|
|
68
|
+
runner: macos-15
|
|
69
|
+
steps:
|
|
70
|
+
- uses: actions/checkout@v6
|
|
71
|
+
- uses: actions/setup-python@v6
|
|
72
|
+
with:
|
|
73
|
+
python-version: "3.${{ matrix.minor }}"
|
|
74
|
+
|
|
75
|
+
- name: Fetch pinned libphonenumber source
|
|
76
|
+
run: python tools/fetch_libphonenumber.py
|
|
77
|
+
|
|
78
|
+
- uses: pypa/cibuildwheel@v4.1.1
|
|
79
|
+
env:
|
|
80
|
+
CIBW_ARCHS_MACOS: ${{ matrix.target.arch }}
|
|
81
|
+
CIBW_BUILD: cp3${{ matrix.minor }}-macosx*
|
|
82
|
+
|
|
83
|
+
- uses: actions/upload-artifact@v7
|
|
84
|
+
with:
|
|
85
|
+
name: wheels-macos-cp3${{ matrix.minor }}-${{ matrix.target.arch }}
|
|
86
|
+
path: wheelhouse/*.whl
|
|
87
|
+
if-no-files-found: error
|
|
88
|
+
|
|
89
|
+
sdist:
|
|
90
|
+
runs-on: ubuntu-24.04
|
|
91
|
+
steps:
|
|
92
|
+
- uses: actions/checkout@v6
|
|
93
|
+
- uses: actions/setup-python@v6
|
|
94
|
+
with:
|
|
95
|
+
python-version: "3.12"
|
|
96
|
+
- name: Fetch pinned libphonenumber source
|
|
97
|
+
run: python tools/fetch_libphonenumber.py
|
|
98
|
+
- run: python -m pip install build
|
|
99
|
+
- run: python -m build --sdist
|
|
100
|
+
- uses: actions/upload-artifact@v7
|
|
101
|
+
with:
|
|
102
|
+
name: sdist
|
|
103
|
+
path: dist/*.tar.gz
|
|
104
|
+
if-no-files-found: error
|
|
105
|
+
|
|
106
|
+
publish:
|
|
107
|
+
if: startsWith(github.ref, 'refs/tags/v')
|
|
108
|
+
needs: [lint, linux-wheels, macos-wheels, sdist]
|
|
109
|
+
runs-on: ubuntu-24.04
|
|
110
|
+
environment: pypi
|
|
111
|
+
permissions:
|
|
112
|
+
id-token: write
|
|
113
|
+
steps:
|
|
114
|
+
- uses: actions/download-artifact@v8
|
|
115
|
+
with:
|
|
116
|
+
pattern: wheels-*
|
|
117
|
+
path: dist
|
|
118
|
+
merge-multiple: true
|
|
119
|
+
- uses: actions/download-artifact@v8
|
|
120
|
+
with:
|
|
121
|
+
name: sdist
|
|
122
|
+
path: dist
|
|
123
|
+
- name: Verify release artifacts
|
|
124
|
+
run: |
|
|
125
|
+
test -f "dist/closeio_phonenumbers-${GITHUB_REF_NAME#v}.tar.gz"
|
|
126
|
+
test "$(find dist -maxdepth 1 -name '*.whl' | wc -l)" -eq 12
|
|
127
|
+
- uses: pypa/gh-action-pypi-publish@release/v1
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
# Byte-compiled / optimized / DLL files
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*$py.class
|
|
5
|
+
|
|
6
|
+
# C extensions
|
|
7
|
+
*.so
|
|
8
|
+
*.dylib
|
|
9
|
+
*.dll
|
|
10
|
+
|
|
11
|
+
# Distribution / packaging
|
|
12
|
+
.Python
|
|
13
|
+
build/
|
|
14
|
+
develop-eggs/
|
|
15
|
+
dist/
|
|
16
|
+
downloads/
|
|
17
|
+
eggs/
|
|
18
|
+
.eggs/
|
|
19
|
+
lib/
|
|
20
|
+
lib64/
|
|
21
|
+
parts/
|
|
22
|
+
sdist/
|
|
23
|
+
var/
|
|
24
|
+
wheels/
|
|
25
|
+
wheelhouse/
|
|
26
|
+
*.egg-info/
|
|
27
|
+
.installed.cfg
|
|
28
|
+
*.egg
|
|
29
|
+
|
|
30
|
+
# Generated native sources and downloaded build inputs
|
|
31
|
+
*.c
|
|
32
|
+
vendor/*.tar.gz
|
|
33
|
+
|
|
34
|
+
# PyInstaller
|
|
35
|
+
*.manifest
|
|
36
|
+
*.spec
|
|
37
|
+
|
|
38
|
+
# Installer logs
|
|
39
|
+
pip-log.txt
|
|
40
|
+
pip-delete-this-directory.txt
|
|
41
|
+
|
|
42
|
+
# Unit test / coverage reports
|
|
43
|
+
htmlcov/
|
|
44
|
+
.tox/
|
|
45
|
+
.nox/
|
|
46
|
+
.coverage
|
|
47
|
+
.coverage.*
|
|
48
|
+
.cache
|
|
49
|
+
nosetests.xml
|
|
50
|
+
coverage.xml
|
|
51
|
+
*.cover
|
|
52
|
+
.hypothesis/
|
|
53
|
+
.pytest_cache/
|
|
54
|
+
.mypy_cache/
|
|
55
|
+
.ruff_cache/
|
|
56
|
+
|
|
57
|
+
# Environments
|
|
58
|
+
.env
|
|
59
|
+
.venv
|
|
60
|
+
env/
|
|
61
|
+
venv/
|
|
62
|
+
ENV/
|
|
63
|
+
env.bak/
|
|
64
|
+
venv.bak/
|
|
65
|
+
|
|
66
|
+
# IDE files
|
|
67
|
+
.idea/
|
|
68
|
+
.vscode/
|
|
69
|
+
*.swp
|
|
70
|
+
*.swo
|
|
71
|
+
|
|
72
|
+
# CMake
|
|
73
|
+
CMakeFiles/
|
|
74
|
+
CMakeCache.txt
|
|
75
|
+
cmake_install.cmake
|
|
76
|
+
CTestTestfile.cmake
|
|
77
|
+
Makefile
|
|
78
|
+
|
|
79
|
+
# OS specific files
|
|
80
|
+
.DS_Store
|
|
81
|
+
.DS_Store?
|
|
82
|
+
._*
|
|
83
|
+
.Spotlight-V100
|
|
84
|
+
.Trashes
|
|
85
|
+
ehthumbs.db
|
|
86
|
+
Thumbs.db
|
|
87
|
+
**/.claude/settings.local.json
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
cmake_minimum_required(VERSION 3.20)
|
|
2
|
+
project(closeio_phonenumbers LANGUAGES C CXX)
|
|
3
|
+
|
|
4
|
+
set(CMAKE_CXX_STANDARD 17)
|
|
5
|
+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|
6
|
+
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
|
7
|
+
|
|
8
|
+
find_package(Python REQUIRED COMPONENTS Interpreter Development.Module)
|
|
9
|
+
find_package(pybind11 CONFIG REQUIRED)
|
|
10
|
+
find_package(ICU 4.4 REQUIRED COMPONENTS uc i18n)
|
|
11
|
+
|
|
12
|
+
include(FetchContent)
|
|
13
|
+
if(POLICY CMP0169)
|
|
14
|
+
cmake_policy(SET CMP0169 OLD)
|
|
15
|
+
endif()
|
|
16
|
+
|
|
17
|
+
# Keep the C++ implementation and all of its embedded metadata reproducible.
|
|
18
|
+
# The Python package version starts with this upstream version.
|
|
19
|
+
set(LIBPHONENUMBER_VERSION "9.0.34")
|
|
20
|
+
set(
|
|
21
|
+
LIBPHONENUMBER_ARCHIVE
|
|
22
|
+
"${CMAKE_CURRENT_SOURCE_DIR}/vendor/libphonenumber-${LIBPHONENUMBER_VERSION}.tar.gz"
|
|
23
|
+
)
|
|
24
|
+
if(EXISTS "${LIBPHONENUMBER_ARCHIVE}")
|
|
25
|
+
set(LIBPHONENUMBER_URL "${LIBPHONENUMBER_ARCHIVE}")
|
|
26
|
+
else()
|
|
27
|
+
set(
|
|
28
|
+
LIBPHONENUMBER_URL
|
|
29
|
+
"https://codeload.github.com/google/libphonenumber/tar.gz/refs/tags/v${LIBPHONENUMBER_VERSION}"
|
|
30
|
+
)
|
|
31
|
+
endif()
|
|
32
|
+
FetchContent_Declare(
|
|
33
|
+
libphonenumber
|
|
34
|
+
URL "${LIBPHONENUMBER_URL}"
|
|
35
|
+
URL_HASH
|
|
36
|
+
"SHA256=5d2a61572110f0538fdb1afbc1f8381426fbfbbf544b45e8ae905297f2f5befa"
|
|
37
|
+
DOWNLOAD_EXTRACT_TIMESTAMP TRUE
|
|
38
|
+
SOURCE_SUBDIR cpp
|
|
39
|
+
)
|
|
40
|
+
|
|
41
|
+
# libphonenumber falls back to this exact Abseil revision. Declare it first so
|
|
42
|
+
# platforms without a packaged Abseil use a verified local archive.
|
|
43
|
+
set(ABSEIL_COMMIT "273292d1cfc0a94a65082ee350509af1d113344d")
|
|
44
|
+
set(
|
|
45
|
+
ABSEIL_ARCHIVE
|
|
46
|
+
"${CMAKE_CURRENT_SOURCE_DIR}/vendor/abseil-cpp-273292d.tar.gz"
|
|
47
|
+
)
|
|
48
|
+
if(EXISTS "${ABSEIL_ARCHIVE}")
|
|
49
|
+
set(ABSEIL_URL "${ABSEIL_ARCHIVE}")
|
|
50
|
+
else()
|
|
51
|
+
set(
|
|
52
|
+
ABSEIL_URL
|
|
53
|
+
"https://codeload.github.com/abseil/abseil-cpp/tar.gz/${ABSEIL_COMMIT}"
|
|
54
|
+
)
|
|
55
|
+
endif()
|
|
56
|
+
FetchContent_Declare(
|
|
57
|
+
abseil-cpp
|
|
58
|
+
URL "${ABSEIL_URL}"
|
|
59
|
+
URL_HASH
|
|
60
|
+
"SHA256=94aef187f688665dc299d09286bfa0d22c4ecb86a80b156dff6aabadc5a5c26d"
|
|
61
|
+
DOWNLOAD_EXTRACT_TIMESTAMP TRUE
|
|
62
|
+
)
|
|
63
|
+
|
|
64
|
+
set(BUILD_GEOCODER ON CACHE BOOL "" FORCE)
|
|
65
|
+
set(BUILD_SHARED_LIBS OFF CACHE BOOL "" FORCE)
|
|
66
|
+
set(BUILD_STATIC_LIB ON CACHE BOOL "" FORCE)
|
|
67
|
+
set(BUILD_TESTING OFF CACHE BOOL "" FORCE)
|
|
68
|
+
set(REGENERATE_METADATA OFF CACHE BOOL "" FORCE)
|
|
69
|
+
set(USE_BOOST OFF CACHE BOOL "" FORCE)
|
|
70
|
+
set(USE_ICU_REGEXP ON CACHE BOOL "" FORCE)
|
|
71
|
+
set(USE_STDMUTEX ON CACHE BOOL "" FORCE)
|
|
72
|
+
FetchContent_GetProperties(libphonenumber)
|
|
73
|
+
if(NOT libphonenumber_POPULATED)
|
|
74
|
+
FetchContent_Populate(libphonenumber)
|
|
75
|
+
endif()
|
|
76
|
+
add_subdirectory(
|
|
77
|
+
"${libphonenumber_SOURCE_DIR}/cpp"
|
|
78
|
+
"${libphonenumber_BINARY_DIR}"
|
|
79
|
+
EXCLUDE_FROM_ALL
|
|
80
|
+
)
|
|
81
|
+
# Xcode 17 diagnoses deprecated constructs in pinned upstream dependencies.
|
|
82
|
+
set(
|
|
83
|
+
LIBPHONENUMBER_APPLECLANG_OPTIONS
|
|
84
|
+
"$<$<CXX_COMPILER_ID:AppleClang>:-Wno-error=deprecated-builtins>"
|
|
85
|
+
"$<$<CXX_COMPILER_ID:AppleClang>:-Wno-error=deprecated-declarations>"
|
|
86
|
+
)
|
|
87
|
+
# GCC 14 diagnoses a false positive in AlmaLinux 8's Protobuf 3.5 headers.
|
|
88
|
+
target_compile_options(
|
|
89
|
+
phonenumber PRIVATE
|
|
90
|
+
"$<$<CXX_COMPILER_ID:GNU>:-Wno-error=array-bounds>"
|
|
91
|
+
${LIBPHONENUMBER_APPLECLANG_OPTIONS}
|
|
92
|
+
)
|
|
93
|
+
target_compile_options(
|
|
94
|
+
geocoding PRIVATE ${LIBPHONENUMBER_APPLECLANG_OPTIONS}
|
|
95
|
+
)
|
|
96
|
+
target_compile_options(
|
|
97
|
+
generate_geocoding_data PRIVATE ${LIBPHONENUMBER_APPLECLANG_OPTIONS}
|
|
98
|
+
)
|
|
99
|
+
|
|
100
|
+
pybind11_add_module(_native MODULE src/native.cpp)
|
|
101
|
+
target_include_directories(
|
|
102
|
+
_native PRIVATE
|
|
103
|
+
"${libphonenumber_SOURCE_DIR}/cpp/src"
|
|
104
|
+
"${ICU_INCLUDE_DIRS}"
|
|
105
|
+
)
|
|
106
|
+
target_compile_definitions(
|
|
107
|
+
_native PRIVATE LIBPHONENUMBER_VERSION="${LIBPHONENUMBER_VERSION}"
|
|
108
|
+
)
|
|
109
|
+
target_link_libraries(
|
|
110
|
+
_native PRIVATE geocoding phonenumber ICU::uc ICU::i18n
|
|
111
|
+
)
|
|
112
|
+
|
|
113
|
+
install(TARGETS _native LIBRARY DESTINATION phonenumbers)
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
# Compatibility
|
|
2
|
+
|
|
3
|
+
`closeio-phonenumbers` implements a focused subset of the pure-Python
|
|
4
|
+
`phonenumbers` interface. The supported API is intentionally explicit: code
|
|
5
|
+
that depends on APIs not listed here should not treat this package as a
|
|
6
|
+
drop-in replacement.
|
|
7
|
+
|
|
8
|
+
## Core API
|
|
9
|
+
|
|
10
|
+
The following names are available from the top-level `phonenumbers` package:
|
|
11
|
+
|
|
12
|
+
| Surface | Notes |
|
|
13
|
+
| --- | --- |
|
|
14
|
+
| `PhoneNumber` | Mutable number object with compatible optional-field semantics |
|
|
15
|
+
| `NumberParseException` | Includes the standard parse error codes |
|
|
16
|
+
| `PhoneNumberFormat` | `E164`, `INTERNATIONAL`, `NATIONAL`, and `RFC3966` |
|
|
17
|
+
| `PhoneNumberType` | Standard values, including `UNKNOWN == 99` |
|
|
18
|
+
| `Leniency` | Matcher leniency constants |
|
|
19
|
+
| `parse` | Supports an optional region and `keep_raw_input` |
|
|
20
|
+
| `format_number` | Formats parsed numbers using `PhoneNumberFormat` |
|
|
21
|
+
| `is_possible_number` | Checks whether a number has a possible shape |
|
|
22
|
+
| `is_valid_number` | Validates a number against libphonenumber metadata |
|
|
23
|
+
| `is_valid_number_for_region` | Validates a number for a specific region |
|
|
24
|
+
| `number_type` | Returns a `PhoneNumberType` value |
|
|
25
|
+
| `is_number_type_geographical` | Checks whether a type is geographical |
|
|
26
|
+
| `region_code_for_number` | Returns a region code or `None` |
|
|
27
|
+
| `region_code_for_country_code` | Returns the primary region for a country code |
|
|
28
|
+
| `country_code_for_region` | Returns the calling code for a region |
|
|
29
|
+
| `national_significant_number` | Returns the national significant number as text |
|
|
30
|
+
| `PhoneNumberMatcher` | Iterates over numbers found in text |
|
|
31
|
+
| `PhoneNumberMatch` | Exposes match offsets, text, and the parsed number |
|
|
32
|
+
|
|
33
|
+
`PhoneNumberMatcher` reports Python character offsets, including when text
|
|
34
|
+
before a match contains multibyte Unicode characters.
|
|
35
|
+
|
|
36
|
+
## Geocoder
|
|
37
|
+
|
|
38
|
+
The `phonenumbers.geocoder` module provides:
|
|
39
|
+
|
|
40
|
+
- `description_for_number`
|
|
41
|
+
- `description_for_valid_number`
|
|
42
|
+
- `country_name_for_number`
|
|
43
|
+
|
|
44
|
+
Descriptions are resolved offline using metadata compiled from the pinned
|
|
45
|
+
libphonenumber release. The geocoder is loaded only when imported.
|
|
46
|
+
|
|
47
|
+
## Timezone lookup
|
|
48
|
+
|
|
49
|
+
The `phonenumbers.timezone` module provides:
|
|
50
|
+
|
|
51
|
+
- `UNKNOWN_TIMEZONE`
|
|
52
|
+
- `time_zones_for_number`
|
|
53
|
+
- `time_zones_for_geographical_number`
|
|
54
|
+
|
|
55
|
+
The C++ library does not expose the phone-prefix timezone mapper, so this
|
|
56
|
+
module uses the timezone map from the pinned libphonenumber release. The map
|
|
57
|
+
is parsed lazily on first use.
|
|
58
|
+
|
|
59
|
+
## Unsupported APIs
|
|
60
|
+
|
|
61
|
+
APIs outside the tables above are not currently provided. Notable omissions
|
|
62
|
+
include:
|
|
63
|
+
|
|
64
|
+
- carrier-name lookup
|
|
65
|
+
- short-number metadata and validation
|
|
66
|
+
- `AsYouTypeFormatter`
|
|
67
|
+
- example-number and general metadata queries
|
|
68
|
+
- alternate formatting data
|
|
69
|
+
- immutable `FrozenPhoneNumber` objects
|
|
70
|
+
- the complete set of matching and comparison helpers
|
|
71
|
+
|
|
72
|
+
Import the API you need in a compatibility test before replacing the
|
|
73
|
+
pure-Python distribution in an existing project.
|
|
74
|
+
|
|
75
|
+
## Supported platforms
|
|
76
|
+
|
|
77
|
+
Published artifacts target:
|
|
78
|
+
|
|
79
|
+
| Python | Operating system | Architectures |
|
|
80
|
+
| --- | --- | --- |
|
|
81
|
+
| CPython 3.12–3.14 | Linux (manylinux 2.28+) | x86-64, ARM64 |
|
|
82
|
+
| CPython 3.12–3.14 | macOS 15+ | x86-64, Apple Silicon |
|
|
83
|
+
|
|
84
|
+
Other Python versions, operating systems, and architectures are unsupported
|
|
85
|
+
unless built from source and validated independently.
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# Contributing
|
|
2
|
+
|
|
3
|
+
Contributions are welcome. Please open an issue before implementing a large
|
|
4
|
+
API addition so its compatibility requirements and metadata cost can be
|
|
5
|
+
understood first.
|
|
6
|
+
|
|
7
|
+
## Development setup
|
|
8
|
+
|
|
9
|
+
Follow the source-build instructions in [README.md](README.md) to install the
|
|
10
|
+
native build dependencies and fetch the pinned source archives. Install the
|
|
11
|
+
development tools with:
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
python -m pip install -e ".[dev]"
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Run the local checks before submitting a change:
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
ruff check src/phonenumbers tests tools
|
|
21
|
+
ruff format --check src/phonenumbers tests tools
|
|
22
|
+
mypy --strict src/phonenumbers
|
|
23
|
+
pytest
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Changes to C++ bindings, build configuration, or packaged data should also be
|
|
27
|
+
verified by building and installing a wheel. CI builds and tests every
|
|
28
|
+
supported wheel target.
|
|
29
|
+
|
|
30
|
+
## Compatibility changes
|
|
31
|
+
|
|
32
|
+
New public APIs should include tests for both ordinary behavior and Python
|
|
33
|
+
semantics such as exceptions, optional fields, equality, and return types.
|
|
34
|
+
Update [COMPATIBILITY.md](COMPATIBILITY.md) whenever the supported surface
|
|
35
|
+
changes.
|
|
36
|
+
|
|
37
|
+
## Updating libphonenumber
|
|
38
|
+
|
|
39
|
+
For a new upstream release:
|
|
40
|
+
|
|
41
|
+
1. Update the libphonenumber version and SHA-256 in `CMakeLists.txt` and
|
|
42
|
+
`tools/fetch_libphonenumber.py`.
|
|
43
|
+
2. Check whether libphonenumber changed its Abseil revision and update its
|
|
44
|
+
commit and SHA-256 if needed.
|
|
45
|
+
3. Replace `src/phonenumbers/_data/timezones.txt` with the matching upstream
|
|
46
|
+
`resources/timezones/map_data.txt`.
|
|
47
|
+
4. Update the source archives listed in `pyproject.toml`.
|
|
48
|
+
5. Set the package version to `<upstream version>.1` and review metadata
|
|
49
|
+
changes with focused tests.
|
|
50
|
+
|
|
51
|
+
By submitting a contribution, you agree that it is licensed under the Apache
|
|
52
|
+
License 2.0.
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
Copyright 2023 The Authors
|
|
179
|
+
|
|
180
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
181
|
+
you may not use this file except in compliance with the License.
|
|
182
|
+
You may obtain a copy of the License at
|
|
183
|
+
|
|
184
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
185
|
+
|
|
186
|
+
Unless required by applicable law or agreed to in writing, software
|
|
187
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
188
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
189
|
+
See the License for the specific language governing permissions and
|
|
190
|
+
limitations under the License.
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
closeio-phonenumbers
|
|
2
|
+
Copyright 2023-2026 The Authors
|
|
3
|
+
|
|
4
|
+
This product includes software developed by the libphonenumber project
|
|
5
|
+
(https://github.com/google/libphonenumber) and the Abseil project
|
|
6
|
+
(https://github.com/abseil/abseil-cpp), both licensed under the Apache License
|
|
7
|
+
2.0.
|
|
8
|
+
|
|
9
|
+
The packaged phone-number, geocoding, and timezone metadata is derived from
|
|
10
|
+
Google's libphonenumber project.
|
|
11
|
+
|
|
12
|
+
Binary distributions may include ICU (https://icu.unicode.org/) and Protocol
|
|
13
|
+
Buffers (https://github.com/protocolbuffers/protobuf). Their respective
|
|
14
|
+
copyright and license terms continue to apply.
|