Unverified Commit c861d8a2 authored by Lei Wang's avatar Lei Wang Committed by GitHub
Browse files

[Dist] Provide an option to include commit ID in version (#884)

* Update MANIFEST.in and setup.py to include commit ID in versioning and adjust included files

- Modified MANIFEST.in to include shared library files `libtvm.so` and `libtvm_runtime.so`.
- Updated setup.py to conditionally include the commit ID in the package version based on the `WITH_COMMITID` environment variable.
- Enhanced versioning logic in version.py to use a truncated commit ID for better compatibility.

* Update setup.py and related scripts to enable commit ID inclusion in package metadata

- Changed the default value of the `WITH_COMMITID` environment variable in setup.py to "True".
- Updated tox.ini to set `WITH_COMMITID` to "TRUE" for the testing environment and "FALSE" for the build environment.
- Modified pypi_distribution.sh to pass `WITH_COMMITID=FALSE` during the wheel build process.

* Update MANIFEST.in to include additional files and directories for packaging

- Added VERSION, CMakeLists.txt, and various requirements files to the package.
- Included recursive inclusion of source files and third-party libraries, while excluding specific clang and llvm directories.
parent a58bf9b6
......@@ -7,4 +7,4 @@ if [ -d build ]; then
rm -r build
fi
PYPI_BUILD=TRUE python setup.py bdist_wheel --plat-name=manylinux1_x86_64
PYPI_BUILD=TRUE WITH_COMMITID=FALSE python setup.py bdist_wheel --plat-name=manylinux1_x86_64
......@@ -43,6 +43,8 @@ USE_LLVM = os.environ.get("USE_LLVM", "False").lower() == "true"
USE_ROCM = os.environ.get("USE_ROCM", "False").lower() == "true"
# Build with Debug mode
DEBUG_MODE = os.environ.get("DEBUG_MODE", "False").lower() == "true"
# Include commit ID in wheel filename and package metadata
WITH_COMMITID = os.environ.get("WITH_COMMITID", "True").lower() == "true"
def load_module_from_path(module_name, path):
......@@ -172,7 +174,12 @@ def get_tilelang_version(with_cuda=True, with_system_info=True, with_commit_id=F
except subprocess.SubprocessError as error:
logger.warning(f"Ignore commit id because failed to get git commit id: {str(error)}")
if commit_id:
version += f"+{commit_id}"
# Truncate commit ID to 8 characters to keep version string reasonable
short_commit_id = commit_id[:8]
if local_version_parts:
version += f".{short_commit_id}"
else:
version += f"+{short_commit_id}"
return version
......@@ -543,7 +550,7 @@ class TileLangBuilPydCommand(build_py):
# if is VERSION file, replace the content with the new version with commit id
if not PYPI_BUILD and item == "VERSION":
version = get_tilelang_version(
with_cuda=False, with_system_info=False, with_commit_id=True)
with_cuda=False, with_system_info=False, with_commit_id=WITH_COMMITID)
target_dir = os.path.dirname(target_dir)
if not os.path.exists(target_dir):
os.makedirs(target_dir)
......@@ -568,7 +575,7 @@ class TileLangSdistCommand(sdist):
def make_distribution(self):
self.distribution.metadata.name = PACKAGE_NAME
self.distribution.metadata.version = get_tilelang_version(
with_cuda=False, with_system_info=False, with_commit_id=False)
with_cuda=False, with_system_info=False, with_commit_id=WITH_COMMITID)
super().make_distribution()
......@@ -841,8 +848,8 @@ class TilelangExtensionBuild(build_ext):
setup(
name=PACKAGE_NAME,
version=(get_tilelang_version(with_cuda=False, with_system_info=False)
if PYPI_BUILD else get_tilelang_version()),
version=(get_tilelang_version(with_cuda=False, with_system_info=False, with_commit_id=False)
if PYPI_BUILD else get_tilelang_version(with_commit_id=WITH_COMMITID)),
packages=find_packages(where="."),
package_dir={"": "."},
author="Tile-AI",
......
......@@ -41,8 +41,12 @@ def get_git_commit_id() -> Union[str, None]:
# NOTE(lei): Although the local commit id cannot capture locally staged changes,
# the local commit id can help mitigate issues caused by incorrect cache to some extent,
# so it should still be kept.
if "+" not in __version__ and (commit_id := get_git_commit_id()):
__version__ = f"{__version__}+{commit_id}"
# Check WITH_COMMITID environment variable to control whether to include commit ID
WITH_COMMITID = os.environ.get("WITH_COMMITID", "True").lower() == "true"
if WITH_COMMITID and "+" not in __version__ and (commit_id := get_git_commit_id()):
# Use short commit ID (8 characters) for better compatibility
short_commit_id = commit_id[:8]
__version__ = f"{__version__}+{short_commit_id}"
# Define the public API for the module
__all__ = ["__version__"]
......@@ -8,6 +8,7 @@ deps =
wheel
build
setenv =
WITH_COMMITID = TRUE
PYTHON_EXECUTABLE = {envpython}
Python3_EXECUTABLE = {envpython}
commands =
......@@ -17,6 +18,7 @@ commands =
skip_install = false
setenv =
PYPI_BUILD = TRUE
WITH_COMMITID = FALSE
PYTHON_EXECUTABLE = {envpython}
Python3_EXECUTABLE = {envpython}
commands =
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment