LAMMPS build - CMake - Not using Python I specify

I have compiled my own python installation with additional libraries for m3gnet to be used with LAMMPS. When I run cmake and specify to use my own python build, it is ignored and instead uses the system python. As a general rule, I keep my compiled code separate from OS provided packages for security and sanity.

Script/commands I use to run cmake

cd /data/tools/download/lammps/build

cmake ../lammps/cmake \
    -DCMAKE_VERBOSE_MAKEFILE:BOOL=yes \
    -DCMAKE_INSTALL_PREFIX:PATH=/data/tools/ubuntu_22.04/lammps/2jun2022/ \
    -DPKG_PYTHON:BOOL=yes \
    -DPYTHON_EXECUTABLE:FILEPATH=/data/tools/ubuntu_22.04/python/3.11.2/bin/python3 \
    | tee cmake.log

After running previous command/script, I get the CMake Warning:

CMake Warning:
  Manually-specified variables were not used by the project:

    PYTHON_EXECUTABLE

While digging through the CMakeCache.txt for python references, the following show up:

//Build PYTHON Package
PKG_PYTHON:BOOL=yes

//No help, variable specified on the command line.
PYTHON_EXECUTABLE:FILEPATH=/data/tools/ubuntu_22.04/python/3.11.2/bin/python3

//Dependencies for the target
lammps_LIB_DEPENDS:STATIC=general;JPEG::JPEG;general;PNG::PNG;general;ZLIB::ZLIB;general;Python::Python;general;/usr/lib/x86_64-linux-gnu/libm.so;general;dl;

//Details about finding Python
FIND_PACKAGE_MESSAGE_DETAILS_Python:INTERNAL=[/usr/bin/python3.10][cfound components: Interpreter ][v3.10.6()]

//Path to a program.
_Python3_EXECUTABLE:INTERNAL=/usr/bin/python3.10
//Python3 Properties
_Python3_INTERPRETER_PROPERTIES:INTERNAL=Python;3;10;6;64;;cpython-310-x86_64-linux-gnu;/usr/lib/python3.10;/usr/lib/python3.10;/usr/lib/python3/dist-packages;/usr/lib/python3/dist-packages
_Python3_INTERPRETER_SIGNATURE:INTERNAL=b91b4035ecb3bb3f5760d35922531bcd
_Python_DEVELOPMENT_EMBED_SIGNATURE:INTERNAL=625d9e0f7a1af1ddb80bfa11fbea90e0
_Python_DEVELOPMENT_MODULE_SIGNATURE:INTERNAL=4bc14a0ea6a21ea267e38aa660e9b54b
_Python_EXECUTABLE:INTERNAL=/usr/bin/python3.10
//Path to a file.
_Python_INCLUDE_DIR:INTERNAL=/usr/include/python3.10
//Python Properties
_Python_INTERPRETER_PROPERTIES:INTERNAL=Python;3;10;6;64;;cpython-310-x86_64-linux-gnu;/usr/lib/python3.10;/usr/lib/python3.10;/usr/lib/python3/dist-packages;/usr/lib/python3/dist-packages
_Python_INTERPRETER_SIGNATURE:INTERNAL=b91b4035ecb3bb3f5760d35922531bcd
//Path to a library.
_Python_LIBRARY_RELEASE:INTERNAL=/usr/lib/x86_64-linux-gnu/libpython3.10.so

The only significant clue I have is that CMake finds a libpython3.10.so where my installation does not have an .so file... only .a files.

$ find /data/tools/ubuntu_22.04/python/3.11.2 -name "libpython3*"
/data/tools/ubuntu_22.04/python/3.11.2/lib/python3.11/config-3.11-x86_64-linux-gnu/libpython3.11.a
/data/tools/ubuntu_22.04/python/3.11.2/lib/libpython3.11.a

I have dug through the documentation. I'm at a loss. Any insights or suggestions on something I missed in the build documentation is appreciated.

Have you tried using -D Python_EXECUTABLE?

-DPYTHON_EXECUTABLE:FILEPATH=/data/tools/ubuntu_22.04/python/3.11.2/bin/python3 should be the same as -D PYTHON_EXECUTABLE:FILEPATH=…

Tried adding the [SPC] between - same results

CMake Warning:
  Manually-specified variables were not used by the project:

    PYTHON_EXECUTABLE

When changing to Python_EXECUTABLE … the CMake Warning goes away.

After compiling LAMMPS- when I run

$lmp -h
Help shows PYTHON as a compiled packageInstalled packages:

PYTHON 

References to python in CMakeCache are inline with expectations as well !!!

Thank You !!!

You are using all caps, my suggestion didn’t.

Noticed that - and it works!!! - Thank You

Sorry, my bad. I was reading on a phone and didn’t scroll to the second part of your message since the first part looked like a repetition of the previous.

1 Like

Would also add that -D Python3_EXECUTABLE will likely need to be set as well. After running cmake- load up CMakeCache.txt and look for references to python and make sure they’re all pointing at your custom install [rather than a system install].

Thank you for your note. This can be remedied in the CMake scripts in use and will be implemented in the next feature release of LAMMPS.

But be reassured, this has no negative impact on building executables. The cases that need updating are the configuration for building the documentation and the configuration for the python scripts checking for coding style conformance. Those will run just fine if they use the system python.