Skip to content

Commit 8128e5d

Browse files
committed
packaging: introduce pyproject.toml
Note: phonenumberslite must now be build from python/phonenumberslite Note: the setup.py is kept for retrocompatibility, in case some script relies on `python setup.py <something-else-than-build-or-install>`
1 parent 38f2ffe commit 8128e5d

File tree

7 files changed

+97
-79
lines changed

7 files changed

+97
-79
lines changed

python/phonenumberslite/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../README.md
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../phonenumbers
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
[project]
2+
name = "phonenumberslite"
3+
4+
authors = [{name = "David Drysdale", email = "[email protected]"}]
5+
classifiers = [
6+
"Development Status :: 5 - Production/Stable",
7+
"Intended Audience :: Developers",
8+
"Operating System :: OS Independent",
9+
"Topic :: Communications :: Telephony",
10+
"Programming Language :: Python :: 2",
11+
"Programming Language :: Python :: 2.5",
12+
"Programming Language :: Python :: 2.6",
13+
"Programming Language :: Python :: 2.7",
14+
"Programming Language :: Python :: 3",
15+
"Programming Language :: Python :: 3.3",
16+
"Programming Language :: Python :: 3.4",
17+
"Programming Language :: Python :: 3.5",
18+
"Programming Language :: Python :: 3.6",
19+
"Programming Language :: Python :: 3.7",
20+
"Programming Language :: Python :: 3.8",
21+
"Programming Language :: Python :: 3.9",
22+
"Programming Language :: Python :: 3.10",
23+
"Programming Language :: Python :: 3.11",
24+
"Programming Language :: Python :: 3.12",
25+
"Programming Language :: Python :: Implementation :: CPython",
26+
"Programming Language :: Python :: Implementation :: PyPy",
27+
]
28+
description = "Python version of Google's common library for parsing, formatting, storing and validating international phone numbers."
29+
dynamic = ["version"]
30+
license = "Apache-2.0"
31+
readme = "README.md"
32+
requires-python = ">=2.5"
33+
urls = {homepage = "https://github.com/daviddrysdale/python-phonenumbers"}
34+
35+
[build-system]
36+
requires = ["setuptools"]
37+
build-backend = "setuptools.build_meta"
38+
39+
[tool.setuptools.dynamic]
40+
version = {attr = "phonenumbers.__version__"}
41+
42+
[tool.setuptools.packages.find]
43+
where = ["."]
44+
include = ["phonenumbers.data", "phonenumbers.shortdata"]

python/phonenumberslite/setup.cfg

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../setup.cfg

python/phonenumberslite/tests

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../tests

python/pyproject.toml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# TODO: handle phonenumberslite
2+
# TODO: handle python versions
3+
4+
[project]
5+
name = "phonenumbers"
6+
7+
authors = [{name = "David Drysdale", email = "[email protected]"}]
8+
classifiers = [
9+
"Development Status :: 5 - Production/Stable",
10+
"Intended Audience :: Developers",
11+
"Operating System :: OS Independent",
12+
"Topic :: Communications :: Telephony",
13+
"Programming Language :: Python :: 2",
14+
"Programming Language :: Python :: 2.5",
15+
"Programming Language :: Python :: 2.6",
16+
"Programming Language :: Python :: 2.7",
17+
"Programming Language :: Python :: 3",
18+
"Programming Language :: Python :: 3.3",
19+
"Programming Language :: Python :: 3.4",
20+
"Programming Language :: Python :: 3.5",
21+
"Programming Language :: Python :: 3.6",
22+
"Programming Language :: Python :: 3.7",
23+
"Programming Language :: Python :: 3.8",
24+
"Programming Language :: Python :: 3.9",
25+
"Programming Language :: Python :: 3.10",
26+
"Programming Language :: Python :: 3.11",
27+
"Programming Language :: Python :: 3.12",
28+
"Programming Language :: Python :: Implementation :: CPython",
29+
"Programming Language :: Python :: Implementation :: PyPy",
30+
]
31+
description = "Python version of Google's common library for parsing, formatting, storing and validating international phone numbers."
32+
dynamic = ["version"]
33+
license = "Apache-2.0"
34+
readme = "README.md"
35+
requires-python = ">=2.5"
36+
urls = {homepage = "https://github.com/daviddrysdale/python-phonenumbers"}
37+
38+
[build-system]
39+
requires = ["setuptools"]
40+
build-backend = "setuptools.build_meta"
41+
42+
[tool.setuptools.dynamic]
43+
version = {attr = "phonenumbers.__version__"}
44+
45+
[tool.setuptools.packages.find]
46+
where = ["."]
47+
include = ["phonenumbers"]

python/setup.py

Lines changed: 2 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -15,82 +15,5 @@
1515
# See the License for the specific language governing permissions and
1616
# limitations under the License.
1717

18-
import distutils.core
19-
import io
20-
import sys
21-
# Importing setuptools adds some features like "setup.py test", but
22-
# it's optional so swallow the error if it's not there.
23-
try:
24-
import setuptools
25-
except ImportError:
26-
pass
27-
28-
major, minor = sys.version_info[:2]
29-
python_25 = (major > 2 or (major == 2 and minor >= 5))
30-
if not python_25:
31-
raise RuntimeError("Python 2.5 or newer is required")
32-
33-
# Discover version of phonenumbers package
34-
from phonenumbers import __version__
35-
36-
# Discover whether per-prefix data is available
37-
if 'lite' in sys.argv:
38-
lite = True
39-
del sys.argv[sys.argv.index('lite')]
40-
else:
41-
lite = False
42-
if not lite:
43-
try:
44-
import phonenumbers.tzdata
45-
except ImportError:
46-
lite = True
47-
48-
with io.open("README.md", mode="r", encoding="utf-8") as readme:
49-
long_description = readme.read()
50-
51-
# Various parameters depend on whether we are the lite package or not
52-
if lite:
53-
pkgname = 'phonenumberslite'
54-
pkgs = ['phonenumbers', 'phonenumbers.data', 'phonenumbers.shortdata']
55-
else:
56-
pkgname = 'phonenumbers'
57-
pkgs = ['phonenumbers', 'phonenumbers.data', 'phonenumbers.geodata', 'phonenumbers.shortdata',
58-
'phonenumbers.carrierdata', 'phonenumbers.tzdata']
59-
60-
distutils.core.setup(name=pkgname,
61-
version=__version__,
62-
description="Python version of Google's common library for parsing, formatting, storing and validating international phone numbers.",
63-
long_description=long_description,
64-
long_description_content_type="text/markdown",
65-
author='David Drysdale',
66-
author_email='[email protected]',
67-
url='https://github.com/daviddrysdale/python-phonenumbers',
68-
license='Apache License 2.0',
69-
packages=pkgs,
70-
test_suite="tests.examplenumberstest",
71-
platforms='Posix; MacOS X; Windows',
72-
package_data={"": ["*.pyi", "py.typed"]},
73-
classifiers=['Development Status :: 5 - Production/Stable',
74-
'Intended Audience :: Developers',
75-
'License :: OSI Approved :: Apache Software License',
76-
'Operating System :: OS Independent',
77-
'Topic :: Communications :: Telephony',
78-
'Programming Language :: Python :: 2',
79-
'Programming Language :: Python :: 2.5',
80-
'Programming Language :: Python :: 2.6',
81-
'Programming Language :: Python :: 2.7',
82-
'Programming Language :: Python :: 3',
83-
'Programming Language :: Python :: 3.3',
84-
'Programming Language :: Python :: 3.4',
85-
'Programming Language :: Python :: 3.5',
86-
'Programming Language :: Python :: 3.6',
87-
'Programming Language :: Python :: 3.7',
88-
'Programming Language :: Python :: 3.8',
89-
'Programming Language :: Python :: 3.9',
90-
'Programming Language :: Python :: 3.10',
91-
'Programming Language :: Python :: 3.11',
92-
'Programming Language :: Python :: 3.12',
93-
'Programming Language :: Python :: Implementation :: CPython',
94-
'Programming Language :: Python :: Implementation :: PyPy',
95-
],
96-
)
18+
import setuptools
19+
setuptools.setup()

0 commit comments

Comments
 (0)