quantumlib / OpenFermion

The electronic structure package for quantum computers.
Apache License 2.0
1.51k stars 372 forks source link

pip installation overwrites module directory #887

Open mfdgroot opened 2 months ago

mfdgroot commented 2 months ago

There seems to be an error when installing openfermion with pip into a specific target dir. When running pip install -t target openfermion, I get WARNING: Target directory /xxx/target/openfermion already exists. Specify --upgrade to force replacement.. This happens toward the end of the installation process. This is what's in the dir without running with --upgrade and getting the warning:

$ls target/openfermion
chem      _compat.py       config.py    contrib      hamiltonians  linalg        ops          py.typed            testing     utils
circuits  _compat_test.py  conftest.py  functionals  __init__.py   measurements  __pycache__  resource_estimates  transforms  _version.py

And this is after running with --upgrade and without warning:

$ls target/openfermion
docs

So all of the module files are also gone.

fdmalone commented 2 months ago

This looks like a common problem with pip: https://github.com/pypa/pip/issues/8063 that hasn't been resolved. @pavoljuhas have you encountered anything like this before?

forget-the-bright commented 1 month ago

已经被这个折磨一天了,最终选择折中的方法 ,使用pipx 我在下面记录我自己探索解决方法的过程 [Having been tortured by this all day, I finally chose the compromise and used pipx Below I document my own search for a solution] https://memos.haowuan.top/m/gUAJKSzdjEjJZk3grRWL8C

fdmalone commented 1 month ago

going to close this an issue with pip, feel free to reopen if there's another solution.

pavoljuhas commented 1 month ago

This looks like a common problem with pip: pypa/pip#8063 that hasn't been resolved. @pavoljuhas have you encountered anything like this before?

This seems to happen because openfermion declares documentation files as data_files and as such they would install under PREFIX/openfermion. The package sources go to PREFIX/lib/pythonX.Y/site-packages/openfermion. The --target=TARGET option makes pip install both the docs and sources to TARGET/openfermion and it seems only the documentation files survive.

I can think of two remedies

(1) use pip install --prefix=/path/to/prefix instead of --target=TARGET so that the openfermion directories for docs and package sources are different

OR

(2) update openfermion/setup.py to have documentation files included as package_data so they get installed somewhere under .../site-packages/openfermion instead of to PREFIX/openfermion.

fdmalone commented 1 month ago

thanks @pavoljuhas I think 2 is probably best.