Skip to content

Commit df99573

Browse files
authored
fix pip3 install error for example like cutlass-gemm in local build. (#311)
following the https://github.com/huggingface/kernel-builder/blob/main/docs/local-dev.md error like ``` copying /tmp/tmpbzk7cg7n.build-lib/cutlass-gemm/_cutlass_gemm_0063d52.abi3.so -> torch-ext/cutlass-gemm Traceback (most recent call last): File "/opt/venv/lib/python3.12/site-packages/setuptools/_distutils/file_util.py", line 39, in _copy_file_contents fdst = open(dst, 'wb') ^^^^^^^^^^^^^^^ FileNotFoundError: [Errno 2] No such file or directory: 'torch-ext/cutlass-gemm/_cutlass_gemm_0063d52.abi3.so' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/opt/venv/lib/python3.12/site-packages/setuptools/command/editable_wheel.py", line 139, in run self._create_wheel_file(bdist_wheel) File "/opt/venv/lib/python3.12/site-packages/setuptools/command/editable_wheel.py", line 340, in _create_wheel_file files, mapping = self._run_build_commands(dist_name, unpacked, lib, tmp) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/venv/lib/python3.12/site-packages/setuptools/command/editable_wheel.py", line 263, in _run_build_commands self._run_build_subcommands() File "/opt/venv/lib/python3.12/site-packages/setuptools/command/editable_wheel.py", line 290, in _run_build_subcommands self.run_command(name) File "/opt/venv/lib/python3.12/site-packages/setuptools/_distutils/cmd.py", line 357, in run_command self.distribution.run_command(command) File "/opt/venv/lib/python3.12/site-packages/setuptools/dist.py", line 1104, in run_command super().run_command(command) File "/opt/venv/lib/python3.12/site-packages/setuptools/_distutils/dist.py", line 1021, in run_command cmd_obj.run() File "/opt/venv/lib/python3.12/site-packages/setuptools/command/build_ext.py", line 102, in run self.copy_extensions_to_source() File "/opt/venv/lib/python3.12/site-packages/setuptools/command/build_ext.py", line 123, in copy_extensions_to_source self.copy_file(regular_file, inplace_file, level=self.verbose) File "/opt/venv/lib/python3.12/site-packages/setuptools/_distutils/cmd.py", line 421, in copy_file return file_util.copy_file( ^^^^^^^^^^^^^^^^^^^^ File "/opt/venv/lib/python3.12/site-packages/setuptools/_distutils/file_util.py", line 157, in copy_file _copy_file_contents(src, dst) File "/opt/venv/lib/python3.12/site-packages/setuptools/_distutils/file_util.py", line 41, in _copy_file_contents raise DistutilsFileError(f"could not create '{dst}': {e.strerror}") distutils.errors.DistutilsFileError: could not create 'torch-ext/cutlass-gemm/_cutlass_gemm_0063d52.abi3.so': No such file or directory /opt/venv/lib/python3.12/site-packages/setuptools/_distutils/dist.py:1021: _DebuggingTips: Problem in editable installation. ``` Signed-off-by: Wang, Yi A <yi.a.wang@intel.com>
1 parent 7bd8ac8 commit df99573

File tree

4 files changed

+20
-17
lines changed

4 files changed

+20
-17
lines changed

build2cmake/src/templates/cpu/setup.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,16 +104,17 @@ def build_extension(self, ext: CMakeExtension) -> None:
104104
)
105105

106106

107+
{% set python_name = name | replace('-', '_') %}
107108
setup(
108-
name="{{ name }}",
109+
name="{{ python_name }}",
109110
# The version is just a stub, it's not used by the final build artefact.
110111
version="0.1.0",
111-
ext_modules=[CMakeExtension("{{ name }}.{{ ops_name }}")],
112+
ext_modules=[CMakeExtension("{{ python_name }}.{{ ops_name }}")],
112113
cmdclass={"build_ext": CMakeBuild},
113-
packages=find_packages(where="torch-ext", include=["{{ name }}*"]),
114+
packages=find_packages(where="torch-ext", include=["{{ python_name }}*"]),
114115
package_dir={"": "torch-ext"},
115116
{% if data_globs %}
116-
package_data={"{{ name }}": [ {{ data_globs }} ]},
117+
package_data={"{{ python_name }}": [ {{ data_globs }} ]},
117118
{% endif %}
118119
zip_safe=False,
119120
install_requires=["torch"],

build2cmake/src/templates/cuda/setup.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -124,16 +124,17 @@ def build_extension(self, ext: CMakeExtension) -> None:
124124

125125

126126

127+
{% set python_name = name | replace('-', '_') %}
127128
setup(
128-
name="{{ name }}",
129+
name="{{ python_name }}",
129130
# The version is just a stub, it's not used by the final build artefact.
130131
version="0.1.0",
131-
ext_modules=[CMakeExtension("{{ name }}.{{ ops_name }}")],
132+
ext_modules=[CMakeExtension("{{ python_name }}.{{ ops_name }}")],
132133
cmdclass={"build_ext": CMakeBuild},
133-
packages=find_packages(where="torch-ext", include=["{{ name }}*"]),
134+
packages=find_packages(where="torch-ext", include=["{{ python_name }}*"]),
134135
package_dir={"": "torch-ext"},
135136
{% if data_globs %}
136-
package_data={"{{ name }}": [ {{ data_globs }} ]},
137+
package_data={"{{ python_name }}": [ {{ data_globs }} ]},
137138
{% endif %}
138139
zip_safe=False,
139140
install_requires=["torch"],

build2cmake/src/templates/metal/setup.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,16 +104,17 @@ def build_extension(self, ext: CMakeExtension) -> None:
104104
)
105105

106106

107+
{% set python_name = name | replace('-', '_') %}
107108
setup(
108-
name="{{ name }}",
109+
name="{{ python_name }}",
109110
# The version is just a stub, it's not used by the final build artefact.
110111
version="0.1.0",
111-
ext_modules=[CMakeExtension("{{ name }}.{{ ops_name }}")],
112+
ext_modules=[CMakeExtension("{{ python_name }}.{{ ops_name }}")],
112113
cmdclass={"build_ext": CMakeBuild},
113-
packages=find_packages(where="torch-ext", include=["{{ name }}*"]),
114+
packages=find_packages(where="torch-ext", include=["{{ python_name }}*"]),
114115
package_dir={"": "torch-ext"},
115116
{% if data_globs %}
116-
package_data={"{{ name }}": [ {{ data_globs }} ]},
117+
package_data={"{{ python_name }}": [ {{ data_globs }} ]},
117118
{% endif %}
118119
zip_safe=False,
119120
install_requires=["torch"],

build2cmake/src/templates/xpu/setup.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -105,17 +105,17 @@ def build_extension(self, ext: CMakeExtension) -> None:
105105
for filename in os.listdir(extdir / cfg):
106106
move(extdir / cfg / filename, extdir / filename)
107107

108-
108+
{% set python_name = name | replace('-', '_') %}
109109
setup(
110-
name="{{ name }}",
110+
name="{{ python_name }}",
111111
# The version is just a stub, it's not used by the final build artefact.
112112
version="0.1.0",
113-
ext_modules=[CMakeExtension("{{ name }}.{{ ops_name }}")],
113+
ext_modules=[CMakeExtension("{{ python_name }}.{{ ops_name }}")],
114114
cmdclass={"build_ext": CMakeBuild},
115-
packages=find_packages(where="torch-ext", include=["{{ name }}*"]),
115+
packages=find_packages(where="torch-ext", include=["{{ python_name }}*"]),
116116
package_dir={"": "torch-ext"},
117117
{% if data_globs %}
118-
package_data={"{{ name }}": [ {{ data_globs }} ]},
118+
package_data={"{{ python_name }}": [ {{ data_globs }} ]},
119119
{% endif %}
120120
zip_safe=False,
121121
install_requires=["torch"],

0 commit comments

Comments
 (0)