Alexander Eberspächer | 15 Oct 21:19 2014
Picon

Debugging workflow: cygdb, debugging symbols and system Python

Dear list,

I would like to ask for advice on a sensible debugging work-flow - on a system
with a few "boundary conditions" in place.

First of all, I use a Xubuntu 14.04 machine. Here, Python 2.7 is system
default, I also develop against that version. python-dbg is installed. As it
turns out, Ubuntu's gdb is linked against Python 3 (for unknown reasons), so I
decided to install a local gdb that is configured with --with-python2.

In that state, "gdb python-dbg" brings up gdb that happily uses Python 2.7
debug information. However, as it turns out, as soon as my scientific Python
software stack is imported in a script I'd like to debug, I get an error:

ImportError: /usr/local/lib/python2.7/dist-packages/scipy/special/_ufuncs.so: undefined symbol: Py_InitModule4_64

This is apparently due to my packages not being compiled with debugging symbols
[1]. If I was using system default versions here, I'd happily go with the *-dbg
packages from the repositories, however, all of scientific Python is built by
myself.

Actually, all I want is to use cygdb in principle as my project is
Python/Cython/Fortran. However, I can't get cygdb to start with a Python that
has debugging symbols:

    Python was not compiled with debug symbols (or it was stripped). Some functionality may not work (properly).

Even if I could, I'd still probably run into the problem I described above. My own
package is compiled with Cython's --gdb options as well as with -g for all gcc/gfortran.

This is where I appreciated your input. How do you handle Cython debugging?
Does cygdb do the job for you? If so, how? How do you deal with a software
stack that doesn't have debugging symbols at hand?

Thanks for your help with this somewhat tangled problem somewhere in-between
what's possible, what's needed and what's easiest.

Regards

Alex Eberspächer


[1] http://hustoknow.blogspot.de/2013/06/why-your-python-program-cant-start-when.html



--

---
You received this message because you are subscribed to the Google Groups "cython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cython-users+unsubscribe <at> googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Stefan Behnel | 15 Oct 07:58 2014
Picon

Release candidate for Cython 0.21.1

Hi everyone,

I uploaded a candidate for a 0.21.1 bug fix release.

http://cython.org/release/Cython-0.21.1pre.tar.gz

It adds a few minor new features and some bug fixes and corrections. Please
give it a quick try, especially if you reported problems that this release
should fix. I had to manually select changes from the master branch, so I
hope I didn't forget anything.

Stefan

Features added
--------------

* New ``cythonize`` option ``-a`` to generate the annotated HTML source
  view.

* Missing C-API declarations in ``cpython.unicode`` were added.

* Passing ``language='c++'`` into cythonize() globally enables C++ mode for
  all modules that were not passed as Extension objects (i.e. only source
  files and file patterns).

* ``Py_hash_t`` is a known type (used in CPython for hash values).

* ``PySlice_*()`` C-API functions are available from the ``cpython.slice``
  module.

* Allow arrays of C++ classes.

Bugs fixed
----------

* Reference leak for non-simple Python expressions in boolean and/or
  expressions.

* To fix a name collision and to reflect availability on host platforms,
  standard C declarations [ clock(), time(), struct tm and tm* functions ]
  were moved from posix/time.pxd to a new libc/time.pxd.  Patch by Charles
  Blake.

* Rerunning unmodified modules in IPython's cython support failed.
  Patch by Matthias Bussonier.

* Casting C++ ``std::string`` to Python byte strings failed when
  auto-decoding was enabled.

* Fatal exceptions in global module init code could lead to crashes
  if the already created module was used later on (e.g. through a
  stale reference in sys.modules or elsewhere).

Other changes
-------------

* Compilation no longer fails hard when unknown compilation options are
  passed.  Instead, it raises a warning and ignores them (as it did
  silently before 0.21).  This will be changed back to an error in a
  future release.

--

-- 

--- 
You received this message because you are subscribed to the Google Groups "cython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cython-users+unsubscribe <at> googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Catherine Moroney | 14 Oct 23:17 2014
Picon
Picon

accessing C

Hello,

I'm using Cython to wrap a third-party library (HDF and HDF-EOS for 
those in the satellite data business) and I want to call the HDF error 
reporting function.  

The syntax for the error function is "HEprint(FILE *, 0)" and i'm stuck 
on how I construct and pass a regular C file pointer (which could be stdout) 
into the function within my Cython code.  

If anybody can post some sample code that writes a text string to 
either a C FILE * or stdout within Cython, I would love to see how you do this.

Thanks for any help,

Catherine

--

-- 

--- 
You received this message because you are subscribed to the Google Groups "cython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cython-users+unsubscribe <at> googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Gregorio Bastardo | 13 Oct 10:38 2014
Picon

Re: debugging external c code

The missing piece of puzzle was the "-s" linker option that is added
by default and removed the debug symbols. After manually linking the
code w/o this option the debugging works fine with gdb.

Now I'd like create a release and a debug version of the same
extension module. Can anyone show a good practice for it (e.g. in
setup.py)? How can I skip the "-s" option in the debug version?

Thanks,
Gregorio

--

-- 

--- 
You received this message because you are subscribed to the Google Groups "cython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cython-users+unsubscribe <at> googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Wenxiang He | 13 Oct 05:38 2014
Picon

cython3 bug

cython -3 publicTest.pyx


I need change DL_IMPORT(void) to void in the generated header file。

otherwise

publicTest.h:15:16: error: old-style parameter declarations in prototyped function definition
 __PYX_EXTERN_C DL_IMPORT(void) cythonFunction(void);

--

---
You received this message because you are subscribed to the Google Groups "cython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cython-users+unsubscribe <at> googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Ryan Lewis | 10 Oct 05:51 2014
Picon

Cython

Hi,

I am a researcher and I develop high performance  c++ software written with the generic programming paradigm for use in data analysis. I really would like an interpreter so that I can test ideas with my library in "real" time. Python itself has a massive amount of tools which would be useful when ingesting data as well as processing and visualizing results. 

I'm trying to evaluate the difficulty of using cython to take my heavily templated header only c++ code, data structures, and all, and get it working with cython? 

In particular:

1) http://docs.cython.org/src/userguide/wrapping_CPlusPlus.html <-- this mentions that cython can "now deal with templates" although I don't see an example. Can anyone show me how that works? In particular, how about calling functions in C++ with arbitrary template parameters? Ideally there is some sort of caching of precompiled .so's so that this work is never repeated...

2) When bringing C++ structs/classes into Cython, is it necessary to write what looks like boilerplate: http://docs.cython.org/src/userguide/wrapping_CPlusPlus.html#templates ? or does some code auto generate this?

I'll probably have more questions, but, i'll wait incase I didn't ask a well formed one so far. 

--

---
You received this message because you are subscribed to the Google Groups "cython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cython-users+unsubscribe <at> googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Joakim Bø | 9 Oct 10:58 2014
Picon

Importing external types in cython

Hi guys!

I need som help applying Cython here; I'm a both a Cython and a C/C++ newbie, my programming has mostly been done in Python.

So, I want to speed up a for loop applying Cython. For my purpose I need to import some packages from an external library. In C++ one would do

#include <dolfin.h>,

then apply

using namespace dolfin;

When this has been done one could use the types in dolfin straightforwardly (e.g. Mesh, Function, Cell and so on..). Now my problem is to get these types into my Cython file, any ideas on how I can do this? I've tried searching around a lot but couldn't find anything.

Thanks in advance!

Joakim

--

---
You received this message because you are subscribed to the Google Groups "cython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cython-users+unsubscribe <at> googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Phillip Middleton | 9 Oct 03:16 2014
Picon

Cython 0.21 compilation/installation error on Linux (Mint 17)

I have been fighting recently (never a previous problem) with upgrading Cython to v 0.21, eventually uninstalling it and trying a fresh install. The upgrade issue appeared to be due to something odd with setuptools (attribute error: no module 'Distutils' ..etc), or how it interacted with Cython during installation. 

I've posted the issue in StackExchange .  This is on Mint 17 using Python 2.7.6, gcc 4.8.4, setuptools 6.0.7 (now that I upgraded it)

In sum, I was attempting to upgrade several packages using pip, many among them which have Cython as a dependency. During that time I received the above attribute error, and found info that led me to believe setuptools required reinstallation. Did that. 
Upon trying to upgrade the packages again, I received errors from things like lxml, matplotlib, psycopg2, MarkupSafe, and a number of others the following complaint: 
ImportError: cannot import name load_ipython_extension.

The issue seemed calls to import Cython (which I had uninstalled). When I attempted install of Cython 0.21 (using pip, easy_install, and manual dl and build approaches) I got the error: 
[Errno 34]: numerical value out of range.

See this in more detail in the above link. 

Ok so I get it, it's an overflow problem. I could understand this if it were a program I was compiling, but I was simply building Cython itself. I did note that the Cython build seems to take various chunks from a zip file and makes this awful looking chain of paths with temp directories. I haven't a clue what it's trying to do. The error appears to occur during the final set of tasks wherein os.getpwdu() is called. I recall in the past that really long path names would bork it in 2.4-5, but I figured that it had been fixed.  What I cannot figure out is, what changed where I cannot install Cython? 

I was recommended to compile with --no-cython-compile, but a pure python implementation isn't what it was truly meant, so I fail to see the benefit. Still, I haven't tried checking whether this works yet or no, just for bug tracking. 

Also, I don't see a way to post bug candidates in Trac on cython.org (if this is indeed the case). Are these supposed to be directed to python.org?

thanks!

Phillip

--

---
You received this message because you are subscribed to the Google Groups "cython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cython-users+unsubscribe <at> googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
CW | 8 Oct 10:00 2014
Picon

Cythonize problem in Cython 0.21

Hi All,

I recently upgraded to Cython 0.21 and ran into trouble when running my setup.py script. The problem is in my call to Cythonize which is:

cythonize(["my.pyx"], include_path=["."],include_dirs=[numpy.get_include()],pyrex_gdb=True)

and i get the error:
Traceback (most recent call last):
 
File "setup.py", line 588, in <module>
    ext_list
= check_extensions()
 
File "setup.py", line 259, in check_extensions
    ext_list
= cythonize(["assimulo"+O.path.sep+"*.pyx"], include_path=[".","assimulo"],include_dirs=[N.get_include()],pyrex_gdb=debug_flag)
 
File "/usr/local/lib/python2.7/dist-packages/Cython/Build/Dependencies.py", line 704, in cythonize
    c_options
= CompilationOptions(**options)
 
File "/usr/local/lib/python2.7/dist-packages/Cython/Compiler/Main.py", line 501, in __init__
   
', '.join(unknown_options)))
ValueError: got unexpected compilation options: pyrex_gdb, include_dirs

The above command works fine in Cython 0.20 and earlier and I checked the changelog for Cython 0.21 but I couldn't find anything there that would cause this. So, my question is, how can I provide the options (include_dirs and pyrex_gdb) in Cython 0.21 and how can I adapt my command?

Thanks!

Best
/Christian

--

---
You received this message because you are subscribed to the Google Groups "cython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cython-users+unsubscribe <at> googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
yi huang | 8 Oct 05:55 2014
Picon

cython 0.21 "Storing unsafe C derivative of temporary Python reference"

I've met this error when i compiling kivy, i can reproduce it in this minimal code:

def main(s):
    cdef char* p = NULL
    p = <bytes>s[:10]

When compile above code, cython compains "Storing unsafe C derivative of temporary Python reference".

If i re-factor above code to this, cython compile it success:

def main(s):
    cdef char* p = NULL
    s1 = s[:10]
    p = <bytes>s1

Is this considered as a bug of cython or normal behavior, in latter case, i guess we need to begin to refactor some code.

--

---
You received this message because you are subscribed to the Google Groups "cython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cython-users+unsubscribe <at> googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Brian | 5 Oct 07:20 2014
Picon

Compiler crash in AnalyseExpressionsTransform?

Hi all,

I am getting this error, and I am not sure what to do about it. I hope you can help! Please let me know if there is any other information I can provide to help figure this out.

Brian

----------------------------------------------------------------------------------------------

        res1 = self.calculate_edge_force(avg_RacA_plus1, avg_RhoA_plus1, node_index, node_index_iPlus1, node_coords, initial_edge_length)
            ^
------------------------------------------------------------

cython_cell.pyx:881:13: Compiler crash in AnalyseExpressionsTransform

ModuleNode.body = StatListNode(cython_cell.pyx:7:0)
StatListNode.stats[14] = StatListNode(cython_cell.pyx:48:5)
StatListNode.stats[0] = CClassDefNode(cython_cell.pyx:48:5,
    as_name = u'ExperimentEnvironment',
    class_name = u'ExperimentEnvironment',
    module_name = u'',
    visibility = u'private')
CClassDefNode.body = StatListNode(cython_cell.pyx:49:4)
StatListNode.stats[37] = StatListNode(cython_cell.pyx:836:9)
StatListNode.stats[0] = CFuncDefNode(cython_cell.pyx:836:9,
    args = [...]/19,
    is_c_class_method = 1,
    modifiers = [...]/0,
    visibility = u'private')
File 'Nodes.py', line 392, in analyse_expressions: StatListNode(cython_cell.pyx:838:8,
    is_terminator = True)
File 'Nodes.py', line 392, in analyse_expressions: StatListNode(cython_cell.pyx:881:40)
File 'Nodes.py', line 4628, in analyse_expressions: SingleAssignmentNode(cython_cell.pyx:881:40)
File 'Nodes.py', line 4738, in analyse_types: SingleAssignmentNode(cython_cell.pyx:881:40)
File 'ExprNodes.py', line 1743, in analyse_target_types: NameNode(cython_cell.pyx:881:13,
    cf_is_null = True,
    cf_maybe_null = True,
    cf_state = [...]/0,
    is_name = True,
    name = u'res1',
    result_is_used = True,
    use_managed_ref = True)

Compiler crash traceback from this point on:
  File "/home/brian/anaconda/lib/python2.7/site-packages/Cython/Compiler/ExprNodes.py", line 1743, in analyse_target_types
    Buffer.used_buffer_aux_vars(self.entry)
  File "/home/brian/anaconda/lib/python2.7/site-packages/Cython/Compiler/Buffer.py", line 283, in used_buffer_aux_vars
    buffer_aux.buflocal_nd_var.used = True
AttributeError: 'NoneType' object has no attribute 'buflocal_nd_var'


--

---
You received this message because you are subscribed to the Google Groups "cython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cython-users+unsubscribe <at> googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Gmane