Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No such file or directory: '/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/torchgen/packaged/ATen/native/native_functions.yaml' #6689

Open
AkiSakurai opened this issue Nov 6, 2024 · 1 comment · May be fixed by #6730

Comments

@AkiSakurai
Copy link

AkiSakurai commented Nov 6, 2024

It is not necessary for the package to be located in get_python_lib.

For example, when compiling PyTorch from source using python3 setup.py develop, the package is located directly in the source folder.

Note that I cannot use the prebuilt PyTorch package, as it is no longer available on Intel Macs.

importlib.util.find_spec('torchgen') might be more portable.

diff --git a/build/Codegen.cmake b/build/Codegen.cmake
index 435b3d2..f772e36 100644
--- a/build/Codegen.cmake
+++ b/build/Codegen.cmake
@@ -79,19 +79,19 @@ function(generate_bindings_for_kernels)
   execute_process(
     COMMAND
       "${PYTHON_EXECUTABLE}" -c
-      "from distutils.sysconfig import get_python_lib;print(get_python_lib())"
+      "import importlib;print(importlib.util.find_spec('torchgen').submodule_search_locations[0])"
     OUTPUT_VARIABLE site-packages-out
     ERROR_VARIABLE site-packages-out-error
     RESULT_VARIABLE site-packages-result
     WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
     OUTPUT_STRIP_TRAILING_WHITESPACE
   )
-  file(GLOB_RECURSE _torchgen_srcs "${site-packages-out}/torchgen/*.py")
+  file(GLOB_RECURSE _torchgen_srcs "${site-packages-out}/*.py")
   set(_gen_command
       "${PYTHON_EXECUTABLE}" -m torchgen.gen_executorch
       --source-path=${EXECUTORCH_ROOT}/codegen --install-dir=${_out_dir}
-      --tags-path=${site-packages-out}/torchgen/packaged/ATen/native/tags.yaml
-      --aten-yaml-path=${site-packages-out}/torchgen/packaged/ATen/native/native_functions.yaml
+      --tags-path=${site-packages-out}/packaged/ATen/native/tags.yaml
+      --aten-yaml-path=${site-packages-out}/packaged/ATen/native/native_functions.yaml
       --op-selection-yaml-path=${_oplist_yaml}
   )
AkiSakurai added a commit to AkiSakurai/executorch that referenced this issue Nov 8, 2024
- Modified the method of retrieving the Python site-packages path to use `importlib.util.find_spec` for better compatibility.
- fix pytorch#6689
AkiSakurai added a commit to AkiSakurai/executorch that referenced this issue Nov 8, 2024
- Modified the method of retrieving the Python site-packages path to use `importlib.util.find_spec` for better compatibility.
- fix pytorch#6689
@JacobSzwejbka
Copy link
Contributor

@larryliu0820 @dbort @GregoryComer can you take a look?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants