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_INSTALL_PREFIX:PATH=/data/tools/ubuntu_22.04/lammps/2jun2022/ \
    -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:


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

//Build PYTHON Package

//No help, variable specified on the command line.

//Dependencies for the target

//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 Properties
//Path to a file.
//Python Properties
//Path to a library.

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

$ find /data/tools/ubuntu_22.04/python/3.11.2 -name "libpython3*"

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:


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:


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.