pyamgx icon indicating copy to clipboard operation
pyamgx copied to clipboard

The issues on building on windows

Open pyramidpoint opened this issue 5 years ago • 11 comments

pyramidpoint avatar Apr 15 '19 05:04 pyramidpoint

@shwina after python setuyp.py install ,this error occurred. image

pyramidpoint avatar Apr 15 '19 05:04 pyramidpoint

Did you install into a Conda environment? If so, did you activate the environment before launching the Python interpreter?

shwina avatar Apr 15 '19 13:04 shwina

@shwina I have installed the
- numpy - scipy - cudatoolkit=9.0 - amgx and I use the base environment

pyramidpoint avatar Apr 16 '19 06:04 pyramidpoint

Thanks - I'm not sure what the issue is and I'm unable to diagnose currently without access to a Windows machine. I suspect that the path to the AMGX libraries is missing from the PATH. Can you inspect the value of the PATH?

shwina avatar Apr 17 '19 16:04 shwina

@pyramidpoint were you able to resolve this or are you still having this issue?

shwina avatar Apr 25 '19 10:04 shwina

@shwina I still have this problem but I can implement it in C,win10,vs2015

pyramidpoint avatar Apr 25 '19 13:04 pyramidpoint

@shwina Hi~ I am trying to build pyamgx on windows, but run into this error image could you help me with this, please? FYI, I have built amgx by msvc2017 and set windows environment variable AMGX_DIR. Many thanks in advance!

lacrymose avatar Aug 18 '20 08:08 lacrymose

Hi @lacrymose. Unfortunately, I don't have access to a Windows machine to test currently, but it looks like the problem you're encountering is similar to the one described here: https://github.com/Unidata/netcdf4-python/issues/460

Could I ask you to try the fix for that issue (https://github.com/Unidata/netcdf4-python/pull/461)?

Specifically, you would have to change this part of setup.py:

from Cython.Build import cythonize
ext = cythonize([
    Extension(
        'pyamgx',
        sources=['pyamgx/pyamgx.pyx'],
        depends=['pyamgx/*.pyx, pyamgx/*.pxi'],
        libraries=['amgxsh'],
        language='c',
        include_dirs = [
            numpy.get_include(),
        ] + AMGX_include_dirs,
        library_dirs = [
            numpy.get_include(),
        ] + AMGX_lib_dirs,
        runtime_library_dirs = [
            numpy.get_include(),
        ] + AMGX_lib_dirs,
)])

to this:

if sys.platform == "win32":
    runtime_lib_dirs = []
else:
    runtime_lib_dirs = [numpy.get_include(),] + AMGX_lib_dirs

from Cython.Build import cythonize
ext = cythonize([
    Extension(
        'pyamgx',
        sources=['pyamgx/pyamgx.pyx'],
        depends=['pyamgx/*.pyx, pyamgx/*.pxi'],
        libraries=['amgxsh'],
        language='c',
        include_dirs = [
            numpy.get_include(),
        ] + AMGX_include_dirs,
        library_dirs = [
            numpy.get_include(),
        ] + AMGX_lib_dirs,
        runtime_lib_dirs=runtime_lib_dirs
)])

If that works, you are more than welcome to submit the change as a PR to this repository.

shwina avatar Aug 18 '20 12:08 shwina

Hi @lacrymose. Unfortunately, I don't have access to a Windows machine to test currently, but it looks like the problem you're encountering is similar to the one described here: Unidata/netcdf4-python#460

Could I ask you to try the fix for that issue (Unidata/netcdf4-python#461)? ...

I can confirm that it works. But as runtime_lib_dirs are removed, Windows needs some help to locate the runtime library. Or error like this will occur.

@shwina after python setuyp.py install ,this error occurred. image

This can be done by either adding amgxsh.dll into PATH manually

set PATH=path/to/your/library;%PATH%
:: for example
:: set PATH=path/to/your/AMGX/build/Release;%PATH%

or build the package with the runtime as component like:

if sys.platform == "win32":
    # find the path to .dll runtime
    data_files = [('', [os.path.join(AMGX_BUILD_DIR, 'Release/amgxsh.dll')])]
else:
    data_files = []

...
setup(...
      data_files=data_files,
      ...)

A complete version can be fount here (with another pr's fix merged for compatibility with AMGX 2.4.0).

yanang007 avatar Dec 31 '23 09:12 yanang007

Hi @yanang007

Thanks for the update! While I don't actively develop this package anymore, I would be happy to merge a PR if you opened one.

shwina avatar Dec 31 '23 09:12 shwina

Hi @shwina, sure! I could make a pr after making it more generic!

yanang007 avatar Dec 31 '23 12:12 yanang007