Skip to content

Commit e78a91e

Browse files
authored
PYTHON-2965 Migrate to a PEP517 compliant build system (#1252)
1 parent df07641 commit e78a91e

File tree

12 files changed

+120
-192
lines changed

12 files changed

+120
-192
lines changed

.evergreen/build-mac.sh

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,8 @@ PYTHON=/Library/Frameworks/Python.framework/Versions/$VERSION/bin/python3
1414
rm -rf build
1515

1616
createvirtualenv $PYTHON releasevenv
17-
python -m pip install --upgrade wheel
18-
python -m pip install setuptools==63.2.0
19-
python setup.py bdist_wheel
17+
python -m pip install build
18+
python -m build --wheel .
2019
deactivate || true
2120
rm -rf releasevenv
2221

.evergreen/build-manylinux-internal.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ for PYTHON in /opt/python/*/bin/python; do
1616
fi
1717
# https://github.com/pypa/manylinux/issues/49
1818
rm -rf build
19-
$PYTHON setup.py bdist_wheel
19+
$PYTHON -m pip install build
20+
$PYTHON -m build --wheel .
2021
rm -rf build
2122

2223
# Audit wheels and write manylinux tag

.evergreen/build-windows.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ for VERSION in 37 38 39 310 311; do
1313
"C:/Python/32/Python${VERSION}/python.exe")
1414
for PYTHON in "${_pythons[@]}"; do
1515
rm -rf build
16-
$PYTHON setup.py bdist_wheel
16+
$PYTHON -m pip install build
17+
$PYTHON -m build --wheel .
1718

1819
# Test that each wheel is installable.
1920
for release in dist/*; do

.evergreen/config.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1121,7 +1121,8 @@ functions:
11211121
done
11221122
# Build source distribution.
11231123
cd src/
1124-
/opt/python/3.7/bin/python3 setup.py sdist
1124+
/opt/python/3.7/bin/python3 -m pip install build
1125+
/opt/python/3.7/bin/python3 -m build --sdist .
11251126
cp dist/* ../releases
11261127
- command: archive.targz_pack
11271128
params:

.evergreen/run-doctests.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33
set -o xtrace
44
set -o errexit
55

6-
${PYTHON_BINARY} setup.py clean
7-
${PYTHON_BINARY} setup.py doc -t
6+
${PYTHON_BINARY} -m pip install tox
7+
${PYTHON_BINARY} -m tox -e doc-test

README.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ Or ``easy_install`` from
7979

8080
You can also download the project source and do::
8181

82-
$ python setup.py install
82+
$ pip install .
8383

8484
Do **not** install the "bson" package from pypi. PyMongo comes with its own
8585
bson package; doing "easy_install bson" installs a third-party package that

RELEASE.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ Doing a Release
3636
To test locally, ``python3 setup.py test`` will build the C extensions and
3737
test. ``python3 tools/clean.py`` will remove the extensions,
3838
and then ``python3 setup.py --no_ext test`` will run the tests without
39-
them. You can also run the doctests: ``python3 setup.py doc -t``.
39+
them. You can also run the doctests: ``tox -e doc-test``.
4040

4141
2. Check Jira to ensure all the tickets in this version have been completed.
4242

doc/index.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,8 @@ following command from the root directory of the **PyMongo** source:
102102

103103
.. code-block:: bash
104104
105-
$ python setup.py doc
105+
$ pip install tox
106+
$ tox -e docs
106107
107108
Indices and tables
108109
------------------

doc/installation.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ latest source from GitHub and install the driver from the resulting tree::
8989

9090
$ git clone https://github.com/mongodb/mongo-python-driver.git pymongo
9191
$ cd pymongo/
92-
$ python3 setup.py install
92+
$ pip install .
9393

9494
Installing from source on Unix
9595
..............................
@@ -186,7 +186,7 @@ If you wish to install PyMongo without the C extensions, even if the
186186
extensions build properly, it can be done using a command line option to
187187
*setup.py*::
188188

189-
$ python3 setup.py --no_ext install
189+
$ NO_EXT=1 python -m pip install .
190190

191191
Installing a beta or release candidate
192192
--------------------------------------

pyproject.toml

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
[build-system]
2+
requires = ["setuptools>=63.0"]
3+
build-backend = "setuptools.build_meta"
4+
5+
[project]
6+
name = "pymongo"
7+
dynamic = ["version"]
8+
description = "Python driver for MongoDB <http://www.mongodb.org>"
9+
readme = "README.rst"
10+
license = {file="LICENSE"}
11+
requires-python = ">=3.7"
12+
authors = [
13+
{ name = "The MongoDB Python Team" },
14+
]
15+
keywords = [
16+
"bson",
17+
"gridfs",
18+
"mongo",
19+
"mongodb",
20+
"pymongo",
21+
]
22+
classifiers = [
23+
"Development Status :: 5 - Production/Stable",
24+
"Intended Audience :: Developers",
25+
"License :: OSI Approved :: Apache Software License",
26+
"Operating System :: MacOS :: MacOS X",
27+
"Operating System :: Microsoft :: Windows",
28+
"Operating System :: POSIX",
29+
"Programming Language :: Python :: Implementation :: CPython",
30+
"Programming Language :: Python :: Implementation :: PyPy",
31+
"Programming Language :: Python :: 3",
32+
"Programming Language :: Python :: 3 :: Only",
33+
"Programming Language :: Python :: 3.7",
34+
"Programming Language :: Python :: 3.8",
35+
"Programming Language :: Python :: 3.9",
36+
"Programming Language :: Python :: 3.10",
37+
"Programming Language :: Python :: 3.11",
38+
"Topic :: Database",
39+
"Typing :: Typed",
40+
]
41+
dependencies = [
42+
"dnspython>=1.16.0,<3.0.0",
43+
]
44+
45+
[project.optional-dependencies]
46+
aws = [
47+
"pymongo-auth-aws<2.0.0",
48+
]
49+
encryption = [
50+
"pymongo[aws]",
51+
"pymongocrypt>=1.6.0,<2.0.0",
52+
]
53+
gssapi = [
54+
"pykerberos;os.name!='nt'",
55+
"winkerberos>=0.5.0;os.name=='nt'"
56+
]
57+
# PyOpenSSL 17.0.0 introduced support for OCSP. 17.1.0 introduced
58+
# a related feature we need. 17.2.0 fixes a bug
59+
# in set_default_verify_paths we should really avoid.
60+
# service_identity 18.1.0 introduced support for IP addr matching.
61+
# Fallback to certifi on Windows if we can't load CA certs from the system
62+
# store and just use certifi on macOS.
63+
# https://www.pyopenssl.org/en/stable/api/ssl.html#OpenSSL.SSL.Context.set_default_verify_paths
64+
ocsp = [
65+
"certifi;os.name=='nt' or sys_platform=='darwin'",
66+
"pyopenssl>=17.2.0",
67+
"requests<3.0.0",
68+
"service_identity>=18.1.0",
69+
]
70+
snappy = [
71+
"python-snappy",
72+
]
73+
# PYTHON-3423 Removed in 4.3 but kept here to avoid pip warnings.
74+
srv = []
75+
tls = []
76+
# PYTHON-2133 Removed in 4.0 but kept here to avoid pip warnings.
77+
zstd = [
78+
"zstandard",
79+
]
80+
81+
[project.urls]
82+
Homepage = "http://github.com/mongodb/mongo-python-driver"
83+
84+
[tool.setuptools.dynamic]
85+
version = {attr = "pymongo._version.__version__"}
86+
87+
[tool.setuptools.packages.find]
88+
include = ["bson","gridfs", "pymongo"]
89+
90+
[tool.setuptools.package-data]
91+
bson=["py.typed", "*.pyi"]
92+
pymongo=["py.typed", "*.pyi"]
93+
gridfs=["py.typed", "*.pyi"]

0 commit comments

Comments
 (0)