PYTHON-1889 Single-source the version tuple/string (#1079)

This commit is contained in:
Steven Silvester 2022-10-17 14:49:02 -05:00 committed by GitHub
parent 1c9193f226
commit 942e28170a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 46 additions and 31 deletions

View File

@ -43,18 +43,15 @@ Doing a Release
3. Add release notes to doc/changelog.rst. Generally just summarize/clarify
the git log, but you might add some more long form notes for big changes.
4. Search and replace the "devN" version number w/ the new version number (see
note above in `Versioning`_).
4. Make sure version number is updated in ``pymongo/_version.py``
5. Make sure version number is updated in setup.py and pymongo/__init__.py
5. Commit with a BUMP version_number message, eg ``git commit -m 'BUMP 3.11.0'``.
6. Commit with a BUMP version_number message, eg ``git commit -m 'BUMP 3.11.0'``.
6. Tag w/ version_number, eg, ``git tag -a '3.11.0' -m 'BUMP 3.11.0' <COMMIT>``.
7. Tag w/ version_number, eg, ``git tag -a '3.11.0' -m '3.11.0' <COMMIT>``.
7. Push commit / tag, eg ``git push && git push --tags``.
8. Push commit / tag, eg ``git push && git push --tags``.
9. Pushing a tag will trigger a release process in Evergreen which builds
8. Pushing a tag will trigger a release process in Evergreen which builds
wheels for manylinux, macOS, and Windows. Wait for the "release-combine"
task to complete and then download the "Release files all" archive. See:
https://evergreen.mongodb.com/waterfall/mongo-python-driver?bv_filter=release
@ -70,27 +67,27 @@ Doing a Release
...
pymongo-<version>.tar.gz
10. Upload all the release packages to PyPI with twine::
9. Upload all the release packages to PyPI with twine::
$ python3 -m twine upload path/to/archive/*
11. Make sure the new version appears on https://pymongo.readthedocs.io/. If the
10. Make sure the new version appears on https://pymongo.readthedocs.io/. If the
new version does not show up automatically, trigger a rebuild of "latest":
https://readthedocs.org/projects/pymongo/builds/
12. Bump the version number to <next version>.dev0 in setup.py/__init__.py,
11. Bump the version number to <next version>.dev0 in ``pymongo/_version.py``,
commit, push.
13. Publish the release version in Jira.
12. Publish the release version in Jira.
14. Announce the release on:
13. Announce the release on:
https://www.mongodb.com/community/forums/c/announcements/driver-releases/110
15. File a ticket for DOCSP highlighting changes in server version and Python
14. File a ticket for DOCSP highlighting changes in server version and Python
version compatibility or the lack thereof, for example:
https://jira.mongodb.org/browse/DOCSP-13536
16. Create a GitHub Release for the tag using
15. Create a GitHub Release for the tag using
https://github.com/mongodb/mongo-python-driver/releases/new.
The title should be "PyMongo X.Y.Z", and the description should contain
a link to the release notes on the the community forum, e.g.

View File

@ -14,7 +14,7 @@
"""Python driver for MongoDB."""
from typing import ContextManager, Optional, Tuple, Union
from typing import ContextManager, Optional
__all__ = [
"ASCENDING",
@ -84,21 +84,8 @@ TEXT = "text"
.. _text index: http://mongodb.com/docs/manual/core/index-text/
"""
version_tuple: Tuple[Union[int, str], ...] = (4, 3, 1)
def get_version_string() -> str:
if isinstance(version_tuple[-1], str):
return ".".join(map(str, version_tuple[:-1])) + version_tuple[-1]
return ".".join(map(str, version_tuple))
__version__: str = get_version_string()
version = __version__
"""Current version of PyMongo."""
from pymongo import _csot
from pymongo._version import __version__, get_version_string, version, version_tuple
from pymongo.collection import ReturnDocument
from pymongo.common import MAX_SUPPORTED_WIRE_VERSION, MIN_SUPPORTED_WIRE_VERSION
from pymongo.cursor import CursorType

28
pymongo/_version.py Normal file
View File

@ -0,0 +1,28 @@
# Copyright 2022-present MongoDB, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Current version of PyMongo."""
from typing import Tuple, Union
version_tuple: Tuple[Union[int, str], ...] = (4, 3, 1)
def get_version_string() -> str:
if isinstance(version_tuple[-1], str):
return ".".join(map(str, version_tuple[:-1])) + version_tuple[-1]
return ".".join(map(str, version_tuple))
__version__: str = get_version_string()
version = __version__

View File

@ -34,7 +34,10 @@ except ImportError:
except ImportError:
_HAVE_SPHINX = False
version = "4.3.1"
version_ns = {}
with open("pymongo/_version.py") as fp:
exec(fp.read(), version_ns)
version = version_ns["__version__"]
f = open("README.rst")
try: