Skip to content

Commit 5385c87

Browse files
Merge #409
409: Add package version r=alallema a=brunoocasali - Add a way to load the package version programmatically. - Change CONTRIBUTING.md and check-release scripts, since there is a new way to update the package version of the python SDK. Co-authored-by: Bruno Casali <[email protected]>
2 parents 8a70ae2 + eebf948 commit 5385c87

File tree

5 files changed

+23
-4
lines changed

5 files changed

+23
-4
lines changed

.github/scripts/check-release.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
# Checking if current tag matches the package version
44
current_tag=$(echo $GITHUB_REF | tr -d 'refs/tags/v')
5-
file_tag=$(grep 'version=' setup.py | cut -d '=' -f 2- | tr -d ' ' | tr -d '"' | tr -d ',')
5+
file_tag=$(grep '__version__ =' meilisearch/version.py | cut -d '=' -f 2- | tr -d ' ' | tr -d '"' | tr -d ',')
66
if [ "$current_tag" != "$file_tag" ]; then
77
echo "Error: the current tag does not match the version in package file(s)."
88
echo "$current_tag vs $file_tag"

CONTRIBUTING.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,10 +114,10 @@ _[Read more about this](https://github.com/meilisearch/integration-guides/blob/m
114114

115115
⚠️ Before doing anything, make sure you got through the guide about [Releasing an Integration](https://github.com/meilisearch/integration-guides/blob/main/resources/integration-release.md).
116116

117-
Make a PR modifying the file [`setup.py`](/setup.py) with the right version.
117+
Make a PR modifying the file [`meilisearch/version.py`](/meilisearch/version.py) with the right version.
118118

119119
```python
120-
version="X.X.X"
120+
__version__ = "X.X.X"
121121
```
122122

123123
Once the changes are merged on `main`, you can publish the current draft release via the [GitHub interface](https://github.com/meilisearch/meilisearch-python/releases): on this page, click on `Edit` (related to the draft release) > update the description (be sure you apply [these recommandations](https://github.com/meilisearch/integration-guides/blob/main/resources/integration-release.md#writting-the-release-description)) > when you are ready, click on `Publish release`.

meilisearch/version.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
__version__ = "0.18.0"
2+
3+
def qualified_version() -> str:
4+
"""Get the qualified version of this module."""
5+
6+
return f"Meilisearch Python (v{__version__})"

setup.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from setuptools import setup, find_packages
2+
from meilisearch.version import __version__
23

34
with open("README.md", "r", encoding="utf8") as fh:
45
long_description = fh.read()
@@ -8,7 +9,7 @@
89
"requests"
910
],
1011
name="meilisearch",
11-
version="0.18.0",
12+
version=__version__,
1213
author="Charlotte Vermandel",
1314
author_email="[email protected]",
1415
description="The python client for Meilisearch API.",

tests/client/test_version.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# pylint: disable=invalid-name
2+
3+
import re
4+
5+
from meilisearch.version import __version__, qualified_version
6+
7+
8+
def test_get_version():
9+
assert re.match(r'^(\d+\.)?(\d+\.)?(\*|\d+)$', __version__)
10+
11+
def test_get_qualified_version():
12+
assert qualified_version() == f"Meilisearch Python (v{__version__})"

0 commit comments

Comments
 (0)