diff --git a/doc/src/Python_install.rst b/doc/src/Python_install.rst index 79cbca6242..aaeeec18f1 100644 --- a/doc/src/Python_install.rst +++ b/doc/src/Python_install.rst @@ -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-----.whl file (the + 'wheel'). And this file can be later installed directly with + ``python -m pip install .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 diff --git a/python/install.py b/python/install.py index 7cce42d2ba..e4a8b6af7b 100644 --- a/python/install.py +++ b/python/install.py @@ -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)