symmetryinvestments / autowrap

Wrap existing D code for use in Python, Excel, C#
BSD 3-Clause "New" or "Revised" License
80 stars 16 forks source link

Q: what config (env var) needed for pynih Python3? #299

Closed mw66 closed 3 years ago

mw66 commented 3 years ago

I'm trying to use pynih, with a simple dub.sdl:

name "demo"
targetType "dynamicLibrary"

configuration "pynih" {
    targetPath "."
    lflags "-L$PYTHON_LIB_DIR"
    dependency "autowrap:pynih"  version="~>0.6.3"
}

but it errors out:

$ dub build --config=pynih
Running pre-generate commands for autowrap:pynih...
make[1]: Entering directory '/root/.dub/packages/autowrap-0.6.3/autowrap/pynih'
make[1]: 'source/python/raw.d' is up to date.
make[1]: Leaving directory '/root/.dub/packages/autowrap-0.6.3/autowrap/pynih'
Performing "debug" build using /usr/bin/dmd for x86_64.
autowrap:common 0.6.3: target for configuration "library" is up to date.
mirror 0.3.0: target for configuration "library" is up to date.
autowrap:reflection 0.6.3: target for configuration "library" is up to date.
autowrap:pynih 0.6.3: building configuration "default"...
/root/.dub/packages/autowrap-0.6.3/autowrap/pynih/source/autowrap/pynih/wrap.d(70,5): Error: static assert:  "Python2 no longer supported"
/usr/bin/dmd failed with exit code 1.

I'm wondering why it pick up Python2 by default? or what config (env var) needed for force pynih use Python3?

mw66 commented 3 years ago

Never mind. I found the problem, it's caused by:

when I first time build the autowrap library via dub, the system default python is symlink-ed to python2, and then I change the symlink to python3, but the dub is still using the ~/.dub/packages/autowrap-0.6.3/autowrap/pynih/source/python/raw.d generated by dpp on python2 from the 1st time build. Thus causing the confusing error message.