Wrapping LAMMPS in python on windows machine: Error 1

trying to wrap lammps and the shared library is missing. how should I solve this issue?
I am running on a Windows machine in Microsoft bash launcher

make serial install-python
make[1]: Entering directory '/mnt/d/Setups/LAMMPS/src/STUBS'
make[1]: 'libmpi_stubs.a' is up to date.
make[1]: Leaving directory '/mnt/d/Setups/LAMMPS/src/STUBS'
Gathering installed package information (may take a little while)
make[1]: Entering directory '/mnt/d/Setups/LAMMPS/src'
make[1]: 'lmpinstalledpkgs.h' is up to date.
Gathering git version information
make[1]: Leaving directory '/mnt/d/Setups/LAMMPS/src'
Compiling LAMMPS for machine serial
make[1]: Entering directory '/mnt/d/Setups/LAMMPS/src/Obj_serial'
make[1]: Leaving directory '/mnt/d/Setups/LAMMPS/src/Obj_serial'
make[1]: Entering directory '/mnt/d/Setups/LAMMPS/src/Obj_serial'
g++ -g -O -std=c++11 main.o  -L../STUBS    -L. -llammps_serial  -lmpi_stubs    -ldl  -o ../lmp_serial
size ../lmp_serial
   text    data     bss     dec     hex filename
7625703  179248    1808 7806759  771f27 ../lmp_serial
make[1]: Leaving directory '/mnt/d/Setups/LAMMPS/src/Obj_serial'
ERROR: LAMMPS shared library ../src/liblammps.so does not exist
usage: install.py [-h] -p PACKAGE -l LIB [-n] [-w WHEELDIR] -v VERSIONFILE

LAMMPS python package installer script

optional arguments:
  -h, --help            show this help message and exit
  -p PACKAGE, --package PACKAGE
                        path to the LAMMPS Python package
  -l LIB, --lib LIB     path to the compiled LAMMPS shared library
  -n, --noinstall       only build a binary wheel. Don't attempt to install it
  -w WHEELDIR, --wheeldir WHEELDIR
                        path to a directory where the created wheel will be
                        stored
  -v VERSIONFILE, --versionfile VERSIONFILE
                        path to the LAMMPS version.h source file
make: *** [Makefile:468: install-python] Error 1

Which version of LAMMPS are you trying to compile?
It doesn’t look like you compiled LAMMPS for building and linking to a shared library, but that is a prerequisite for the LAMMPS python module, since it uses the ctypes module to load the LAMMPS C library interface.
Is there a specific reason why you cannot use a pre-compiled LAMMPS executables for Windows?

I’m using LAMMPS (15 Jun 2023), and the examples run successfully outside of Python.
I need the src to run a custom fix command (Link found here)
How can I compile LAMMPS for building and linking to a shared library?

Just follow the documentation: 3.4. Basic build options — LAMMPS documentation

This seems to be written for a significantly older version of LAMMPS (4-5 years old) and thus will likely require some porting effort to run correctly with a current version. 4.10. Notes for updating code written for older LAMMPS versions — LAMMPS documentation

I use the same fix in the same version of LAMMPS on a Linux-based machine (on ComputeCanada) and it works just fine. Also, I can call pre-compiled LAMMPS (executables for Windows) on my current Windows-PC using python.
If I can call LAMMPS on my windows-PC, I’m sure I can run the fix in it

Hi @akohlmey
upon compiling in shared mode, I tried to install python into site-packages folder. But I got a NoneType error. Any idea how to solve this issue?

make serial mode=shlib
make install-python

results in:

Cleaning old build directory
Purging existing wheels...
Traceback (most recent call last):
  File "../python/install.py", line 84, in <module>
    os.chdir(builddir)
TypeError: coercing to Unicode: need string or buffer, NoneType found
make: *** [Makefile:468: install-python] Error 1

I have never seen this kind of failure before. Can you please edit the failing file python/install.py to add a print statement in line 84 so that it looks like this:

builddir = shutil.copytree(pythondir, os.path.join(olddir, 'build-python'))
print("builddir = ", builddir)
os.chdir(builddir)

Then run again and quote the output here. Thanks.