Skip to content
This repository has been archived by the owner on May 3, 2024. It is now read-only.

Cython compiler error when installing/building cDNA_cupcake #241

Open
skchronicles opened this issue Sep 14, 2023 · 2 comments
Open

Cython compiler error when installing/building cDNA_cupcake #241

skchronicles opened this issue Sep 14, 2023 · 2 comments

Comments

@skchronicles
Copy link

skchronicles commented Sep 14, 2023

Hello there,

I hope you're having an awesome day, and that all is going well on our side. I just wanted to reach out to you because I ran into an issue when installing/building cDNA_cupcake using the instructions that you have provided. I am installing/building cDNA_cupcake to use with sqanti3 with python/3.10.6.

Here is the command I am running to install cDNA_Cupcake/v28.0.0:

# Already have its other dependencies installed
$ mkdir -p /opt2/cdna_cupcake/28.0.0/ \
        && wget https://github.com/Magdoll/cDNA_Cupcake/archive/refs/tags/v28.0.0.tar.gz -O /opt2/cdna_cupcake/28.0.0/v28.0.0.tar.gz \
        && tar -zvxf /opt2/cdna_cupcake/28.0.0/v28.0.0.tar.gz -C /opt2/cdna_cupcake/28.0.0/ \
        && rm -f /opt2/cdna_cupcake/28.0.0/v28.0.0.tar.gz \
        && cd /opt2/cdna_cupcake/28.0.0/cDNA_Cupcake-28.0.0 \
        && python setup.py build \
        && python setup.py install

And here is the error message/traceback I get when running the command above:

#17 4.003 cDNA_Cupcake-28.0.0/targeted/calc_probe_hit_from_sam.py
#17 5.114 /usr/local/lib/python3.10/dist-packages/Cython/Compiler/Main.py:384: FutureWarning: Cython directive 'language_level' not set, using '3str' for now (Py3). This has changed from earlier releases! File: /opt2/cdna_cupcake/28.0.0/cDNA_Cupcake-28.0.0/cupcake/ice/find_ECE.pyx
#17 5.114   tree = Parsing.p_module(s, pxd, full_module_name)
#17 5.205 /usr/local/lib/python3.10/dist-packages/Cython/Compiler/Main.py:384: FutureWarning: Cython directive 'language_level' not set, using '3str' for now (Py3). This has changed from earlier releases! File: /opt2/cdna_cupcake/28.0.0/cDNA_Cupcake-28.0.0/cupcake/tofu/branch/c_branch.pyx
#17 5.205   tree = Parsing.p_module(s, pxd, full_module_name)
#17 5.206 
#17 5.206 Error compiling Cython file:
#17 5.206 ------------------------------------------------------------
#17 5.206 ...
#17 5.206                 exon_tree.insert_interval(Interval(e_start+offset, i+offset, index))
#17 5.206                 index += 1
#17 5.206                 tag = False
#17 5.206             elif baseC[i] > 0 and (altC_pos[i] > threshSplit or altC_neg[i+1] < -threshSplit): # alt. junction found!
#17 5.206                 # end the current exon at i and start a new one at i + 1
#17 5.206                 print "alt. junction found at", i
#17 5.206                       ^
#17 5.206 ------------------------------------------------------------
#17 5.206 
#17 5.206 cupcake/tofu/branch/c_branch.pyx:30:22: Syntax error in simple statement list
#17 5.206 Traceback (most recent call last):
#17 5.206   File "/opt2/cdna_cupcake/28.0.0/cDNA_Cupcake-28.0.0/setup.py", line 25, in <module>
#17 5.206 Compiling cupcake/tofu/branch/intersection_unique.pyx because it changed.
#17 5.206 Compiling cupcake/tofu/branch/c_branch.pyx because it changed.
#17 5.206 Compiling cupcake/ice/find_ECE.pyx because it changed.
#17 5.206 [1/3] Cythonizing cupcake/ice/find_ECE.pyx
#17 5.206 [2/3] Cythonizing cupcake/tofu/branch/c_branch.pyx
#17 5.207     ext_modules = cythonize(ext_modules),
#17 5.207   File "/usr/local/lib/python3.10/dist-packages/Cython/Build/Dependencies.py", line 1134, in cythonize
#17 5.208     cythonize_one(*args)
#17 5.208   File "/usr/local/lib/python3.10/dist-packages/Cython/Build/Dependencies.py", line 1301, in cythonize_one
#17 5.208     raise CompileError(None, pyx_file)
#17 5.208 Cython.Compiler.Errors.CompileError: cupcake/tofu/branch/c_branch.pyx
------
executor failed running [/bin/sh -c mkdir -p /opt2/cdna_cupcake/28.0.0/     && wget https://github.com/Magdoll/cDNA_Cupcake/archive/refs/tags/v28.0.0.tar.gz -O /opt2/cdna_cupcake/28.0.0/v28.0.0.tar.gz     && tar -zvxf /opt2/cdna_cupcake/28.0.0/v28.0.0.tar.gz -C /opt2/cdna_cupcake/28.0.0/     && rm -f /opt2/cdna_cupcake/28.0.0/v28.0.0.tar.gz     && cd /opt2/cdna_cupcake/28.0.0/cDNA_Cupcake-28.0.0     && python setup.py build     && python setup.py install]: exit code: 1

It appears this pyx script, cupcake/tofu/branch/c_branch.pyx, contains python2 syntax. The warning the compiler is giving above before the traceback states that because the Compiler language_level directive is not set, it is defaulting to python3:

Cython directive 'language_level' not set, using '3str' for now (Py3).

This is causing the compiler to error out when it reaches the python2 style print statement. Can you please fix this on your side when you have a moment of free time? I also noticed this issue is documented/described here in at sqanti3. For the time being, I am going to patch the setup.py similar to what is described in the sqanti issue.

Thank you again for your time, and have a great day!

Best regards,
@skchronicles

@skchronicles
Copy link
Author

I just noticed that there was a that was a PR submitted to address the issue here:
#239

@skchronicles
Copy link
Author

skchronicles commented Sep 14, 2023

I ran into a few other issues while installing cDNA_Cupcake. I will describe each of them below:

  1. The python package, sklearn, that is listed in the setup.py file is depreciated and it has been removed from the python package index for the version of python that I am using python/3.10.6 default version you can install via apt-get for ubuntu/22.04-LTS. It can be fixed by replacing sklearn in the setup.py with scikit-learn.

  2. np.int has been depreciated in numpy>=1.20.0. Here is a description of the change. This causing problems in a few different places where you are declaring integers types in a few of your scripts:
    image

To fix this issue, I replaced np.int with np.int_ as the authors of numpy have suggested.

TLDR
To summarize, here are the set of commands, I had to run to install/patch cDNA_Cupcake to install it with python/3.10.6:

mkdir -p /opt2/cdna_cupcake/28.0.0/ \
    && wget https://github.com/Magdoll/cDNA_Cupcake/archive/refs/tags/v28.0.0.tar.gz -O /opt2/cdna_cupcake/28.0.0/v28.0.0.tar.gz \
    && tar -zvxf /opt2/cdna_cupcake/28.0.0/v28.0.0.tar.gz -C /opt2/cdna_cupcake/28.0.0/ \
    && rm -f /opt2/cdna_cupcake/28.0.0/v28.0.0.tar.gz \
    && cd /opt2/cdna_cupcake/28.0.0/cDNA_Cupcake-28.0.0 \
    # Patch: some pyx files contain python2,
    # need to specify the langauage_level as
    # py2 otherwise it defaults to py3.
    && sed -i 's/cythonize(ext_modules)/cythonize(ext_modules, language_level = "2")/' setup.py \
    # sklearn is depreciated, use scikit-learn instead
    && sed -i 's/sklearn/scikit-learn/' setup.py \
    # numpy, np.int is depreciated, use int instead:
    # https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations
    && find /opt2/cdna_cupcake/28.0.0/cDNA_Cupcake-28.0.0 \
        -type f -exec grep 'np\.int' {} /dev/null \; 2> /dev/null \
        | awk -F ':' -v q="'" -v b='\\' '{print "sed -i", q"s/np"b".int"b"("b"s"b"|$"b")/np.int_/g"q,$1}' \
        | sort \
        | uniq \
        | bash \
    && python setup.py build \
    && python setup.py install

export PATH="${PATH}:/opt2/cdna_cupcake/28.0.0/cDNA_Cupcake-28.0.0/sequence"

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant