diff --git a/.github/workflows/build-wheels-cpu-macos.yaml b/.github/workflows/build-wheels-cpu-macos.yaml index a97c69f6..f1e1fc18 100644 --- a/.github/workflows/build-wheels-cpu-macos.yaml +++ b/.github/workflows/build-wheels-cpu-macos.yaml @@ -36,6 +36,7 @@ jobs: env: # disable repair CIBW_REPAIR_WHEEL_COMMAND: "" + CIBW_BUILD_FRONTEND: "build" CIBW_ENVIRONMENT: CMAKE_ARGS="-DCMAKE_OSX_ARCHITECTURES=arm64;x86_64 " CIBW_BUILD: "cp310-* cp311-* cp312-*" MACOSX_DEPLOYMENT_TARGET: ${{ matrix.os }} diff --git a/.github/workflows/build-wheels-cpu.yaml b/.github/workflows/build-wheels-cpu.yaml index e18e66b5..c0de06bc 100644 --- a/.github/workflows/build-wheels-cpu.yaml +++ b/.github/workflows/build-wheels-cpu.yaml @@ -35,6 +35,7 @@ jobs: env: # disable repair CIBW_REPAIR_WHEEL_COMMAND: "" + CIBW_BUILD_FRONTEND: "build" CIBW_SKIP: "*musllinux*" CIBW_BUILD: "cp310-* cp311-* cp312-*" CMAKE_BUILD_PARALLEL_LEVEL: 4 @@ -77,6 +78,7 @@ jobs: env: # disable repair CIBW_REPAIR_WHEEL_COMMAND: "" + CIBW_BUILD_FRONTEND: "build" CIBW_BUILD: "cp310-* cp311-* cp312-*" CMAKE_BUILD_PARALLEL_LEVEL: 16 with: @@ -104,8 +106,9 @@ jobs: - name: Build wheels uses: pypa/cibuildwheel@v2.20.0 env: - CIBW_SKIP: "*musllinux* pp*" CIBW_REPAIR_WHEEL_COMMAND: "" + CIBW_BUILD_FRONTEND: "build" + CIBW_SKIP: "*musllinux* pp*" CIBW_ARCHS: "aarch64" CIBW_BUILD: "cp310-* cp311-* cp312-*" CMAKE_BUILD_PARALLEL_LEVEL: $(nproc) diff --git a/.github/workflows/build-wheels-metal.yaml b/.github/workflows/build-wheels-metal.yaml index b423c92c..930aad72 100644 --- a/.github/workflows/build-wheels-metal.yaml +++ b/.github/workflows/build-wheels-metal.yaml @@ -35,6 +35,7 @@ jobs: env: # disable repair CIBW_REPAIR_WHEEL_COMMAND: "" + CIBW_BUILD_FRONTEND: "build" CIBW_ARCHS: "arm64" CIBW_BUILD: "cp310-* cp311-* cp312-*" CIBW_ENVIRONMENT: CMAKE_ARGS="-DCMAKE_OSX_ARCHITECTURES=arm64 -DCMAKE_APPLE_SILICON_PROCESSOR=arm64 -DGGML_METAL=ON -DSD_METAL=ON" diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 489218f3..72ece928 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -25,7 +25,7 @@ jobs: fetch-depth: 0 # This fetches all history so you can access any version of the submodules - name: Set up Python - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} diff --git a/nexa/__init__.py b/nexa/__init__.py index b3c06d48..c1336bdb 100644 --- a/nexa/__init__.py +++ b/nexa/__init__.py @@ -1 +1 @@ -__version__ = "0.0.1" \ No newline at end of file +__version__ = "0.0.5" \ No newline at end of file diff --git a/nexa/cli/entry.py b/nexa/cli/entry.py index d8bdddb5..955ef6d0 100644 --- a/nexa/cli/entry.py +++ b/nexa/cli/entry.py @@ -1,6 +1,8 @@ import argparse import uvicorn +from nexa import __version__ + def run_onnx_inference(args): kwargs = {k: v for k, v in vars(args).items() if v is not None} model_path = kwargs.pop("model_path") @@ -73,6 +75,15 @@ def main(): parser = argparse.ArgumentParser( description="Nexa CLI tool for handling various model operations." ) + + parser.add_argument( + "-V", + "--version", + action="version", + version=__version__, + help="Show the version of the Nexa SDK.", + ) + subparsers = parser.add_subparsers(dest="command", help="sub-command help") # ONNX subparsers diff --git a/nexa/gguf/lib_utils.py b/nexa/gguf/lib_utils.py index ff2d887f..462ebcfe 100644 --- a/nexa/gguf/lib_utils.py +++ b/nexa/gguf/lib_utils.py @@ -8,11 +8,6 @@ from pathlib import Path from typing import List -from nexa.utils import ( - is_nexa_cuda_installed, - is_nexa_metal_installed, -) - def is_gpu_available(): current_dir = os.path.dirname(os.path.abspath(__file__)) @@ -72,17 +67,19 @@ def load_library(lib_base_name: str): def _add_windows_dll_directories(base_path: Path) -> None: - try_add_cuda_lib_path() os.add_dll_directory(str(base_path)) os.environ["PATH"] = str(base_path) + os.pathsep + os.environ["PATH"] - if sys.version_info >= (3, 8): - if "CUDA_PATH" in os.environ: - os.add_dll_directory(os.path.join(os.environ["CUDA_PATH"], "bin")) - os.add_dll_directory(os.path.join(os.environ["CUDA_PATH"], "lib")) - if "HIP_PATH" in os.environ: - os.add_dll_directory(os.path.join(os.environ["HIP_PATH"], "bin")) - os.add_dll_directory(os.path.join(os.environ["HIP_PATH"], "lib")) + if is_gpu_available(): + try_add_cuda_lib_path() + + if sys.version_info >= (3, 8): + if "CUDA_PATH" in os.environ: + os.add_dll_directory(os.path.join(os.environ["CUDA_PATH"], "bin")) + os.add_dll_directory(os.path.join(os.environ["CUDA_PATH"], "lib")) + if "HIP_PATH" in os.environ: + os.add_dll_directory(os.path.join(os.environ["HIP_PATH"], "bin")) + os.add_dll_directory(os.path.join(os.environ["HIP_PATH"], "lib")) def try_add_cuda_lib_path(): diff --git a/pyproject.toml b/pyproject.toml index 14384e89..16aea040 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,14 +4,14 @@ build-backend = "scikit_build_core.build" [project] name = "nexaai" -version = "0.0.5.1" +dynamic = ["version"] description = "Nexa AI SDK" readme = "README.md" license = { text = "MIT" } authors = [{ name = "Nexa AI", email = "octopus@nexa4ai.com" }] dependencies = [ "faster_whisper", - "typing-extensions>=4.5.0", # For ggml + "typing-extensions>=4.5.0", # For ggml "numpy>=1.20.0", "diskcache>=5.6.1", "jinja2>=2.11.3", @@ -21,9 +21,9 @@ dependencies = [ "pydantic", "pillow", "prompt_toolkit", - "tqdm", # Shared dependencies + "tqdm", # Shared dependencies "tabulate", - "streamlit" + "streamlit", ] classifiers = [ "Programming Language :: Python :: 3", @@ -36,8 +36,8 @@ classifiers = [ [project.optional-dependencies] onnx = [ "librosa", - "optimum[onnxruntime]", # for CPU version - "diffusers", # required for image generation + "optimum[onnxruntime]", # for CPU version + "diffusers", # required for image generation "optuna", "pydantic", "PyYAML", @@ -46,7 +46,7 @@ onnx = [ "soundfile", "streamlit_audiorec", "transformers", - "ttstokenizer" + "ttstokenizer", ] [project.urls] @@ -71,15 +71,30 @@ wheel.packages = [ "nexa.gguf.server", "nexa.onnx", "nexa.onnx.streamlit", - "nexa.onnx.server" + "nexa.onnx.server", +] +sdist.include = [ + "CMakeLists.txt", + "dependency/llama.cpp/*", + "dependency/stable-diffusion.cpp/*", +] +sdist.exclude = [ + ".github", + "build", + "dist", + "nexa.egg-info", + "dependency/llama.cpp/build", + "dependency/stable-diffusion.cpp/build", ] -sdist.include = ["CMakeLists.txt", "dependency/llama.cpp/*", "dependency/stable-diffusion.cpp/*"] -sdist.exclude = [".github", "build", "dist", "nexa.egg-info", "dependency/llama.cpp/build", "dependency/stable-diffusion.cpp/build"] build.verbose = true cmake.build-type = "Release" cmake.version = ">=3.16" # cmake.args = ["-DCMAKE_CXX_FLAGS=-fopenmp"] # for macOS with Intel Silicon cmake.args = ["-DCMAKE_BUILD_PARALLEL_LEVEL=16"] +[tool.scikit-build.metadata.version] +provider = "scikit_build_core.metadata.regex" +input = "nexa/__init__.py" + [tool.pytest.ini_options] -testpaths = ["tests"] \ No newline at end of file +testpaths = ["tests"] diff --git a/scripts/releases-to-pep-503.sh b/scripts/releases-to-pep-503.sh index 9d2dc312..82c2fb3f 100644 --- a/scripts/releases-to-pep-503.sh +++ b/scripts/releases-to-pep-503.sh @@ -79,9 +79,9 @@ if [ "$version" == "cpu" ]; then echo "

NEXAAI SDK Python Wheels

" >> "$root_dir/index.html" echo " CPU
" >> "$root_dir/index.html" echo " Metal
" >> "$root_dir/index.html" - echo " CUDA 12.1
" >> "$root_dir/index.html" - echo " CUDA 12.2
" >> "$root_dir/index.html" - echo " CUDA 12.3
" >> "$root_dir/index.html" + # echo " CUDA 12.1
" >> "$root_dir/index.html" + # echo " CUDA 12.2
" >> "$root_dir/index.html" + # echo " CUDA 12.3
" >> "$root_dir/index.html" echo " CUDA 12.4
" >> "$root_dir/index.html" echo " " >> "$root_dir/index.html" echo "" >> "$root_dir/index.html" diff --git a/tests/utils.py b/tests/utils.py index 84729190..79bc084c 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -3,27 +3,27 @@ def download_model(url, output_dir): """ - Download a file from a given URL using wget, if it doesn't already exist. - + Download a file from a given URL using curl, if it doesn't already exist. + Args: - url: str, the URL of the file to download. - output_dir: str, the directory where the file should be saved. - + Returns: - str: The path to the downloaded file. """ file_name = url.split("/")[-1] output_path = os.path.join(output_dir, file_name) - + if os.path.exists(output_path): print(f"File {file_name} already exists in {output_dir}. Skipping download.") return output_path - + try: - subprocess.run(["wget", url, "-O", output_path], check=True) + subprocess.run(["curl", url, "--output", output_path], check=True) print(f"Downloaded {file_name} to {output_dir}") except subprocess.CalledProcessError as e: print(f"Failed to download {file_name}: {e}") raise - + return output_path \ No newline at end of file