DOES NOT WORK!!! Windows 10 Instructions - PyNEC From Source in Anaconda 3 virtual environment with WSL2 + Ubuntu + VS2019
First of all, you need to follow the original installation instructions for PyNEC with respect to things you need to install on your computer.
This includes installing swig
and C/C++
compilers. I have Visual Studio 2019 Community Edition installed, which gives me the MSVC compiler tools. I installed swig 4.0.2
and added it to my PATH
.
When I tried the rest of the instructions, I couldn't get build.sh
to work. Presumably I need to install make
for Windows to get this to work? I think I also had trouble with the softlink. Will try again later
with git bash
trying to apply some of the things I learned here. However, I got it installed using the instructions below.
These modified instructions use Windows Subsystem for Linux for the make
and configure
steps, and assume WSL2
is installed as described here, a distro is installed (I use Ubuntu 20.04) and make
is installed.
I know I also had to apt install
several other things, including whatever provides libtoolize
. Linux should prompt you to resolve these issues when you're going through the commands. Also, presumably this works with the original Windows Subsystem for Linux, instead of WSL2
which requires a very-up-to-date windows installation, but unfortunately I haven't tested that.
Start by opening an Administrator Anaconda Command Prompt for the virtual environment you're installing in:
Then type:
git clone --recursive https://github.com/tmolteno/python-necpp/
cd python-necpp
cd PyNEC
mklink /d necpp_src ..\necpp_src
git submodule update --remote
Now open necpp_src/Makefile.am
in Visual Studio Code. At the bottom, see where it says CRLF
, click and change (at the top) to LF
then save the file. The motivation for this step is described here.
Now, return to the command prompt and type
wsl
cd necpp_src
make -f Makefile.git
./configure --without-lapack
exit
Now you should be back at the Anaconda command prompt (instead of linux). Make sure you're back in
the PyNEC
folder (you should be) and then type
python setup.py build
At this point, I get a bunch of errors and a linker failure!
LINK : error LNK2001: unresolved external symbol PyInit__PyNEC
However, this doesn't seem to be a problem.
Ignore the failure and type
pip install .
This successfully builds the wheel and installs PyNEC
in the virtual environment.
I don't know how to softlink necpp_src
without being an administrator. This is not an issue on my machine, but it's inconvenient and could be a dealbreaker for those without admin access. Presumably something
in the makefile or something could be changed to do this without softlinking?
The symbolic link needs to be in place for pip
and python setup.py build
so a Linux symlink doesn't work.
The biggest issue is cleaning up the admin-created python-necpp
source directory, which I do with RMDIR /S python-necpp
.