diff --git a/src/builtin-adapter/README.md b/src/builtin-adapter/README.md index dbf2de16..ff39b6b0 100644 --- a/src/builtin-adapter/README.md +++ b/src/builtin-adapter/README.md @@ -2,13 +2,13 @@ ## Install from TestPyPI -Install `model-explorer-adapter` via pip from TestPyPI. For example, in a -Python virtual environment: +Install `ai-edge-model-explorer-adapter` via pip from TestPyPI. For example, in +a Python virtual environment: ``` % python3 -m venv ~/tmp/venv % source ~/tmp/venv/bin/activate -(venv) $ pip install -i https://test.pypi.org/simple/ model-explorer-converter +(venv) $ pip install -i https://test.pypi.org/simple/ ai-edge-model-explorer-adapter ``` ## Use the Package @@ -17,7 +17,7 @@ example: ``` (venv) $ python3 ->>> from model_explorer_adapter import _pywrap_convert_wrapper as convert_wrapper +>>> from ai_edge_model_explorer_adapter import _pywrap_convert_wrapper as convert_wrapper >>> config = convert_wrapper.VisualizeConfig() >>> model_path = 'foo.tflite' >>> json = convert_wrapper.ConvertFlatbufferToJson(config, model_path, True) @@ -37,8 +37,8 @@ package version, which should be a string of the form "x.x.x". For example: % tree gen/adapter_pip/dist gen/adapter_pip/dist -├── model_explorer_adapter-0.1.0-cp311-cp311-linux_x86_64.whl -└── model-explorer-adapter-0.1.0.linux-x86_64.tar.gz +├── ai_edge_model_explorer_adapter-0.1.0-cp311-cp311-linux_x86_64.whl +└── ai-edge-model-explorer-adapter-0.1.0.linux-x86_64.tar.gz ``` ### Install @@ -49,7 +49,7 @@ environment: ``` % python3 -m venv ~/tmp/venv % source ~/tmp/venv/bin/activate -(venv) $ pip install gen/adapter_pip/dist/model_explorer_adapter-0.1.0-cp311-cp311-linux_x86_64.whl +(venv) $ pip install gen/adapter_pip/dist/ai_edge_model_explorer_adapter-0.1.0-cp311-cp311-linux_x86_64.whl ``` The package should now be importable and usable. diff --git a/src/builtin-adapter/python/pip_package/build_cp39_package.sh b/src/builtin-adapter/python/pip_package/build_cp39_package.sh deleted file mode 100755 index 6c90d271..00000000 --- a/src/builtin-adapter/python/pip_package/build_cp39_package.sh +++ /dev/null @@ -1,121 +0,0 @@ -#!/usr/bin/env bash -# Copyright 2024 The Model Explorer Authors. All Rights Reserved. -# -# 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. -# ============================================================================== - -set -ex - -USAGE="$(basename $0) - -Builds a pip package for the Model Explorer backend adapter. - - should be a string of the form "x.x.x", eg. "1.2.0". -" - -# Define a regex pattern for the format x.x.x -PATTERN="^[0-9]+\.[0-9]+\.[0-9]+$" - -if [[ -z "${1}" ]]; then - echo "${USAGE}" - exit 1 -fi - -# Check if the argument matches the pattern -if [[ "$1" =~ $PATTERN ]]; then - export PACKAGE_VERSION="${1}" -else - echo "Error: The package version '$1' is not in the correct format." - exit 1 -fi - -SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" -PYTHON="python3.9" -export TF_PYTHON_VERSION="3.9" -export PROJECT_NAME=${WHEEL_PROJECT_NAME:-model_explorer_adapter} -BUILD_DIR="gen/adapter_pip" -BAZEL_FLAGS="--copt=-O3" -ARCH="$(uname -m)" - -# Build source tree. -rm -rf "${BUILD_DIR}" && mkdir -p "${BUILD_DIR}/model_explorer_adapter" -cp -r "${SCRIPT_DIR}/MANIFEST.in" \ - "${BUILD_DIR}" -cp "${SCRIPT_DIR}/setup_with_binary.py" "${BUILD_DIR}/setup.py" -echo "__version__ = '${PACKAGE_VERSION}'" >> "${BUILD_DIR}/model_explorer_adapter/__init__.py" - -# Build python _pywrap_convert_wrapper. - -# We need to pass down the environment variable with a possible alternate Python -# include path for Python 3.x builds to work. -export CROSSTOOL_PYTHON_INCLUDE_PATH - -case "${TENSORFLOW_TARGET}" in - windows) - LIBRARY_EXTENSION=".pyd" - ;; - *) - LIBRARY_EXTENSION=".so" - ;; -esac - -# Set linkopt for arm64 architecture. -case "${ARCH}" in - x86_64) - ;; - arm64) - BAZEL_FLAGS="${BAZEL_FLAGS} --linkopt="-ld_classic"" - ;; - *) - echo "Unsupported architecture: ${ARCH}" - exit 1 - ;; -esac - -bazel build -c opt -s --config=monolithic --config=noaws --config=nogcp --config=nohdfs --config=nonccl \ - ${BAZEL_FLAGS} python/convert_wrapper:_pywrap_convert_wrapper -cp "bazel-bin/python/convert_wrapper/_pywrap_convert_wrapper${LIBRARY_EXTENSION}" \ - "${BUILD_DIR}/model_explorer_adapter" - -# Bazel generates the wrapper library with r-x permissions for user. -# At least on Windows, we need write permissions to delete the file. -# Without this, setuptools fails to clean the build directory. -chmod u+w "${BUILD_DIR}/model_explorer_adapter/_pywrap_convert_wrapper${LIBRARY_EXTENSION}" - -# Build python wheel. -cd "${BUILD_DIR}" - -# Assign the wheel name based on the platform and architecture. Naming follows -# TF released wheel package. -if test -e "/System/Library/CoreServices/SystemVersion.plist"; then - if [[ "${ARCH}" == "arm64" ]]; then - # MacOS Silicon - WHEEL_PLATFORM_NAME="macosx_12_0_arm64" - else - # MacOS Intel - WHEEL_PLATFORM_NAME="macosx_10_15_x86_64" - fi -elif test -e "/etc/lsb-release"; then - # Linux - WHEEL_PLATFORM_NAME="manylinux_2_17_x86_64" -fi - -if [[ -n "${WHEEL_PLATFORM_NAME}" ]]; then - ${PYTHON} setup.py bdist --plat-name=${WHEEL_PLATFORM_NAME} \ - bdist_wheel --plat-name=${WHEEL_PLATFORM_NAME} -else - ${PYTHON} setup.py bdist bdist_wheel -fi - -echo "Output can be found here:" -find ${PWD} -name '*.whl' \ No newline at end of file diff --git a/src/builtin-adapter/python/pip_package/build_pip_package.sh b/src/builtin-adapter/python/pip_package/build_pip_package.sh index 20b0342f..b4574166 100755 --- a/src/builtin-adapter/python/pip_package/build_pip_package.sh +++ b/src/builtin-adapter/python/pip_package/build_pip_package.sh @@ -45,17 +45,17 @@ PYTHON_VERSION="$(${PYTHON} --version | cut -d " " -f 2)" IFS='.' read -ra VERSION_PARTS <<< "${PYTHON_VERSION}" # TF only supports python version ["3.9", "3.10", "3.11", "3.12"]. export TF_PYTHON_VERSION="${VERSION_PARTS[0]}.${VERSION_PARTS[1]}" -export PROJECT_NAME=${WHEEL_PROJECT_NAME:-model_explorer_adapter} +export PROJECT_NAME=${WHEEL_PROJECT_NAME:-ai_edge_model_explorer_adapter} BUILD_DIR="gen/adapter_pip" BAZEL_FLAGS="--copt=-O3" ARCH="$(uname -m)" # Build source tree. -rm -rf "${BUILD_DIR}" && mkdir -p "${BUILD_DIR}/model_explorer_adapter" +rm -rf "${BUILD_DIR}" && mkdir -p "${BUILD_DIR}/ai_edge_model_explorer_adapter" cp -r "${SCRIPT_DIR}/MANIFEST.in" \ "${BUILD_DIR}" cp "${SCRIPT_DIR}/setup_with_binary.py" "${BUILD_DIR}/setup.py" -echo "__version__ = '${PACKAGE_VERSION}'" >> "${BUILD_DIR}/model_explorer_adapter/__init__.py" +echo "__version__ = '${PACKAGE_VERSION}'" >> "${BUILD_DIR}/ai_edge_model_explorer_adapter/__init__.py" # Build python _pywrap_convert_wrapper. @@ -88,12 +88,12 @@ esac bazel build -c opt -s --config=monolithic --config=noaws --config=nogcp --config=nohdfs --config=nonccl \ ${BAZEL_FLAGS} python/convert_wrapper:_pywrap_convert_wrapper cp "bazel-bin/python/convert_wrapper/_pywrap_convert_wrapper${LIBRARY_EXTENSION}" \ - "${BUILD_DIR}/model_explorer_adapter" + "${BUILD_DIR}/ai_edge_model_explorer_adapter" # Bazel generates the wrapper library with r-x permissions for user. # At least on Windows, we need write permissions to delete the file. # Without this, setuptools fails to clean the build directory. -chmod u+w "${BUILD_DIR}/model_explorer_adapter/_pywrap_convert_wrapper${LIBRARY_EXTENSION}" +chmod u+w "${BUILD_DIR}/ai_edge_model_explorer_adapter/_pywrap_convert_wrapper${LIBRARY_EXTENSION}" # Build python wheel. cd "${BUILD_DIR}" diff --git a/src/builtin-adapter/python/pip_package/setup_with_binary.py b/src/builtin-adapter/python/pip_package/setup_with_binary.py index 794ea20e..52b3df6b 100644 --- a/src/builtin-adapter/python/pip_package/setup_with_binary.py +++ b/src/builtin-adapter/python/pip_package/setup_with_binary.py @@ -33,13 +33,13 @@ version=PACKAGE_VERSION, description=DOCLINES[0], long_description='\n'.join(DOCLINES[2:]), - url='https://www.tensorflow.org/lite/', - author='Google, LLC', - author_email='packages@tensorflow.org', + url='https://github.com/google-ai-edge/model-explorer', + author='Google AI Edge', + author_email='odml-devtools-team@google.com', license='Apache 2.0', include_package_data=True, has_ext_modules=lambda: True, - keywords='tflite tensorflow tensor machine learning model explorer adapter', + keywords='google ai edge machine learning model explorer adapter', classifiers=[ 'Development Status :: 5 - Production/Stable', 'Intended Audience :: Developers',