Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build Error #13

Closed
Prajwal-Prathiksh opened this issue Jul 19, 2023 · 5 comments
Closed

Build Error #13

Prajwal-Prathiksh opened this issue Jul 19, 2023 · 5 comments

Comments

@Prajwal-Prathiksh
Copy link

Prajwal-Prathiksh commented Jul 19, 2023

Facing a local build (and pip install) error with cyarray.

Details

carray.pyx is throwing a Cython.Compiler.Errors.CompileError, due to two kinds of error:

  • Cannot assign type 'double' to 'long'. Fix: Use int division (//) in the corresponding .mako file
  • Assignment to a read-only property. Fix: To be identified.

Error message

generating file D:\OSS\cyarray\cyarray\carray.pxd from D:\OSS\cyarray\cyarray\carray.pxd.mako
generating file D:\OSS\cyarray\cyarray\carray.pyx from D:\OSS\cyarray\cyarray\carray.pyx.mako

Compiling cyarray/carray.pyx because it changed.
[1/1] Cythonizing cyarray/carray.pyx
C:\Users\prajw\miniconda3\envs\sph39\lib\site-packages\Cython\Compiler\Main.py:381: FutureWarning: Cython directive 'language_level' not set, using '3str' for now (Py3). This has changed from earlier releases! File: D:\OSS\cyarray\cyarray\carray.pxd
  tree = Parsing.p_module(s, pxd, full_module_name)
warning: cyarray\carray.pyx:63:0: The 'IF' statement is deprecated and will be removed in a future Cython version. Consider using runtime conditions or C macros instead. See https://github.com/cython/cython/issues/4310

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

    else:

        if 64%item_size == 0:

            return (n*item_size/64 + 1)*64/item_size
                                          ^
------------------------------------------------------------

cyarray\carray.pyx:159:42: Cannot assign type 'double' to 'long'

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

            return (n*item_size/64 + 1)*64/item_size

        else:

            return (n*item_size/64 + 1)*64
                                       ^
------------------------------------------------------------

cyarray\carray.pyx:163:39: Cannot assign type 'double' to 'long'

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

            self.data = self._old_data

            self._old_data = NULL

            self._npy_array.data = <char *>self.data
                           ^
------------------------------------------------------------

cyarray\carray.pyx:907:27: Assignment to a read-only property

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

            self.data = self._old_data

            self._old_data = NULL

            self._npy_array.data = <char *>self.data
                           ^
------------------------------------------------------------

cyarray\carray.pyx:1917:27: Assignment to a read-only property

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

            self.data = self._old_data

            self._old_data = NULL

            self._npy_array.data = <char *>self.data
                           ^
------------------------------------------------------------

cyarray\carray.pyx:2927:27: Assignment to a read-only property

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

            self.data = self._old_data

            self._old_data = NULL

            self._npy_array.data = <char *>self.data
                           ^
------------------------------------------------------------

cyarray\carray.pyx:3937:27: Assignment to a read-only property

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

            self.data = self._old_data

            self._old_data = NULL

            self._npy_array.data = <char *>self.data
                           ^
------------------------------------------------------------

cyarray\carray.pyx:4947:27: Assignment to a read-only property
Traceback (most recent call last):
  File "D:\OSS\cyarray\setup.py", line 160, in <module>
    setup_package()
  File "D:\OSS\cyarray\setup.py", line 105, in setup_package
    ext_modules = cythonize(
  File "C:\Users\prajw\miniconda3\envs\sph39\lib\site-packages\Cython\Build\Dependencies.py", line 1134, in cythonize
    cythonize_one(*args)
  File "C:\Users\prajw\miniconda3\envs\sph39\lib\site-packages\Cython\Build\Dependencies.py", line 1301, in cythonize_one
    raise CompileError(None, pyx_file)
Cython.Compiler.Errors.CompileError: cyarray/carray.pyx

OS & C++ versions

OS Name:                   Microsoft Windows 11 Home Single Language
OS Version:                10.0.22621 N/A Build 22621
System Type:               x64-based PC
Microsoft Visual C++ 2015-2022 Redistributable (x64) - 14.36.32532

Python environment

conda 23.3.1
Python 3.9.17
colorama          0.4.6
compyle           0.9.dev0 d:\oss\compyle
Cython            3.0.0
exceptiongroup    1.1.2
iniconfig         2.0.0
Mako              1.2.4
MarkupSafe        2.1.3
numpy             1.25.1
packaging         23.1
pip               23.1.2
platformdirs      3.9.1
pluggy            1.2.0
pytest            7.4.0
pytools           2023.1
setuptools        67.8.0
tomli             2.0.1
typing_extensions 4.7.1
wheel             0.38.4
@Prajwal-Prathiksh
Copy link
Author

Prajwal-Prathiksh commented Jul 19, 2023

cython >= 3.0a1 causes the compilation errors to be thrown.

The following sources deal with and fix the issue @prabhuramachandran.

@dineshadepu
Copy link

dineshadepu commented Aug 9, 2023

Thanks Prajwal, I am facing the same issue. Can you please elaborate on how to install this now? @Prajwal-Prathiksh This breaks pysph installation on Ubuntu 22.

@prabhuramachandran
Copy link
Contributor

Sorry I should fix this, basically install Cython < 3.x and it should work. I would suggest first installing the earlier cython version and then pip install --no-build-isolation

@dineshadepu
Copy link

Thanks for the prompt response. I tried using older Cython versions and different Python versions like 3.8, 3.9, and 3.10, but the problem still exists.

I'll wait for the bug to be fixed and keep working on my project. Thank you for looking into this.

@dineshadepu
Copy link

I somehow made it to work by replicating the exact versions of python, cython, numpy as my laptop. It was showing several different kind of errors, a few are, related to inspect and few others.

These are the steps I followed to have a successful pysph installation with cyarray:

conda create -n pysph_env python=3.10.9 anaconda
conda activate pysph_env
pip install cython==0.29.35
pip install cyarray --no-build-isolation
python -m pip install numpy==1.23.5
pip install pysph --no-build-isolation

nauaneed added a commit to nauaneed/cyarray that referenced this issue Aug 17, 2023
nauaneed added a commit to nauaneed/cyarray that referenced this issue Aug 17, 2023
cython>3.0 disallows setting `ndarray.data=<char *>some_data`.

I believe `ndarray.data=<char *>some_data` is being used in the first
place because it is more efficient than using
`PyArray_SimpleNewFromData`, maybe.

So, this cython restriction is overcome with a
fix from https://github.com/rainwoodman/pandas/blob/05d3fe2402e4563124e7060837ded7513ab5bca7/pandas/_libs/reduction.pyx#L27

interim partial fix for pypr#13 (comment)
nauaneed added a commit to nauaneed/cyarray that referenced this issue Aug 17, 2023
partial fix for pypr#13
thanks prajwal
nauaneed added a commit to nauaneed/cyarray that referenced this issue Aug 17, 2023
cython>3.0 disallows setting `ndarray.data=<char *>some_data`.

I believe `ndarray.data=<char *>some_data` is being used in the first
place because it is more efficient than using
`PyArray_SimpleNewFromData`, maybe.

So, this cython restriction is overcome with a
fix from https://github.com/rainwoodman/pandas/blob/05d3fe2402e4563124e7060837ded7513ab5bca7/pandas/_libs/reduction.pyx#L27

interim partial fix for pypr#13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants