diff --git a/python/setup.py b/python/setup.py index 9d340016d5d..c7fe063afa7 100644 --- a/python/setup.py +++ b/python/setup.py @@ -73,8 +73,8 @@ import sys from utils import ( + BuildConfig, run, - create_build_config, override_build_config_from_env, ) @@ -92,11 +92,8 @@ def version_tag(config): def main(): - # Parse arguments using argparse - # Use argparse to create description of arguments from command line - config, forward_args = create_build_config() - - # Override build config from environment variables + config = BuildConfig() + # Override build config from environment variables. override_build_config_from_env(config) if "clean" in sys.argv: @@ -106,8 +103,6 @@ def main(): if config.cpp_standard < 20: raise ValueError("nvfuser requires C++20 standard or higher") - sys.argv = [sys.argv[0]] + forward_args - run(config, version_tag(config), relative_path="..") diff --git a/python/utils.py b/python/utils.py index 272d347c23e..203a89ee5b9 100644 --- a/python/utils.py +++ b/python/utils.py @@ -2,7 +2,6 @@ # All rights reserved. # SPDX-License-Identifier: BSD-3-Clause -import argparse import os import multiprocessing import subprocess @@ -50,180 +49,6 @@ def get_env_flag_bool(name: str) -> bool: return os.getenv(name).upper() in ["ON", "1", "YES", "TRUE", "Y"] -def parse_args(): - parser = argparse.ArgumentParser( - description="NVFUSER build options", add_help=False - ) - - # Add arguments that don't go to setuptools - parser.add_argument( - "--cmake-only", - dest="cmake_only", - action="store_true", - help="Only generate ./build directory with cmake setup", - ) - parser.add_argument( - "--no-python", - dest="no_python", - action="store_true", - help="Skips python API target libnvfuser.so", - ) - parser.add_argument( - "--no-cutlass", - dest="no_cutlass", - action="store_true", - help="Skips building cutlass kernels", - ) - parser.add_argument( - "--no-test", - dest="no_test", - action="store_true", - help="Skips cpp tests test_nvfuser", - ) - parser.add_argument( - "--no-benchmark", - dest="no_benchmark", - action="store_true", - help="Skips benchmark target nvfuser_bench", - ) - parser.add_argument( - "--no-ninja", - dest="no_ninja", - action="store_true", - help="Use make instead of ninja for build", - ) - parser.add_argument( - "--build-with-ucc", - dest="build_with_ucc", - action="store_true", - help="Build nvfuser with UCC support", - ) - parser.add_argument( - "--explicit-error-check", - dest="explicit_error_check", - action="store_true", - help="Enable explicit error checking", - ) - parser.add_argument( - "--build-with-asan", - dest="build_with_asan", - action="store_true", - help="Build with Address Sanitizer", - ) - parser.add_argument( - "--build-without-distributed", - dest="build_without_distributed", - action="store_true", - help="Build nvfuser without multidevice support", - ) - parser.add_argument( - "--no-system-nvtx", - dest="no_system_nvtx", - action="store_true", - help="Disable system NVTX", - ) - parser.add_argument( - "--debug", - dest="debug_mode", - action="store_true", - help="Building nvfuser in debug mode", - ) - parser.add_argument( - "--debinfo", - dest="debinfo_mode", - action="store_true", - help="Building nvfuser in release mode with debug info", - ) - parser.add_argument( - "--build-dir", - dest="build_dir", - type=str, - default="", - help="Specify in which directory to build nvfuser", - ) - parser.add_argument( - "--install-dir", - dest="install_dir", - type=str, - default="", - help="Specify in which directory to install nvfuser", - ) - parser.add_argument( - "-install_requires", - dest="install_requires", - type=str, - help="Specify package required for installation", - ) - parser.add_argument( - "--extras_require", - dest="extras_require", - type=str, - help="Specify extra requirements", - ) - parser.add_argument( - "-version-tag", - dest="version_tag", - type=str, - help="Specify the tag for build nvfuser version", - ) - parser.add_argument( - "-wheel-name", - dest="wheel_name", - type=str, - default="nvfuser", - help="Specify the wheel name", - ) - parser.add_argument( - "--cpp", - dest="cpp_standard", - type=int, - help="Specify the C++ standard to use", - default=20, - ) - - # Use parse_known_args to separate our arguments from setuptools arguments - args, forward_args = parser.parse_known_args() - return args, forward_args - - -# Create BuildConfig using argparse -def create_build_config(): - # Parse arguments and set global variables accordingly - args, forward_args = parse_args() - - # Create a BuildConfig from args - config = BuildConfig( - cmake_only=args.cmake_only, - no_python=args.no_python, - no_cutlass=args.no_cutlass, - no_test=args.no_test, - no_benchmark=args.no_benchmark, - no_ninja=args.no_ninja, - build_with_ucc=args.build_with_ucc, - build_with_asan=args.build_with_asan, - build_without_distributed=args.build_without_distributed, - explicit_error_check=args.explicit_error_check, - wheel_name=args.wheel_name, - build_dir=args.build_dir, - install_dir=args.install_dir, - cpp_standard=args.cpp_standard, - ) - - # Apply remaining options - if args.debug_mode: - config.build_type = "Debug" - if args.debinfo_mode: - config.build_type = "RelwithDebInfo" - if args.install_requires: - config.install_requires = args.install_requires.split(",") - if args.extras_require: - config.extras_require = eval(args.extras_require) - if args.version_tag: - config.version_tag = args.version_tag - config.overwrite_version = True - return config, forward_args - - # Override BuildConfig with environment variables. Only change if variable # exists. Do not use default to override argparse. def override_build_config_from_env(config): diff --git a/setup.py b/setup.py deleted file mode 100644 index e1cd19eb726..00000000000 --- a/setup.py +++ /dev/null @@ -1,107 +0,0 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-present NVIDIA CORPORATION & AFFILIATES. -# All rights reserved. -# SPDX-License-Identifier: BSD-3-Clause -# -# Usage: -# [MAX_JOBS] python setup.py develop [args] -# -# Environment variables used during build: -# -# MAX_JOBS -# maximum number of compile jobs we should use to compile your code -# -# NvFuser build arguments: -# -# --cmake-only -# Only generate ./build directory with cmake setup -# -# --no-python -# Skips python API target `libnvfuser.so`, i.e. `_C.cpython-xxx.so` -# -# --no-test -# Skips cpp tests `test_nvfuser` -# -# --no-benchmark -# Skips benchmark target `nvfuser_bench` -# -# --no-ninja -# In case you want to use make instead of ninja for build -# -# --build-with-ucc -# Build nvfuser with UCC support. You may need to specify environment variables of UCC_HOME, UCC_DIR, UCX_HOME, UCX_DIR. -# -# --build-without-distributed -# Build nvfuser without multidevice support -# -# --debug -# Building nvfuser in debug mode -# -# --debinfo -# Building nvfuser in release mode with debug info, a.k.a. RelwithDebInfo -# -# --build-dir= -# Specify in which directory to build nvfuser. If not specified, the default build directory is "./build". -# -# --install-dir= -# Specify in which directory to install nvfuser. If not specified, the default install directory is "./python/nvfuser". -# -# -version-tag=TAG -# Specify the tag for build nvfuser version, this is used for pip wheel -# package nightly where we might want to add a date tag -# nvfuser-VERSION+TAG+gitSHA1-....-whl -# -# -install_requires=pkg0[,pkg1...] -# this is used for pip wheel build to specify package required for install -# e.g. -install_requires=nvidia-cuda-nvrtc-cu12 -# -# -wheel-name=NAME -# Specify the wheel name this is used for pip wheel package where we want -# to identify the cuda toolkit version -# -# --cpp=STANDARD -# Specify the C++ standard to use for building nvfuser. The default is C++20. -# - -# TODO Remove nvfuser symbolic link to python/nvfuser -# TODO Remove tools/gen_nvfuser_version.py symbolic link to python/tools/gen_nvfuser_version.py -# TODO Remove tools/memory.py symbolic link to python/tools/memory.py - -import sys - - -from python.utils import ( - run, - create_build_config, -) - - -def version_tag(config): - from python.tools.gen_nvfuser_version import get_version - - version = get_version() - if config.overwrite_version: - version = version.split("+")[0] - if len(config.version_tag) != 0: - # use "." to be pypi friendly - version = ".".join([version, config.version_tag]) - return version - - -def main(): - # Parse arguments using argparse - config, forward_args = create_build_config() - - if "clean" in sys.argv: - # only disables BUILD_SETUP, but keep the argument for setuptools - config.build_setup = False - - if config.cpp_standard < 20: - raise ValueError("nvfuser requires C++20 standard or higher") - - sys.argv = [sys.argv[0]] + forward_args - - run(config, version_tag(config), relative_path=".") - - -if __name__ == "__main__": - main()