r9y9/pyopenjtalk

Windows support

r9y9 opened this issue · 3 comments

r9y9 commented

It should be possible to support Windows as well, but I don't have a machine to test. Would be nice if anyone wants to contribute to this.

I tried to build pyopenjtalk in a Windows environment.
I rewrote setup.py and mecab/src/config.h as follows, and was able to synthesize speech without any problems.

setup.py
Hiroshiba@6630457

mecab/src/config.h
/* #undef HAVE_WINDOWS_H */ to #define HAVE_WINDOWS_H 1
/* #undef VERSION */to #define VERSION "1.10"
#define HAVE_DIRENT_H 1 to // #define HAVE_DIRENT_H 1

I think setup.py can be made more stylish by adding the windows flag, but I don't have a good idea for config.h.
(Windows does not have cmake, so the following code does not work...)

pyopenjtalk/setup.py

Lines 49 to 55 in d28b910

if not exists(join(src_top, "mecab", "src", "config.h")):
cwd = os.getcwd()
build_dir = join(src_top, "build")
os.makedirs(build_dir, exist_ok=True)
os.chdir(build_dir)
run(["cmake", ".."])
os.chdir(cwd)

r9y9 commented

Thanks for looking into this. A cleaner way is to write a script that generates config.h. i.e. what cmake currently does: https://github.com/r9y9/open_jtalk/blob/22213146d3491d708ec9b827851de8c0bbca29d7/src/CMakeLists.txt#L43-L79.

It would not be that hard technically but I guess we need to write a bunch of python code to handle run-time check property (parsing config.in, checking headers if exist, checking functions available, etc).

The easiest but not perfect way is to include a pre-generated config.h into the repo and use it at the build time. However, I am reluctant to do this as it may not work on other platforms.

I see.
I think it's a smart solution, but it will take some effort.
If that method is implemented, I will try to run it on windows.
Thanks!