dwavesystems / dwave-samplers

Classical algorithms for solving binary quadratic models
Apache License 2.0
8 stars 12 forks source link

Build breaks on some systems: Error compiling Cython file #32

Closed yurivict closed 4 months ago

yurivict commented 2 years ago
===>  Configuring for py39-dwave-samplers-1.0.0.d1

Error compiling Cython file:
------------------------------------------------------------
..

cimport numpy as np
from dimod cimport cyBQM_float64
from dimod.libcpp cimport cppBinaryQuadraticModel

from dwave.samplers.tree.orang cimport samples_type, PyArray_ENABLEFLAGS
^
------------------------------------------------------------

dwave/samplers/tree/sample.pyx:31:0: 'dwave/samplers/tree/orang.pxd' not found

Error compiling Cython file:
------------------------------------------------------------
..

cimport numpy as np
from dimod cimport cyBQM_float64
from dimod.libcpp cimport cppBinaryQuadraticModel

from dwave.samplers.tree.orang cimport samples_type, PyArray_ENABLEFLAGS
^
------------------------------------------------------------

dwave/samplers/tree/sample.pyx:31:0: 'dwave/samplers/tree/orang/samples_type.pxd' not found

Error compiling Cython file:
------------------------------------------------------------
..

cimport numpy as np
from dimod cimport cyBQM_float64
from dimod.libcpp cimport cppBinaryQuadraticModel

from dwave.samplers.tree.orang cimport samples_type, PyArray_ENABLEFLAGS
^
------------------------------------------------------------

dwave/samplers/tree/sample.pyx:31:0: 'dwave/samplers/tree/orang/PyArray_ENABLEFLAGS.pxd' not found

Error compiling Cython file:
------------------------------------------------------------
..
    # pass in pointers so that sample_bqm can fill things in
    cdef double logpf

    # samples
    cdef int srows, scols
    cdef samples_type* samples_pointer
        ^
------------------------------------------------------------

dwave/samplers/tree/sample.pyx:110:9: 'samples_type' is not a type identifier

Error compiling Cython file:
------------------------------------------------------------
..
              &pair_marginals_pointer, &pmrows, &pmcols,
              &pair_pointer, &prows, &pcols)

    # create a numpy array without making a copy then tell numpy it needs to
    # free the memory
    samples = np.asarray(<samples_type[:srows, :scols]> samples_pointer)
                         ^
------------------------------------------------------------

dwave/samplers/tree/sample.pyx:138:26: 'samples_type' is not a type identifier

Error compiling Cython file:
------------------------------------------------------------
..
              &pair_marginals_pointer, &pmrows, &pmcols,
              &pair_pointer, &prows, &pcols)

    # create a numpy array without making a copy then tell numpy it needs to
    # free the memory
    samples = np.asarray(<samples_type[:srows, :scols]> samples_pointer)
                                                       ^
------------------------------------------------------------

dwave/samplers/tree/sample.pyx:138:56: Can only create cython.array from pointer or array

Error compiling Cython file:
------------------------------------------------------------
..
              &pair_pointer, &prows, &pcols)

    # create a numpy array without making a copy then tell numpy it needs to
    # free the memory
    samples = np.asarray(<samples_type[:srows, :scols]> samples_pointer)
    PyArray_ENABLEFLAGS(samples, np.NPY_OWNDATA)
   ^
------------------------------------------------------------

dwave/samplers/tree/sample.pyx:139:4: 'PyArray_ENABLEFLAGS' is not a constant, variable or function identifier

Error compiling Cython file:
------------------------------------------------------------
..
                if samples[i, j] == 0:
                    samples[i, j] = -1

    if marginals:
        variable_marginals = np.asarray(<double[:smlen]> single_marginals_pointer)
        PyArray_ENABLEFLAGS(variable_marginals, np.NPY_OWNDATA)
       ^
------------------------------------------------------------

dwave/samplers/tree/sample.pyx:151:8: 'PyArray_ENABLEFLAGS' is not a constant, variable or function identifier

Error compiling Cython file:
------------------------------------------------------------
..
        variable_marginals = np.asarray(<double[:smlen]> single_marginals_pointer)
        PyArray_ENABLEFLAGS(variable_marginals, np.NPY_OWNDATA)

        if pmrows * pmcols:
            interaction_marginals = np.asarray(<double[:pmrows, :pmcols]> pair_marginals_pointer)
            PyArray_ENABLEFLAGS(interaction_marginals, np.NPY_OWNDATA)
           ^
------------------------------------------------------------

dwave/samplers/tree/sample.pyx:155:12: 'PyArray_ENABLEFLAGS' is not a constant, variable or function identifier

Error compiling Cython file:
------------------------------------------------------------
..
        else:
            interaction_marginals = np.empty(shape=(pmrows, pmcols), dtype=np.double)

        if prows * pcols:
            interactions = np.asarray(<int[:prows, :pcols]> pair_pointer)
            PyArray_ENABLEFLAGS(interactions, np.NPY_OWNDATA)
           ^
------------------------------------------------------------

dwave/samplers/tree/sample.pyx:161:12: 'PyArray_ENABLEFLAGS' is not a constant, variable or function identifier
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "setup.py", line 53, in <module>
    ext_modules=cythonize(
  File "/usr/local/lib/python3.9/site-packages/Cython/Build/Dependencies.py", line 1127, in cythonize
    cythonize_one(*args)
  File "/usr/local/lib/python3.9/site-packages/Cython/Build/Dependencies.py", line 1250, in cythonize_one
    raise CompileError(None, pyx_file)
Cython.Compiler.Errors.CompileError: dwave/samplers/tree/sample.pyx
Compiling dwave/samplers/random/cyrandom.pyx because it depends on /usr/local/lib/python3.9/site-packages/dimod/quadratic/cyqm/cyqm_template.pxd.pxi.
Compiling dwave/samplers/tree/sample.pyx because it depends on /usr/local/lib/python3.9/site-packages/dimod/quadratic/cyqm/cyqm_template.pxd.pxi.
Compiling dwave/samplers/tree/solve.pyx because it depends on /usr/local/lib/python3.9/site-packages/dimod/quadratic/cyqm/cyqm_template.pxd.pxi.
Compiling dwave/samplers/tree/utilities.pyx because it depends on /usr/local/lib/python3.9/site-packages/dimod/quadratic/cyqm/cyqm_template.pxd.pxi.
[1/4] Cythonizing dwave/samplers/random/cyrandom.pyx
[2/4] Cythonizing dwave/samplers/tree/sample.pyx
*** Error code 1

Version: 1.0.0.dev1 OS: FreeBSD 13.1

arcondello commented 2 years ago

Interesting. dwave/samplers/tree/sample.pyx:31:0: 'dwave/samplers/tree/orang.pxd' not found seems to be the original error. Though that file is present. Can you send the full traceback? Including your build command?

yurivict commented 2 years ago

Here is a complete log: http://beefy16.nyi.freebsd.org/data/130amd64-default/1b5765194c92/logs/py39-dwave-samplers-1.0.0.d1.log

It is an IPv6 URL. Are you able to see it?

arcondello commented 2 years ago

I can see the log. I am not familiar with BSD build pipelines though. Is there some sort of configuration file that goes with it?

yurivict commented 2 years ago

It builds from the port. FreeBSD ports build using the ports framework which contains recipes for everything.

In this case the full command is:

===>  Configuring for py39-dwave-samplers-1.0.0.d1
(cd /disk-samsung/freebsd-ports/science/py-dwave-samplers/work-py39/dwave-samplers-1.0.0.dev1; /usr/bin/env XDG_DATA_HOME=/disk-samsung/freebsd-ports/science/py-dwave-samplers/work-py39  XDG_CONFIG_HOME=/disk-samsung/freebsd-ports/science/py-dwave-samplers/work-py39  XDG_CACHE_HOME=/disk-samsung/freebsd-ports/science/py-dwave-samplers/work-py39/.cache  HOME=/disk-samsung/freebsd-ports/science/py-dwave-samplers/work-py39 PATH=/disk-samsung/freebsd-ports/science/py-dwave-samplers/work-py39/.bin:/home/yuri/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin PKG_CONFIG_LIBDIR=/disk-samsung/freebsd-ports/science/py-dwave-samplers/work-py39/.pkgconfig:/usr/local/libdata/pkgconfig:/usr/local/share/pkgconfig:/usr/libdata/pkgconfig NO_PIE=yes MK_DEBUG_FILES=no MK_KERNEL_SYMBOLS=no SHELL=/bin/sh NO_LINT=YES LDSHARED="cc -shared" PYTHONDONTWRITEBYTECODE= PYTHONOPTIMIZE= PREFIX=/usr/local  LOCALBASE=/usr/local  CC="cc" CFLAGS="-O2 -pipe -fno-omit-frame-pointer  -fstack-protector-strong -fno-strict-aliasing "  CPP="cpp" CPPFLAGS="-fno-omit-frame-pointer"  LDFLAGS=" -fstack-protector-strong " LIBS=""  CXX="c++" CXXFLAGS="-O2 -pipe -fno-omit-frame-pointer -fstack-protector-strong -fno-strict-aliasing -fno-omit-frame-pointer  "  MANPREFIX="/usr/local" BSD_INSTALL_PROGRAM="install  -s -m 555"  BSD_INSTALL_LIB="install  -s -m 0644"  BSD_INSTALL_SCRIPT="install  -m 555"  BSD_INSTALL_DATA="install  -m 0644"  BSD_INSTALL_MAN="install  -m 444" /usr/local/bin/python3.9 -c  "import sys; import setuptools;  __file__='setup.py'; sys.argv[0]='setup.py';  exec(compile(open(__file__, 'rb').read().replace(b'\\r\\n', b'\\n'), __file__, 'exec'))" config )
Compiling dwave/samplers/greedy/descent.pyx because it changed.
Compiling dwave/samplers/random/cyrandom.pyx because it changed.
Compiling dwave/samplers/sa/simulated_annealing.pyx because it changed.
Compiling dwave/samplers/tabu/tabu_search.pyx because it changed.
Compiling dwave/samplers/tree/sample.pyx because it changed.
Compiling dwave/samplers/tree/solve.pyx because it changed.
Compiling dwave/samplers/tree/utilities.pyx because it changed.

Strangely it builds on some systems and not on others. My desktop builds it without a problem.

arcondello commented 1 year ago

@yurivict any update on this issue? Can we close it?