@@ -83,6 +83,22 @@ func (c *PythonSpec) NameSpace(path string) (string, string, error) {
8383 // XXX: hardcoded python version
8484 condaPrefix := "/home/zhenyang/anaconda3/envs/abcoder/lib/python3.11"
8585 if strings .HasPrefix (path , condaPrefix ) {
86+ if strings .HasPrefix (path , condaPrefix + "/site-packages" ) {
87+ // external module
88+ relPath , err := filepath .Rel (condaPrefix + "/site-packages" , path )
89+ if err != nil {
90+ return "" , "" , err
91+ }
92+ relPath = strings .TrimSuffix (relPath , ".py" )
93+ pkgPath := strings .ReplaceAll (relPath , string (os .PathSeparator ), "." )
94+ modPath := strings .Split (pkgPath , "." )
95+ if len (modPath ) >= 1 {
96+ modName := modPath [0 ]
97+ return modName , pkgPath , nil
98+ }
99+ panic (fmt .Sprintf ("Malformed Namespace %s, pkgPath %s" , path , pkgPath ))
100+ }
101+ // builtin module
86102 modName := "builtins"
87103 relPath , err := filepath .Rel (condaPrefix , path )
88104 if err != nil {
@@ -93,7 +109,7 @@ func (c *PythonSpec) NameSpace(path string) (string, string, error) {
93109 return modName , pkgPath , nil
94110 }
95111
96- panic (fmt .Sprintf ("Namespace %s" , path ))
112+ panic (fmt .Sprintf ("Unhandled Namespace %s" , path ))
97113}
98114
99115func (c * PythonSpec ) ShouldSkip (path string ) bool {
0 commit comments