Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions maint/scripts/local_distribution_tox.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/bin/bash

# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.

multi_python_version=("3.8","3.9","3.10" "3.11", "3.12")
for python_version in "${multi_python_version[@]}"; do
echo "Installing Python ${python_version}..."
apt-get install -y python${python_version}
done

pip install -r requirements-build.txt

# if dist and build directories exist, remove them
if [ -d dist ]; then
rm -r dist
fi

# Build source distribution (disabled for now)
# python setup.py sdist --formats=gztar,zip

# Build wheels for different Python versions
echo "Building wheels for multiple Python versions..."
tox -e py38,py39,py310,py311,py312

if [ $? -ne 0 ]; then
echo "Error: Failed to build the wheels."
exit 1
else
echo "Wheels built successfully."
fi
1 change: 1 addition & 0 deletions requirements-build.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ packaging
setuptools>=61
torch
wheel
tox
16 changes: 15 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,21 @@ def download_and_extract_llvm(version, is_aarch64=False, extract_path="3rdparty"


def update_submodules():
"""Updates git submodules."""
"""Updates git submodules if in a git repository."""

def is_git_repo():
try:
# Check if current directory is a git repository
subprocess.check_output(["git", "rev-parse", "--is-inside-work-tree"],
stderr=subprocess.STDOUT)
return True
except (subprocess.CalledProcessError, FileNotFoundError):
return False

if not is_git_repo():
print("Info: Not a git repository, skipping submodule update.")
return

try:
subprocess.check_call(["git", "submodule", "update", "--init", "--recursive"])
except subprocess.CalledProcessError as error:
Expand Down
25 changes: 25 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
[tox]
envlist = py38,py39,py310,py311,py312
isolated_build = True

[testenv]
deps =
wheel
build
commands =
python -m build --wheel -o {toxinidir}/dist

[testenv:py38]
basepython = python3.8

[testenv:py39]
basepython = python3.9

[testenv:py310]
basepython = python3.10

[testenv:py311]
basepython = python3.11

[testenv:py312]
basepython = python3.12
Loading