Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 17, 2022
Merged
Show file tree
Hide file tree
Changes from all 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
27 changes: 12 additions & 15 deletions RELEASE.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.
Expand Down
17 changes: 2 additions & 15 deletions pymongo/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

"""Python driver for MongoDB."""

from typing import ContextManager, Optional, Tuple, Union
from typing import ContextManager, Optional

__all__ = [
"ASCENDING",
Expand Down Expand Up @@ -84,21 +84,8 @@
.. _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
Expand Down
28 changes: 28 additions & 0 deletions pymongo/_version.py
Original file line number Diff line number Diff line change
@@ -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__
5 changes: 4 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,10 @@
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:
Expand Down