kelvinou01 / conda-which

Which package does this file belong to?
MIT License
2 stars 0 forks source link

Check if you have an absolute path before looking for a file #2

Closed jypeter closed 2 months ago

jypeter commented 3 months ago

If you want to make your extension more foolproof, you could check if the path supplied by the user is absolute before looking for the file

On the other hand, you could also:

(bauer_env)  >conda which lib/python3.12/site-packages/bs4/formatter.py
Environments from ~/.condarc/environments.txt: {'/home/share/unix_files/cdat/miniconda3_21-02/envs/cdatm_py3', '/home/share/unix_files/cdat/miniconda3_2024-03/envs/bauer_env', '/home/share/unix_files/cdat/miniconda3_2024-03'}

File 'lib/python3.12/site-packages/bs4/formatter.py' does not exist

(bauer_env) >conda which /home/share/unix_files/cdat/miniconda3_2024-03/envs/bauer_env/lib/python3.12/site-packages/bs4/formatter.py
Environments from ~/.condarc/environments.txt: {'/home/share/unix_files/cdat/miniconda3_2024-03/envs/bauer_env', '/home/share/unix_files/cdat/miniconda3_2024-03', '/home/share/unix_files/cdat/miniconda3_21-02/envs/cdatm_py3'}
File '/home/share/unix_files/cdat/miniconda3_2024-03/envs/bauer_env/lib/python3.12/site-packages/bs4/formatter.py' belongs to
  📦 Package: beautifulsoup4-4.12.3-pyha770c72_0
  🌏 Environment: /home/share/unix_files/cdat/miniconda3_2024-03/envs/bauer_env
kelvinou01 commented 2 months ago

Hey @jypeter, the behavior with relative paths is intended. In linux convention, relative paths are assumed to be w.r.t the cwd.

Also, prepending the environments' paths would lead to correctness issues. For example, bin/clean may be used by two different packages installed in two different environments.