Skip to content

Commit

Permalink
Use py-build-cmake
Browse files Browse the repository at this point in the history
  • Loading branch information
ilya-lavrenov committed Jun 10, 2024
1 parent 1ee4f38 commit 25a54c0
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 36 deletions.
16 changes: 6 additions & 10 deletions .github/workflows/genai_python_lib.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,9 @@ jobs:
- run: sudo ./ov/install_dependencies/install_openvino_dependencies.sh
- run: source ./ov/setupvars.sh && cmake -DCMAKE_BUILD_TYPE=Release -S ./ -B ./build/
- run: source ./ov/setupvars.sh && cmake --build ./build/ --config Release -j
# GitHub Actions already provides what is listed in ./requirements-build.txt but the internal
# build system doesn't. Install ./requirements-build.txt to detect possible conflicts.
- run: source ./ov/setupvars.sh && python -m pip install ./thirdparty/openvino_tokenizers/[transformers] -r ./requirements-build.txt -r ./tests/python_tests/requirements.txt --extra-index-url https://storage.openvinotoolkit.org/simple/wheels/pre-release --upgrade-strategy eager
- run: source ./ov/setupvars.sh && python -m pip install ./thirdparty/openvino_tokenizers/[transformers] -r ./tests/python_tests/requirements.txt --extra-index-url https://storage.openvinotoolkit.org/simple/wheels/pre-release --upgrade-strategy eager
- run: source ./ov/setupvars.sh && PYTHONPATH=./build/:$PYTHONPATH python -m pytest ./tests/python_tests/test_generate_api.py -m precommit
- run: source ./ov/setupvars.sh && python -m pip install . --config-settings=build-dir="build" --verbose
- run: source ./ov/setupvars.sh && python -m pip install . --verbose
- run: python -m pytest ./tests/python_tests/test_generate_api.py -m precommit

macos_genai_python_lib:
Expand All @@ -49,11 +47,9 @@ jobs:
- run: brew install coreutils scons
- run: source ./ov/setupvars.sh && cmake -DCMAKE_BUILD_TYPE=Release -S ./ -B ./build/
- run: source ./ov/setupvars.sh && cmake --build ./build/ --config Release -j
# GitHub Actions already provides what is listed in ./requirements-build.txt but the internal
# build system doesn't. Install ./requirements-build.txt to detect possible conflicts.
- run: source ./ov/setupvars.sh && python -m pip install ./thirdparty/openvino_tokenizers/[transformers] -r ./requirements-build.txt -r ./tests/python_tests/requirements.txt --extra-index-url https://storage.openvinotoolkit.org/simple/wheels/pre-release --upgrade-strategy eager
- run: source ./ov/setupvars.sh && python -m pip install ./thirdparty/openvino_tokenizers/[transformers] -r ./tests/python_tests/requirements.txt --extra-index-url https://storage.openvinotoolkit.org/simple/wheels/pre-release --upgrade-strategy eager
- run: source ./ov/setupvars.sh && PYTHONPATH=./build/:$PYTHONPATH python -m pytest ./tests/python_tests/test_generate_api.py -m precommit
- run: source ./ov/setupvars.sh && python -m pip install . --config-settings=build-dir="build" --verbose
- run: source ./ov/setupvars.sh && python -m pip install . --verbose
- run: python -c "from openvino_genai import LLMPipeline"
- run: python -m pytest ./tests/python_tests/test_generate_api.py -m precommit

Expand All @@ -78,8 +74,8 @@ jobs:
- run: mklink /D ov w_openvino_toolkit_windows_2024.2.0.dev20240524_x86_64
- run: call ./ov/setupvars.bat && cmake -DCMAKE_BUILD_TYPE=Release -S ./ -B ./build/
- run: call ./ov/setupvars.bat && cmake --build ./build/ --config Release -j
- run: call ./ov/setupvars.bat && python -m pip install ./thirdparty/openvino_tokenizers/[transformers] -r ./requirements-build.txt -r ./tests/python_tests/requirements.txt --extra-index-url https://storage.openvinotoolkit.org/simple/wheels/pre-release --upgrade-strategy eager
- run: call ./ov/setupvars.bat && python -m pip install ./thirdparty/openvino_tokenizers/[transformers] -r ./tests/python_tests/requirements.txt --extra-index-url https://storage.openvinotoolkit.org/simple/wheels/pre-release --upgrade-strategy eager
# cmd evaluates variables in a different way. Setting PYTHONPATH before setupvars.bat instead of doing that after solves that.
- run: set "PYTHONPATH=./build/" && call ./ov/setupvars.bat && python -m pytest ./tests/python_tests/test_generate_api.py -m precommit
- run: call ./ov/setupvars.bat && python -m pip install . --config-settings=build-dir="build" --verbose
- run: call ./ov/setupvars.bat && python -m pip install . --verbose
- run: python -m pytest ./tests/python_tests/test_generate_api.py -m precommit
41 changes: 20 additions & 21 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "openvino_genai"
version = "2024.2.0.0"
version = "2024.3.0.0"
description = "Python bindings for https://github.com/openvinotoolkit/openvino.genai"
requires-python = ">=3.8"
readme = {file = "src/README.md", content-type="text/markdown"}
Expand All @@ -16,31 +16,30 @@ classifiers = [
"Programming Language :: Python :: 3.12",
]
dependencies = [
"openvino_tokenizers~=2024.2.0.0"
"openvino_tokenizers~=2024.3.0.0"
]

[tool.scikit-build]
cmake.build-type = "Release"
cmake.source-dir = "./"
cmake.targets = ["py_generate_pipeline"] # Adding genai would trigger a Release build and Debug build after it. py_generate_pipeline depends on genai and genai will be built anyway. It's not been investigated why both build types are triggered.
cmake.version = ">=3.23"
install.components = ["wheel_genai"]
sdist.cmake = true
wheel.packages = ["src/python/openvino_genai"]
wheel.install-dir = "openvino_genai"
wheel.build-tag = "000"
wheel.license-files = ["LICENSE", "SECURITY.md", "third-party-programs.txt"]
[tool.py-build-cmake.module]
directory = "src/python"

[[tool.scikit-build.generate]]
path = "openvino_genai/__version__.py"
template = '''
__version__ = "${version}"
'''
[tool.py-build-cmake.sdist]
exclude = ["llm_bench", "samples", "tests", "thirdparty"]

[tool.py-build-cmake.cmake]
minimum_version = "3.23"
build_type = "Release"
config = ["Release"]
find_python3 = true
build_args = ["--parallel", "--target", "py_generate_pipeline"]
install_args = ["--strip"]
install_components = ["wheel_genai"]

[build-system]
# TODO: add build.tool-args = ["--parallel"] after scikit-build-core is updated to 0.9.4+.
requires = ["scikit-build-core~=0.8.0"] # See https://github.com/openvinotoolkit/openvino_tokenizers/pull/123
build-backend = "scikit_build_core.build"
requires = [
"py-build-cmake@git+https://github.com/tttapa/py-build-cmake@7ab73da351c7140f06d727a8705bece4cf544cd9",
"cmake~=3.23"
]
build-backend = "py_build_cmake.build"

[tool.pytest.ini_options]
markers = [
Expand Down
2 changes: 0 additions & 2 deletions requirements-build.txt

This file was deleted.

4 changes: 2 additions & 2 deletions src/python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,6 @@ install(TARGETS openvino_genai py_generate_pipeline LIBRARY DESTINATION python/o
# wheel_genai component is used for wheel generation in pyproject.toml.
# Exclude wheel_genai from normal packaging because there's pygenai_X_Y component for that.
install(TARGETS openvino_genai py_generate_pipeline
LIBRARY DESTINATION . COMPONENT wheel_genai
RUNTIME DESTINATION . COMPONENT wheel_genai
LIBRARY DESTINATION openvino_genai COMPONENT wheel_genai
RUNTIME DESTINATION openvino_genai COMPONENT wheel_genai
EXCLUDE_FROM_ALL)

0 comments on commit 25a54c0

Please sign in to comment.