document and handle the case of a previous distutils installation.

in this case 'make install-python' should not continue but instead
it now aborts and asks the user to do a manual uninstall
This commit is contained in:
Axel Kohlmeyer
2022-02-25 16:10:46 -05:00
parent bb3a5b4057
commit 578a7cc54c
2 changed files with 21 additions and 2 deletions

View File

@ -187,6 +187,23 @@ folder that the dynamic loader searches or inside of the installed
folders are searched by default by Python or the LAMMPS Python
package.
.. versionchanged:: TBD
.. note::
If there is an existing installation of the LAMMPS python
module, ``make install-python`` will try to update it.
However, that will fail if the older version of the module
was installed by LAMMPS versions until 17Feb2022. Those
were using the distutils package, which does not create a
"manifest" that allows a clean uninstall. The ``make
install-python`` command will always produce a
lammps-<version>-<python>-<abi>-<os>-<arch>.whl file (the
'wheel'). And this file can be later installed directly with
``python -m pip install <wheel file>.whl`` without having to
type ``make install-python`` again and repeating the build
step, too.
For the traditional make process you can override the python
version to version x.y when calling ``make`` with
``PYTHON=pythonX.Y``. For a CMake based compilation this choice

View File

@ -83,8 +83,10 @@ for wheel in glob.glob('lammps-*.whl'):
txt = subprocess.check_output([sys.executable, '-m', 'pip', 'install', '--force-reinstall', wheel], stderr=subprocess.STDOUT, shell=False)
print(txt.decode('UTF-8'))
continue
except:
pass
except subprocess.CalledProcessError as err:
errmsg = err.output.decode('UTF-8')
if errmsg.find("distutils installed"):
sys.exit(errmsg + "You need to uninstall the LAMMPS python module manually first.\n")
try:
print('Installing wheel into standard site-packages folder failed. Trying user folder now')
txt = subprocess.check_output([sys.executable, '-m', 'pip', 'install', '--user', '--force-reinstall', wheel], stderr=subprocess.STDOUT, shell=False)