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:
@ -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
|
folders are searched by default by Python or the LAMMPS Python
|
||||||
package.
|
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
|
For the traditional make process you can override the python
|
||||||
version to version x.y when calling ``make`` with
|
version to version x.y when calling ``make`` with
|
||||||
``PYTHON=pythonX.Y``. For a CMake based compilation this choice
|
``PYTHON=pythonX.Y``. For a CMake based compilation this choice
|
||||||
|
|||||||
@ -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)
|
txt = subprocess.check_output([sys.executable, '-m', 'pip', 'install', '--force-reinstall', wheel], stderr=subprocess.STDOUT, shell=False)
|
||||||
print(txt.decode('UTF-8'))
|
print(txt.decode('UTF-8'))
|
||||||
continue
|
continue
|
||||||
except:
|
except subprocess.CalledProcessError as err:
|
||||||
pass
|
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:
|
try:
|
||||||
print('Installing wheel into standard site-packages folder failed. Trying user folder now')
|
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)
|
txt = subprocess.check_output([sys.executable, '-m', 'pip', 'install', '--user', '--force-reinstall', wheel], stderr=subprocess.STDOUT, shell=False)
|
||||||
|
|||||||
Reference in New Issue
Block a user