Skip to content
Open
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
15 changes: 3 additions & 12 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
from setuptools import find_packages, setup
from setuptools.dist import Distribution

from tensorrt_llm._packaging_utils import get_license_files


def parse_requirements(filename: os.PathLike):
with open(filename) as f:
Expand Down Expand Up @@ -75,17 +77,6 @@ def get_version():
return version


def get_license():
import sysconfig
platform_tag = sysconfig.get_platform()
if "x86_64" in platform_tag:
return ["LICENSE", "ATTRIBUTIONS-CPP-x86_64.md"]
elif "arm64" in platform_tag or "aarch64" in platform_tag:
return ["LICENSE", "ATTRIBUTIONS-CPP-aarch64.md"]
else:
raise RuntimeError(f"Unrecognized CPU architecture: {platform_tag}")


class BinaryDistribution(Distribution):
"""Distribution which always forces a binary package with platform name"""

Expand Down Expand Up @@ -255,7 +246,7 @@ def extract_from_precompiled(precompiled_location: str, package_data: List[str],
package_data={
'tensorrt_llm': package_data,
},
license_files=get_license(),
license_files=get_license_files(),
entry_points={
'console_scripts': [
'trtllm-build=tensorrt_llm.commands.build:main',
Expand Down
35 changes: 35 additions & 0 deletions tensorrt_llm/_packaging_utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# SPDX-FileCopyrightText: Copyright (c) 2022-2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Shared utilities for packaging and distribution."""


def get_license_files():
"""Get the list of license files to include in the package based on platform.

Returns:
List[str]: Platform-specific license files.
"""
import sysconfig
platform_tag = sysconfig.get_platform()
if "x86_64" in platform_tag:
return [
"LICENSE", "ATTRIBUTIONS-CPP-x86_64.md", "ATTRIBUTIONS-Python.md"
]
elif "arm64" in platform_tag or "aarch64" in platform_tag:
return [
"LICENSE", "ATTRIBUTIONS-CPP-aarch64.md", "ATTRIBUTIONS-Python.md"
]
else:
raise RuntimeError(f"Unrecognized CPU architecture: {platform_tag}")
16 changes: 3 additions & 13 deletions tests/unittest/test_pip_install.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,15 @@
import os
import subprocess
import sys
import sysconfig

import requests


def get_expected_license_files():
"""Get expected license files based on platform architecture."""
platform_tag = sysconfig.get_platform()
if "x86_64" in platform_tag:
return ["LICENSE", "ATTRIBUTIONS-CPP-x86_64.md"]
elif "arm64" in platform_tag or "aarch64" in platform_tag:
return ["LICENSE", "ATTRIBUTIONS-CPP-aarch64.md"]
else:
raise RuntimeError(f"Unrecognized CPU architecture: {platform_tag}")


def verify_license_files():
"""Verify that the correct platform-specific license files are packaged."""
expected_files = get_expected_license_files()
# Import after package is installed to ensure we're testing the installed version
from tensorrt_llm._packaging_utils import get_license_files
expected_files = get_license_files()

result = subprocess.run(
'python3 -c "from importlib.metadata import distribution; '
Expand Down
Loading