File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -57,6 +57,7 @@ pub struct Componentize {
5757 /// directory will be searched for a `site-packages` subdirectory, which will be appended to the path as a
5858 /// convenience for `venv` users. Alternatively, if `pipenv` is in `$PATH` and `pipenv --venv` produces a
5959 /// non-empty result, it will be searched for a `site-packages` subdirectory, which will likewise be appended.
60+ /// If the previous options fail, the `site` module in python will be used to get the `site-packages`
6061 #[ arg( short = 'p' , long, default_value = "." ) ]
6162 pub python_path : Vec < String > ,
6263
@@ -156,7 +157,18 @@ fn find_site_packages() -> Result<Option<PathBuf>> {
156157 }
157158 } else {
158159 // `pipenv` is in `$PATH`, but this app does not appear to be using it
159- None
160+ // Get site packages location using the `site` module in python
161+ match process:: Command :: new ( "python3" )
162+ . args ( [ "-c" , "import site; print(site.getsitepackages()[0])" ] )
163+ . output ( )
164+ {
165+ Ok ( output) => {
166+ let path =
167+ Path :: new ( str:: from_utf8 ( & output. stdout ) ?. trim ( ) ) . to_path_buf ( ) ;
168+ Some ( path)
169+ }
170+ Err ( _) => None ,
171+ }
160172 }
161173 }
162174 Err ( _) => {
You can’t perform that action at this time.
0 commit comments