Skip to content

Commit

Permalink
Add __version__ attribute so Mesop users can easily tell which versio…
Browse files Browse the repository at this point in the history
…n of Mesop they're using (#112)
  • Loading branch information
wwwillchen authored Apr 13, 2024
1 parent 11c8d36 commit f6c81e4
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 3 deletions.
2 changes: 1 addition & 1 deletion docs/internal/publishing.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Follow these instructions for releasing a new version of Mesop publicly via PyPI

## Bump the version

Update `mesop/pip_package/setup.py` version field to the next version.
Update `mesop/version.py` by incrementing the version number. We follow semver.

## Install locally

Expand Down
1 change: 1 addition & 0 deletions mesop/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ py_library(
],
visibility = ["//build_defs:mesop_users"],
deps = [
"//mesop/pip_package:version",
# REF(//scripts/scaffold_component.py):insert_component_import
"//mesop/components/table:py",
"//mesop/components/sidenav:py",
Expand Down
3 changes: 3 additions & 0 deletions mesop/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,13 @@
)
from mesop.features import page as page
from mesop.key import Key as Key
from mesop.pip_package.version import VERSION
from mesop.runtime import runtime
from mesop.server.colab_run import colab_run as colab_run
from mesop.server.wsgi_app import wsgi_app

__version__ = VERSION


class _WsgiAppModule(types.ModuleType):
def __call__(
Expand Down
7 changes: 7 additions & 0 deletions mesop/pip_package/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ package(

licenses(["notice"])

py_library(
name = "version",
srcs = ["version.py"],
visibility = ["//build_defs:mesop_internal"],
)

sh_binary(
name = "build_pip_package",
srcs = ["build_pip_package.sh"],
Expand All @@ -19,6 +25,7 @@ sh_binary(
"requirements.txt",
"setup.cfg",
"setup.py",
"version.py",
":deterministic_tar_gz",
"//mesop", # Main Mesop target
"//mesop/bin", # CLI binary
Expand Down
1 change: 1 addition & 0 deletions mesop/pip_package/build_pip_package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ build() (
mv -f "mesop/pip_package/requirements.txt" .
mv -f "mesop/pip_package/setup.cfg" .
mv -f "mesop/pip_package/setup.py" .
mv -f "mesop/pip_package/version.py" .
rm -rf "mesop/pip_package"

rm -f mesop/mesop # bazel py_binary sh wrapper
Expand Down
9 changes: 7 additions & 2 deletions mesop/pip_package/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,14 @@
# limitations under the License.
# ==============================================================================


from setuptools import find_packages, setup

# Intentionally do not import "from mesop.pip_package.version"
# because this will drag in other modules through mesop/__init__.py
# incl. third-party packages like Flask which don't exist
# in this script environment.
from version import VERSION


def get_required_packages():
with open("requirements.txt") as f:
Expand All @@ -35,7 +40,7 @@ def get_readme():

setup(
name="mesop",
version="0.4.1",
version=VERSION,
description="Build UIs in Python",
long_description=get_readme(),
url="https://github.com/google/mesop",
Expand Down
6 changes: 6 additions & 0 deletions mesop/pip_package/version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
"""Contains the version string."""

VERSION = "0.4.1"

if __name__ == "__main__":
print(VERSION)

0 comments on commit f6c81e4

Please sign in to comment.