diff --git a/mesop/BUILD b/mesop/BUILD index 8e8fa9306..e663222c0 100644 --- a/mesop/BUILD +++ b/mesop/BUILD @@ -17,7 +17,7 @@ py_library( ], visibility = ["//build_defs:mesop_users"], deps = [ - "//mesop/pip_package:version", + ":version", # REF(//scripts/scaffold_component.py):insert_component_import "//mesop/components/embed:py", "//mesop/components/table:py", @@ -50,6 +50,12 @@ py_library( ], ) +py_library( + name = "version", + srcs = ["version.py"], + visibility = ["//build_defs:mesop_internal"], +) + py_library( name = "example_index", srcs = ["example_index.py"], diff --git a/mesop/__init__.py b/mesop/__init__.py index 3d3d34fb5..bbc73c279 100644 --- a/mesop/__init__.py +++ b/mesop/__init__.py @@ -129,10 +129,10 @@ ) 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 +from mesop.version import VERSION __version__ = VERSION diff --git a/mesop/pip_package/BUILD b/mesop/pip_package/BUILD index 2078afb93..3fe81b628 100644 --- a/mesop/pip_package/BUILD +++ b/mesop/pip_package/BUILD @@ -1,19 +1,9 @@ -# Description: -# Tools for building the Mesop pip package. -load("//build_defs:defaults.bzl", "py_binary", "py_library") - package( default_visibility = ["//build_defs:mesop_internal"], ) 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"], @@ -24,9 +14,9 @@ sh_binary( "requirements.txt", "setup.cfg", "setup.py", - "version.py", ":deterministic_tar_gz", "//mesop", # Main Mesop target + "//mesop:version.py", "//mesop/bin", # CLI binary "//mesop/labs", # Mesop labs target ], diff --git a/mesop/pip_package/build_pip_package.sh b/mesop/pip_package/build_pip_package.sh index 65a4d75c5..f4e4e7879 100755 --- a/mesop/pip_package/build_pip_package.sh +++ b/mesop/pip_package/build_pip_package.sh @@ -79,7 +79,11 @@ 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" . + # version.py is copied because it's used in two ways: + # 1) used by ./setup.py (see note how it must be imported without + # depending on the rest of mesop package) + # 2) used by mesop/__init__.py as a constant in the public API + cp "mesop/version.py" . rm -rf "mesop/pip_package" rm -f mesop/mesop # bazel py_binary sh wrapper diff --git a/mesop/pip_package/version.py b/mesop/version.py similarity index 100% rename from mesop/pip_package/version.py rename to mesop/version.py