31
31
# check if the isaac-sim directory exists
32
32
if not os .path .exists (isaacsim_dir ):
33
33
raise FileNotFoundError (
34
- f"Could not find the isaac-sim directory: { isaacsim_dir } . There are two possible reasons for this:\n "
35
- " \ t 1. The Isaac Sim directory does not exist as a symlink in the Isaac Lab directory. \n "
36
- "\t 2. The script could import the 'isaacsim' package. This could be due to the 'isaacsim' package not being "
34
+ f"Could not find the isaac-sim directory: { isaacsim_dir } . There are two possible reasons for this:"
35
+ f" \n \ t 1. The Isaac Sim directory does not exist as a symlink at: { os . path . join ( ISAACLAB_DIR , '_isaac_sim' ) } "
36
+ "\n \ t 2. The script could import the 'isaacsim' package. This could be due to the 'isaacsim' package not being "
37
37
"installed in the Python environment.\n "
38
- "Please make sure that the Isaac Sim directory exists or that the 'isaacsim' package is installed."
38
+ "\n Please make sure that the Isaac Sim directory exists or that the 'isaacsim' package is installed."
39
39
)
40
40
41
41
ISAACSIM_DIR = isaacsim_dir
@@ -48,39 +48,49 @@ def overwrite_python_analysis_extra_paths(isaaclab_settings: str) -> str:
48
48
The extraPaths are replaced with the path names from the isaac-sim settings file that exists in the
49
49
"{ISAACSIM_DIR}/.vscode/settings.json" file.
50
50
51
+ If the isaac-sim settings file does not exist, the extraPaths are not overwritten.
52
+
51
53
Args:
52
54
isaaclab_settings: The settings string to use as template.
53
55
54
56
Returns:
55
57
The settings string with overwritten python analysis extra paths.
56
-
57
- Raises:
58
- FileNotFoundError: If the isaac-sim settings file does not exist.
59
58
"""
60
59
# isaac-sim settings
61
60
isaacsim_vscode_filename = os .path .join (ISAACSIM_DIR , ".vscode" , "settings.json" )
62
- # make sure the isaac-sim settings file exists
63
- if not os .path .exists (isaacsim_vscode_filename ):
64
- raise FileNotFoundError (f"Could not find the isaac-sim settings file: { isaacsim_vscode_filename } " )
65
-
66
- # read the path names from the isaac-sim settings file
67
- with open (isaacsim_vscode_filename ) as f :
68
- vscode_settings = f .read ()
69
- # extract the path names
70
- # search for the python.analysis.extraPaths section and extract the contents
71
- settings = re .search (r"\"python.analysis.extraPaths\": \[.*?\]" , vscode_settings , flags = re .MULTILINE | re .DOTALL )
72
- settings = settings .group (0 )
73
- settings = settings .split ('"python.analysis.extraPaths": [' )[- 1 ]
74
- settings = settings .split ("]" )[0 ]
75
-
76
- # read the path names from the isaac-sim settings file
77
- path_names = settings .split ("," )
78
- path_names = [path_name .strip ().strip ('"' ) for path_name in path_names ]
79
- path_names = [path_name for path_name in path_names if len (path_name ) > 0 ]
80
-
81
- # change the path names to be relative to the Isaac Lab directory
82
- rel_path = os .path .relpath (ISAACSIM_DIR , ISAACLAB_DIR )
83
- path_names = ['"${workspaceFolder}/' + rel_path + "/" + path_name + '"' for path_name in path_names ]
61
+
62
+ # we use the isaac-sim settings file to get the python.analysis.extraPaths for kit extensions
63
+ # if this file does not exist, we will not add any extra paths
64
+ if os .path .exists (isaacsim_vscode_filename ):
65
+ # read the path names from the isaac-sim settings file
66
+ with open (isaacsim_vscode_filename ) as f :
67
+ vscode_settings = f .read ()
68
+ # extract the path names
69
+ # search for the python.analysis.extraPaths section and extract the contents
70
+ settings = re .search (
71
+ r"\"python.analysis.extraPaths\": \[.*?\]" , vscode_settings , flags = re .MULTILINE | re .DOTALL
72
+ )
73
+ settings = settings .group (0 )
74
+ settings = settings .split ('"python.analysis.extraPaths": [' )[- 1 ]
75
+ settings = settings .split ("]" )[0 ]
76
+
77
+ # read the path names from the isaac-sim settings file
78
+ path_names = settings .split ("," )
79
+ path_names = [path_name .strip ().strip ('"' ) for path_name in path_names ]
80
+ path_names = [path_name for path_name in path_names if len (path_name ) > 0 ]
81
+
82
+ # change the path names to be relative to the Isaac Lab directory
83
+ rel_path = os .path .relpath (ISAACSIM_DIR , ISAACLAB_DIR )
84
+ path_names = ['"${workspaceFolder}/' + rel_path + "/" + path_name + '"' for path_name in path_names ]
85
+ else :
86
+ path_names = []
87
+ print (
88
+ f"[WARN] Could not find Isaac Sim VSCode settings: { isaacsim_vscode_filename } ."
89
+ "\n \t This will result in missing 'python.analysis.extraPaths' in the VSCode"
90
+ "\n \t settings, which limits the functionality of the Python language server."
91
+ "\n \t However, it does not affect the functionality of the Isaac Lab project."
92
+ "\n \t We are working on a fix for this issue with the Isaac Sim team."
93
+ )
84
94
85
95
# add the path names that are in the Isaac Lab extensions directory
86
96
isaaclab_extensions = os .listdir (os .path .join (ISAACLAB_DIR , "source" , "extensions" ))
@@ -89,9 +99,9 @@ def overwrite_python_analysis_extra_paths(isaaclab_settings: str) -> str:
89
99
# combine them into a single string
90
100
path_names = ",\n \t \t " .expandtabs (4 ).join (path_names )
91
101
# deal with the path separator being different on Windows and Unix
92
- path_names = path_names .replace ("/ " , os . sep )
102
+ path_names = path_names .replace ("\\ " , "/" )
93
103
94
- # replace the path names in the Isaac Lab settings file with the path names from the isaac-sim settings file
104
+ # replace the path names in the Isaac Lab settings file with the path names parsed
95
105
isaaclab_settings = re .sub (
96
106
r"\"python.analysis.extraPaths\": \[.*?\]" ,
97
107
'"python.analysis.extraPaths": [\n \t \t ' .expandtabs (4 ) + path_names + "\n \t ]" .expandtabs (4 ),
@@ -116,10 +126,7 @@ def overwrite_default_python_interpreter(isaaclab_settings: str) -> str:
116
126
The settings string with overwritten default python interpreter.
117
127
"""
118
128
# read executable name
119
- python_exe = sys .executable
120
- # if python interpreter is from conda, use that. Otherwise, use the template.
121
- if "conda" not in python_exe :
122
- return isaaclab_settings
129
+ python_exe = sys .executable .replace ("\\ " , "/" )
123
130
# replace the default python interpreter in the Isaac Lab settings file with the path to the
124
131
# python interpreter in the Isaac Lab directory
125
132
isaaclab_settings = re .sub (
@@ -146,9 +153,9 @@ def main():
146
153
147
154
# overwrite the python.analysis.extraPaths in the Isaac Lab settings file with the path names
148
155
isaaclab_settings = overwrite_python_analysis_extra_paths (isaaclab_template_settings )
149
- # overwrite the default python interpreter in the Isaac Lab settings file
150
- # NOTE: thisis disabled since we don't need it. The default interpreter should always be the one from isaac-sim
151
- # isaaclab_settings = overwrite_default_python_interpreter(isaaclab_settings)
156
+ # overwrite the default python interpreter in the Isaac Lab settings file with the path to the
157
+ # python interpreter used to call this script
158
+ isaaclab_settings = overwrite_default_python_interpreter (isaaclab_settings )
152
159
153
160
# add template notice to the top of the file
154
161
header_message = (
0 commit comments