Skip to content

Commit 5a2bf34

Browse files
Fix installation files
1 parent cdc8996 commit 5a2bf34

File tree

3 files changed

+4
-101
lines changed

3 files changed

+4
-101
lines changed

.pre-commit-config.yaml

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,6 @@ repos:
1212
args: [--maxkb=500, --enforce-all]
1313
exclude: >
1414
(?x)^(
15-
internal/experimental/GTC_2024_demo/SDXL_PTQ.ipynb|
16-
internal/experimental/vae_training/.*|
17-
internal/examples/diffusers/quantization/assets/.*.png|
1815
examples/diffusers/quantization/assets/.*.png|
1916
examples/diffusers/cache_diffusion/assets/.*.png|
2017
)$
@@ -25,7 +22,6 @@ repos:
2522
- id: check-toml
2623
- id: check-yaml
2724
args: [--allow-multiple-documents]
28-
exclude: ^internal/.gitlab/ # !references are not supported
2925
- id: debug-statements
3026
- id: end-of-file-fixer
3127
- id: mixed-line-ending
@@ -115,14 +111,6 @@ repos:
115111
examples/speculative_decoding/main.py|
116112
examples/speculative_decoding/medusa_utils.py|
117113
examples/speculative_decoding/server_generate.py|
118-
internal/examples/diffusers/cache_diffusion/cache_diffusion/module.py|
119-
internal/examples/diffusers/cache_diffusion/pipeline/models/sdxl.py|
120-
internal/examples/mlperf/infer.py|
121-
internal/examples/onnx_ptq/quantize_llama.py|
122-
internal/examples/torchvision/modelopt_torchvision.py|
123-
internal/examples/vlm_eval/data_utils.py|
124-
internal/examples/vlm_eval/eval_utils.py|
125-
internal/examples/vlm_eval/mmmu.py|
126114
)$
127115
128116
# Default hook for Apache 2.0 in core c/c++/cuda files
@@ -167,4 +155,3 @@ repos:
167155
- id: lychee
168156
args: ["--no-progress", "--exclude-loopback"]
169157
stages: [manual] # Only run with `pre-commit run --all-files --hook-stage manual lychee`
170-
exclude: internal/

pyproject.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ build-backend = "setuptools.build_meta"
1111
####################################################################################################
1212
[tool.ruff]
1313
target-version = "py310"
14-
extend-exclude = ["internal/experimental/*", "internal/examples/crush/ptq.py"]
1514
line-length = 100 # Line length limit for code
1615
fix = true
1716

setup.py

Lines changed: 4 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,16 @@
1515

1616
"""The package setup script for modelopt customizing certain aspects of the installation process."""
1717

18-
import glob
1918
import os
19+
import platform
2020

2121
import setuptools
22-
from Cython.Build import cythonize
23-
from setuptools.command.build_py import build_py
24-
from setuptools.extension import Extension
25-
from setuptools_scm import get_version
2622

2723
# Package configuration ############################################################################
2824
name = "nvidia-modelopt"
29-
# TODO: Set version to static stable release version when creating the release branch
30-
# version = os.environ.get("SETUPTOOLS_SCM_PRETEND_VERSION", "X.Y.Z")
31-
version = get_version(root=".", fallback_version="0.0.0")
25+
version = os.environ.get(
26+
"SETUPTOOLS_SCM_PRETEND_VERSION", "0.31.0" if platform.system() == "Linux" else "0.27.0"
27+
)
3228
packages = setuptools.find_namespace_packages(include=["modelopt*"])
3329
package_dir = {"": "."}
3430
package_data = {"modelopt": ["**/*.h", "**/*.cpp", "**/*.cu"]}
@@ -122,85 +118,6 @@
122118
optional_deps["dev"] = [deps for k in optional_deps for deps in optional_deps[k]]
123119

124120

125-
# External release overwrites ######################################################################
126-
# TODO: Remove this section before copying the setup.py to the modelopt github repository
127-
128-
# You can modify the installation process with the following env variables:
129-
# - ``MODELOPT_EXTERNAL``: if set to ``true`` (Default is ``False``), external packages (excluding
130-
# `modelopt.core`) will be packaged into a wheel `nvidia-modelopt`. Also, internal dependencies
131-
# will not be installed or packaged. This is useful for external releases.
132-
# - ``MODELOPT_CORE_EXTERNAL``: if set to ``true`` (Default is ``False``), only `modelopt.core` will
133-
# be compiled into a separate wheel `nvidia-modelopt-core`. This wheel will not have any pip
134-
# dependencies. This is useful for external releases.
135-
136-
MODELOPT_EXTERNAL = os.environ.get("MODELOPT_EXTERNAL", "false").lower() == "true"
137-
MODELOPT_CORE_EXTERNAL = os.environ.get("MODELOPT_CORE_EXTERNAL", "false").lower() == "true"
138-
139-
assert not (MODELOPT_EXTERNAL and MODELOPT_CORE_EXTERNAL), (
140-
"Cannot set both `MODELOPT_EXTERNAL` and `MODELOPT_CORE_EXTERNAL` to true."
141-
)
142-
143-
144-
if MODELOPT_EXTERNAL:
145-
packages = setuptools.find_namespace_packages(
146-
include=[ # Modules for external release (everything except modelopt.core)
147-
"modelopt", # __init__.py
148-
"modelopt.deploy*",
149-
"modelopt.onnx*",
150-
"modelopt.torch*",
151-
]
152-
)
153-
elif MODELOPT_CORE_EXTERNAL:
154-
name = "nvidia-modelopt-core"
155-
packages = ["modelopt_core"] + [
156-
f"modelopt_core.{p}" for p in setuptools.find_namespace_packages(where="modelopt/core")
157-
]
158-
package_dir = {"modelopt_core": "modelopt/core"}
159-
package_data = {}
160-
required_deps = []
161-
optional_deps = {}
162-
163-
# Cythonize all non-init files in modelopt_core
164-
compiled_files = [
165-
f.replace(os.sep, "/") # Windows compatible
166-
for f in glob.iglob("modelopt/core/**/*.py", recursive=True)
167-
if not f.endswith("__init__.py")
168-
]
169-
ext_modules = cythonize(
170-
[
171-
Extension(
172-
f.replace("modelopt/core", "modelopt_core").replace(".py", "").replace("/", "."),
173-
sources=[f],
174-
)
175-
for f in compiled_files
176-
],
177-
compiler_directives={"language_level": "3"},
178-
build_dir="build/modelopt_core_build",
179-
)
180-
181-
class ModeloptBuildPy(build_py):
182-
"""A custom builder class to modify the python build process for regular installs.
183-
184-
The build process is executed during ``pip install .``. This is also triggered in certain cases
185-
during editable installs, i.e., ``pip install -e .``, starting from Python 3.9+. One trigger is
186-
when new packages are discovered!
187-
"""
188-
189-
def find_package_modules(self, *args, **kwargs):
190-
"""If a package exists as compiled version skip python version."""
191-
return [
192-
pm
193-
for pm in super().find_package_modules(*args, **kwargs)
194-
if pm[-1].replace(os.sep, "/") not in compiled_files
195-
]
196-
197-
setup_kwargs["ext_modules"] = ext_modules
198-
setup_kwargs["cmdclass"] = {"build_py": ModeloptBuildPy}
199-
else:
200-
# remove nvidia-modelopt-core dependency for internal installations / wheels
201-
required_deps = [dep for dep in required_deps if not dep.startswith("nvidia-modelopt-core")]
202-
203-
204121
if __name__ == "__main__":
205122
setuptools.setup(
206123
name=name,

0 commit comments

Comments
 (0)