diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8bedc4b..8aba709 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -47,7 +47,6 @@ jobs: with: python-version: ${{ matrix.python-version }} streamlit-version: ${{ matrix.streamlit-version }} - importlib-metadata-version: '8.2.0' - run: playwright install diff --git a/example.py b/example.py index ae3c126..84f3af3 100644 --- a/example.py +++ b/example.py @@ -8,21 +8,12 @@ import requests import streamlit as st -import importlib_metadata from streamlit_searchbox import st_searchbox logging.getLogger("streamlit_searchbox").setLevel(logging.DEBUG) st.set_page_config(layout="centered", page_title="Searchbox Demo") -# Check the version of Streamlit -def get_streamlit_version(): - try: - version = importlib_metadata.version("streamlit") - return version - except importlib_metadata.PackageNotFoundError: - return None - def search_wikipedia_ids(searchterm: str) -> List[tuple[str, Any]]: """ function with list of tuples (label:str, value:any) @@ -301,9 +292,8 @@ def search_kwargs(searchterm: str, **kwargs) -> List[str]: st.write(manual) with fragment_example: - # Only pass scope if the version is >= 1.37 - version = get_streamlit_version() - if version and version >= "1.37": + # Only pass scope if the version is >= 1.37 + if st.__version__ >= "1.37": if "app_runs" not in st.session_state: diff --git a/setup.py b/setup.py index 79ab05e..c0b6bfe 100644 --- a/setup.py +++ b/setup.py @@ -17,7 +17,6 @@ # version 1.37 reruns lead to constant iFrame resets # version 1.35/1.36 also have reset issues but less frequent "streamlit >= 1.0", - "importlib-metadata" ], extras_require={ "tests": [ diff --git a/streamlit_searchbox/__init__.py b/streamlit_searchbox/__init__.py index 21a38f3..db9200c 100644 --- a/streamlit_searchbox/__init__.py +++ b/streamlit_searchbox/__init__.py @@ -12,7 +12,6 @@ import streamlit as st import streamlit.components.v1 as components -import importlib_metadata try: @@ -21,15 +20,6 @@ # conditional import for streamlit version <1.27 from streamlit import experimental_rerun as rerun # type: ignore -# Check the version of Streamlit -def get_streamlit_version(): - try: - version = importlib_metadata.version("streamlit") - return version - except importlib_metadata.PackageNotFoundError: - return None - -print("streamlit version:", get_streamlit_version()) # point to build directory parent_dir = os.path.dirname(os.path.abspath(__file__)) @@ -89,7 +79,7 @@ def _process_search( key: str, searchterm: str, rerun_on_update: bool, - rerun_scope: str, + rerun_scope: Literal["app", "fragment"] = "app", **kwargs, ) -> None: # nothing changed, avoid new search @@ -107,8 +97,8 @@ def _process_search( if rerun_on_update: # Only pass scope if the version is >= 1.37 - version = get_streamlit_version() - if version and version >= "1.37": + + if st.__version__ >= "1.37": rerun(scope=rerun_scope) # Pass scope if present else: rerun() @@ -194,7 +184,7 @@ def st_searchbox( style_absolute: bool = False, style_overrides: StyleOverrides | None = None, key: str = "searchbox", - rerun_scope: str = "app", + rerun_scope: Literal["app", "fragment"] = "app", **kwargs, ) -> Any: """ @@ -288,8 +278,7 @@ def st_searchbox( if rerun_on_update: # Only pass scope if the version is >= 1.37 - version = get_streamlit_version() - if version and version >= "1.37": + if st.__version__ >= "1.37": rerun(scope=rerun_scope) # Pass scope if present else: rerun()