@@ -119,6 +119,46 @@ fn is_python_executable_name(exe: &Path) -> bool {
119119 }
120120}
121121
122+ pub fn should_search_for_environments_in_path < P : AsRef < Path > > ( path : & P ) -> bool {
123+ // Never search in the .git folder
124+ // Never search in the node_modules folder
125+ // Mostly copied from https://github.com/github/gitignore/blob/main/Python.gitignore
126+ let folders_to_ignore = [
127+ "node_modules" ,
128+ ".cargo" ,
129+ ".devcontainer" ,
130+ ".github" ,
131+ ".git" ,
132+ ".tox" ,
133+ ".nox" ,
134+ ".hypothesis" ,
135+ ".ipynb_checkpoints" ,
136+ ".eggs" ,
137+ ".coverage" ,
138+ ".cache" ,
139+ ".pyre" ,
140+ ".ptype" ,
141+ ".pytest_cache" ,
142+ ".vscode" ,
143+ "__pycache__" ,
144+ "__pypackages__" ,
145+ ".mypy_cache" ,
146+ "cython_debug" ,
147+ "env.bak" ,
148+ "venv.bak" ,
149+ "Scripts" , // If the folder ends bin/scripts, then ignore it, as the parent is most likely an env.
150+ "bin" , // If the folder ends bin/scripts, then ignore it, as the parent is most likely an env.
151+ ] ;
152+ for folder in folders_to_ignore. iter ( ) {
153+ if path. as_ref ( ) . ends_with ( folder) {
154+ trace ! ( "Ignoring folder: {:?}" , path. as_ref( ) ) ;
155+ return false ;
156+ }
157+ }
158+
159+ true
160+ }
161+
122162#[ cfg( test) ]
123163mod tests {
124164 use super :: * ;
@@ -186,43 +226,3 @@ mod tests {
186226 ) ) ;
187227 }
188228}
189-
190- pub fn should_search_for_environments_in_path < P : AsRef < Path > > ( path : & P ) -> bool {
191- // Never search in the .git folder
192- // Never search in the node_modules folder
193- // Mostly copied from https://github.com/github/gitignore/blob/main/Python.gitignore
194- let folders_to_ignore = [
195- "node_modules" ,
196- ".cargo" ,
197- ".devcontainer" ,
198- ".github" ,
199- ".git" ,
200- ".tox" ,
201- ".nox" ,
202- ".hypothesis" ,
203- ".ipynb_checkpoints" ,
204- ".eggs" ,
205- ".coverage" ,
206- ".cache" ,
207- ".pyre" ,
208- ".ptype" ,
209- ".pytest_cache" ,
210- ".vscode" ,
211- "__pycache__" ,
212- "__pypackages__" ,
213- ".mypy_cache" ,
214- "cython_debug" ,
215- "env.bak" ,
216- "venv.bak" ,
217- "Scripts" , // If the folder ends bin/scripts, then ignore it, as the parent is most likely an env.
218- "bin" , // If the folder ends bin/scripts, then ignore it, as the parent is most likely an env.
219- ] ;
220- for folder in folders_to_ignore. iter ( ) {
221- if path. as_ref ( ) . ends_with ( folder) {
222- trace ! ( "Ignoring folder: {:?}" , path. as_ref( ) ) ;
223- return false ;
224- }
225- }
226-
227- true
228- }
0 commit comments