Skip to content

Commit 4be2a71

Browse files
committed
Reapply "Fix building source distributions (#6381)"
This reverts commit a7b48c8.
1 parent 584f273 commit 4be2a71

File tree

12 files changed

+207
-215
lines changed

12 files changed

+207
-215
lines changed

.github/workflows/create_release.yml

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -43,30 +43,31 @@ jobs:
4343
tag_or_branch="${tag_or_branch#refs/heads/}"
4444
# replace directory separators with _ in branch name
4545
tag_or_branch="${tag_or_branch//\//_}"
46+
if [[ ${tag_or_branch} == v* ]]; then
47+
# strip trailing v from tag name
48+
tag_or_branch="${tag_or_branch#v}"
49+
# important: version must be fixed in setup.py
50+
sed -i -e "s:^TRITON_VERSION = .*:TRITON_VERSION = '${tag_or_branch}':" setup.py || exit 1
51+
fi
4652
echo "RELEASE_NAME=triton-$tag_or_branch" >> "$GITHUB_ENV"
47-
echo "RELEASE_FILE=triton-$tag_or_branch.tar.gz" >> "$GITHUB_ENV"
4853
- name: Create source distribution
4954
run: |
50-
# Create new folder with specified name so extracting the archive yields that
51-
rm -rf "/tmp/$RELEASE_NAME"
52-
cp -r "$PWD" "/tmp/$RELEASE_NAME"
53-
mv "/tmp/$RELEASE_NAME" .
54-
# Cleanup
55-
find "$RELEASE_NAME" -name '.git*' -exec rm -rv {} \; || true
56-
# Create archive
57-
tar -czf "$RELEASE_FILE" "$RELEASE_NAME"
58-
echo "Created source archive $RELEASE_FILE with content: $(ls -a "$RELEASE_NAME")"
55+
pip install build || exit 1
56+
python -m build -s || exit 1
57+
cd dist || exit 1
58+
release_file=( *.tar.gz )
59+
echo "RELEASE_FILE=${release_file}" >> "$GITHUB_ENV"
5960
- name: Upload source distribution for release
6061
if: ${{ github.event_name == 'release' }}
6162
uses: softprops/action-gh-release@v2
6263
with:
63-
files: ${{env.RELEASE_FILE}}
64+
files: dist/${{env.RELEASE_FILE}}
6465
- name: Upload source distribution to GHA artifacts for release tags
6566
if: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') && contains(github.ref, 'rc') }}
6667
uses: actions/[email protected]
6768
with:
6869
name: ${{ env.RELEASE_FILE }}
69-
path: ${{ env.RELEASE_FILE }}
70+
path: dist/${{ env.RELEASE_FILE }}
7071
- name: Set output
7172
id: release_name
7273
run: echo "name=release_name::${{ env.RELEASE_NAME }}.tar.gz" >> "${GITHUB_OUTPUT}"

.github/workflows/wheels.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,12 @@ jobs:
7979
export CIBW_BUILD="cp3{9,10,11,12,13,13t}-manylinux_${{ matrix.config.arch }}"
8080
export CIBW_SKIP="cp{35,36,37,38}-*"
8181
export CIBW_FREE_THREADED_SUPPORT=1
82-
python3 -m cibuildwheel python --output-dir wheelhouse
82+
python3 -m cibuildwheel . --output-dir wheelhouse
83+
84+
- uses: actions/upload-artifact@v4
85+
with:
86+
name: cibw-wheels-manylinux_2_28_${{ matrix.config.arch }}-wheels-upload
87+
path: ./wheelhouse/*.whl
8388

8489
- name: Install Azure CLI
8590
if: ${{ steps.check-version.outputs.new_commit == 'true' }}

MANIFEST.in

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
graft bin
2+
graft cmake
3+
graft docs
4+
graft include
5+
graft lib
6+
graft python/src
7+
graft python/test
8+
graft python/triton/backends/amd
9+
graft python/triton/backends/nvidia
10+
graft python/triton/tools/extra/cuda
11+
graft test
12+
graft third_party
13+
graft unittest
14+
include CMakeLists.txt
15+
include Makefile
16+
include python/build_helpers.py
17+
include python/requirements.txt
18+
include python/test-requirements.txt

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ dev-install-torch:
7979

8080
.PHONY: dev-install-triton
8181
dev-install-triton:
82-
$(PYTHON) -m pip install -e python --no-build-isolation -v
82+
$(PYTHON) -m pip install -e . --no-build-isolation -v
8383

8484
.PHONY: dev-install
8585
.NOPARALLEL: dev-install

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ git clone https://github.com/triton-lang/triton.git
7171
cd triton
7272

7373
pip install -r python/requirements.txt # build-time dependencies
74-
pip install -e python
74+
pip install -e .
7575
```
7676

7777
Or with a virtualenv:
@@ -84,7 +84,7 @@ python -m venv .venv --prompt triton
8484
source .venv/bin/activate
8585

8686
pip install -r python/requirements.txt # build-time dependencies
87-
pip install -e python
87+
pip install -e .
8888
```
8989

9090
# Building with a custom LLVM
@@ -124,7 +124,7 @@ arbitrary LLVM version.
124124
$ LLVM_INCLUDE_DIRS=$LLVM_BUILD_DIR/include \
125125
LLVM_LIBRARY_DIR=$LLVM_BUILD_DIR/lib \
126126
LLVM_SYSPATH=$LLVM_BUILD_DIR \
127-
pip install -e python
127+
pip install -e .
128128

129129
# Tips for building
130130

@@ -139,7 +139,7 @@ arbitrary LLVM version.
139139
can be changed anytime.
140140

141141
- If you're running out of memory when building Triton, specify the `MAX_JOBS`
142-
environment variable (to the `pip install -e python` command) to limit the
142+
environment variable (to the `pip install -e .` command) to limit the
143143
number of jobs.
144144

145145
- Pass `--no-build-isolation` to `pip install` to make nop builds faster.
@@ -150,7 +150,7 @@ arbitrary LLVM version.
150150
(probably because, in our build, users don't invoke cmake directly, but
151151
instead use setup.py). Teach vscode how to compile Triton as follows.
152152

153-
- Do a local build. Run command `pip install -e python`
153+
- Do a local build. Run command `pip install -e .`
154154
- Get the full path to the `compile_commands.json` file produced by the build:
155155
`find python/build -name 'compile_commands.json' | xargs readlink -f`.
156156
You might get a full path similar to `/Users/{username}/triton/python/build/cmake.macosx-11.1-arm64-cpython-3.12/compile_commands.json`

pyproject.toml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
[build-system]
2-
requires = ["setuptools>=78.1.0", "wheel", "cmake>=3.18", "ninja>=1.11.1"]
2+
requires = ["setuptools>=78.1.0", "cmake>=3.18", "ninja>=1.11.1", "pybind11>=2.13.1"]
3+
build-backend = "setuptools.build_meta"
34

45
[tool.yapf]
56
based_on_style = "pep8"
@@ -9,6 +10,12 @@ each_dict_entry_on_separate_line=false
910
split_before_named_assigns = false
1011
split_complex_comprehension = true
1112

13+
# We're incrementally switching from autopep8 to ruff.
14+
[tool.autopep8]
15+
aggressive = 1
16+
ignore = "E501,E701,E731,W690,W503"
17+
max_line_length = 88
18+
1219
[tool.ruff]
1320
line-length = 120
1421

python/build_helpers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,6 @@ def get_cmake_dir():
1212
plat_name = sysconfig.get_platform()
1313
python_version = sysconfig.get_python_version()
1414
dir_name = f"cmake.{plat_name}-{sys.implementation.name}-{python_version}"
15-
cmake_dir = Path(get_base_dir()) / "python" / "build" / dir_name
15+
cmake_dir = Path(get_base_dir()) / "build" / dir_name
1616
cmake_dir.mkdir(parents=True, exist_ok=True)
1717
return cmake_dir

python/triton/_C/include

Lines changed: 0 additions & 1 deletion
This file was deleted.

python/triton/backends/__init__.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
11
import importlib
22
import inspect
3-
import os
3+
import sys
44
from dataclasses import dataclass
55
from .driver import DriverBase
66
from .compiler import BaseBackend
77

8+
if sys.version_info >= (3, 10):
9+
from importlib.metadata import entry_points
10+
else:
11+
from importlib_metadata import entry_points
12+
813

914
def _find_concrete_subclasses(module, base_class):
1015
ret = []
@@ -27,16 +32,11 @@ class Backend:
2732

2833
def _discover_backends():
2934
backends = dict()
30-
root = os.path.dirname(__file__)
31-
for name in os.listdir(root):
32-
if not os.path.isdir(os.path.join(root, name)):
33-
continue
34-
if name.startswith('__'):
35-
continue
36-
compiler = importlib.import_module(f"triton.backends.{name}.compiler")
37-
driver = importlib.import_module(f"triton.backends.{name}.driver")
38-
backends[name] = Backend(_find_concrete_subclasses(compiler, BaseBackend),
39-
_find_concrete_subclasses(driver, DriverBase))
35+
for ep in entry_points().select(group="triton.backends"):
36+
compiler = importlib.import_module(f"{ep.value}.compiler")
37+
driver = importlib.import_module(f"{ep.value}.driver")
38+
backends[ep.name] = Backend(_find_concrete_subclasses(compiler, BaseBackend),
39+
_find_concrete_subclasses(driver, DriverBase))
4040
return backends
4141

4242

0 commit comments

Comments
 (0)