Skip to content

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

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

Closed
AkiSakurai opened this issue Nov 6, 2024 · 2 comments · Fixed by #6730
Labels
module: user experience Issues related to reducing friction for users

Comments

@AkiSakurai
Copy link
Contributor

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?

AkiSakurai added a commit to AkiSakurai/executorch that referenced this issue Jan 5, 2025
- Modified the method of retrieving the Python site-packages path to use `importlib.util.find_spec` for better compatibility.
- fix pytorch#6689
@mergennachin mergennachin moved this to To triage in ExecuTorch DevX Jan 7, 2025
@mcr229 mcr229 added the bug label Jan 14, 2025
@mergennachin mergennachin added the module: user experience Issues related to reducing friction for users label Jan 15, 2025
@larryliu0820
Copy link
Contributor

Thanks for your suggestion and fix! Marking this as resolved.

@larryliu0820 larryliu0820 moved this from To triage to Done in ExecuTorch DevX Feb 4, 2025
@larryliu0820 larryliu0820 closed this as completed by moving to Done in ExecuTorch DevX Feb 4, 2025
larryliu0820 pushed a commit that referenced this issue Mar 17, 2025
- Modified the method of retrieving the Python site-packages path to use `importlib.util.find_spec` for better compatibility.
- fix #6689
AkiSakurai added a commit to AkiSakurai/executorch that referenced this issue Mar 18, 2025
- 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 Mar 18, 2025
- 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 Apr 1, 2025
- Modified the method of retrieving the Python site-packages path to use `importlib.util.find_spec` for better compatibility.
- fix pytorch#6689
mergennachin pushed a commit that referenced this issue Apr 1, 2025
- Modified the method of retrieving the Python site-packages path to use
`importlib.util.find_spec` for better compatibility.
- fix #6689
kirklandsign pushed a commit that referenced this issue Apr 11, 2025
- Modified the method of retrieving the Python site-packages path to use
`importlib.util.find_spec` for better compatibility.
- fix #6689
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
module: user experience Issues related to reducing friction for users
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

5 participants