Thursday, April 25, 2013

kdev-python 1.5 rc1 -- please test!

Hi!

Five months have passed since the release of kdev-python 1.4.1, and it's about time for the next release! The 1.5 release will contain various new features and bug fixes, and also will work with KDevelop 4.5, which is to be released soon.

One of the new features in kdev-python 1.5: initializing properties in class constructors via code completion

Notable Bugs fixed

The following issues were fixed, among others:
  • 312275 don't add brackets if importing functions
  • 318802 fix quadruple-quotes from causing completion to malfunction
  • 317998 issue with function definition ranges causing completion to malfunction
  • 317808 correct inheritance completion with member access
  • 309817 correctly build uses for declarations in some corner cases
  • 309469 include documentation files for PyKDE and the rest of PyQt
  • 308986 fix a rare crash with some function definitions
  • 1d34b03 fix an infinite loop in the debugger plugin
  • 031badc don't reparse files on session restart if not necessary
The numbers are the bug / commit IDs of the change.

Notable new Features

The following new features are worth mentioning:
  • 333cf91 sort completion items based on name similarity
  • 6dc24ad class attribute initialization completion
  • cd03cee PEP8 error checking. Enable it in "configure kdevelop" if you want to use it.
  • b3ba512 support adding watches in the debugger plugin
Name-aware variable sorting: Although "the_bar" comes first alphabetically, "the_foo" is sorted first because its name matches the left side of the expression. You can still get an alphabetical list by invoking full completion.

Features that didn't make it into 1.5 yet

Two things that I wanted in 1.5 but which are not there are Python 3 support, and GHNS support. The latter is just not ready yet (might be in 1.5.1 or 1.5.2, but probably 1.6), the former can only be released in Q1 2014, as explained here.

Get it

kdev-python 1.5 is to be used with kdevplatform 1.5, and only 1.5 (so, kdevplatform with version numbers >= 1.4.60 and < 1.5.40). It's not going to work with kdevplatform master, or kdevplatform 1.4.
Please test this RC thoroughly and report any issues you find to the bugtracker, so the final 1.5 release can be as nice as possible! Get the tarball from download.kde.org. The sha256sum of the tarball is
441f675baddbfb9832a49458cc3c9a17daac4db55e7312c7a85d184bc0f4c776
Have fun with it! (not with the checksum, with the program I meant... you know)

27 comments:

  1. Great to see the work going on! Thank you!
    Is there anything like forced built-ins like in PyDev (http://pydev.org/manual_101_interpreter.html#PyDevInterpreterConfiguration-ForcedBuiltins)?

    ReplyDelete
    Replies
    1. No, but something with comparable effect will be in 1.6; you'll have a button to tell kdev-python to do this once for a libary, and store the information it extracted for future use.

      Delete
  2. I made a simple script to install this version: http://blindvic.blogspot.ru/2013/04/compiling-kdevelop-with-kdev-python-15.html

    Some notes:
    - Default indentation is 2 spaces.
    - Backspace deletes spaces one by one, instead of going to previous line indentation level.

    Suggestion: pressing tab in the middle of code line - indent the line - no need to go to the beginning of the line.

    ReplyDelete
    Replies
    1. Very nice, thanks!

      The default indentation being set to 2 spaces is what kate does, I wanted to change it for ages -- but probably there's people who want the default to be this ;)
      It's not set to 2 in kdev-python, it's just what kate does; kdev-python can't control it. As said, it would need to be changed in kate (and I'd like it to be changed ;).

      For the second thing, there's a checkbox in the settings -> configure editor which does that (I forgot the name, but it's easy to find).

      About pressing tab in the middle of a line, hm, not sure. What if I want to place a tab there, say, for an ASCII table in a comment or so? Sure it would be useful in most situations, but annoying in others...
      Anyways, this, too is a pure kate feature and not something I can do in kdev-python.

      Cheers!

      Delete
  3. So it's not possible to have different indentation settings per project/file type? For example for js files have indentation of 2 spaces, while for Python files - 4?

    ReplyDelete
    Replies
    1. I'm not an expert for how kate indent works, but I think the indent width settings are global; so, no. You can however use kate modelines: http://kate-editor.org/2006/02/09/kate-modelines/

      Delete
  4. Also, PyDev automatically adds `import` after i enter something like `from PyQt4 `

    ReplyDelete
  5. I just lost a project... I tried to create a simple Python project from an existing directory. It warned me about the existing directory. Then add Git VCS. Then it freezed. I killed the app. Then tried to do the same. It said VCS could not add files and deleted all the dir...

    ReplyDelete
  6. I guess it's because of unfinished repo creation when the app freezed:
    /home/vic/projects/yand1> git add -- /home/vic/projects/yand1
    fatal: Unable to create '/home/vic/projects/yand1/.git/index.lock': File exists.

    If no other git process is currently running, this probably means a
    git process crashed in this repository earlier. Make sure no other git
    process is running and remove the file manually to continue.

    Command finished with error UnknownError.
    Command exited with value 128.

    Anyway, i think it should ask the user, whether to delete anything.

    ReplyDelete
    Replies
    1. Wait, wait, what did you do exactly? I have never heard of a similar issue. When you want to import an existing project, you're supposed to use Project -> Open / Import, not Project -> New from Template. The latter might indeed overwrite some files, but it does warn about it.
      What do you mean by "lost a project"? What you wrote just indicates that the git index is locked, which is easy to fix by just creating the lock file.

      Can you describe the steps you did? Optimally you could so so in a bug report to kdevelop (not kdev-python -- not related to kdev-python). Thanks!

      Cheers,
      Sven

      Delete
  7. Thank you very much for kdevelop!
    But i am having a problem.
    \
    i am building it against :

    kdevelop 4.5
    kdev-python 1.5
    kdev-platform 1.5

    Build successful but when kdevelop is ran:
    "Cannot load library /home/v3ss/kdev/lib64/kde4/kdevpdb.so: (libkdev4pythonparser.so: cannot open shared object file: No such file or directory)" '

    ReplyDelete
    Replies
    1. Hmm, sounds like your library path is not set correctly. It's difficult to tell about a correct fix remotely, but you could try linking libkdev4pythonparser.so (search where it was installed) to /usr/lib/libkdev4pythonparser.so (which is definitely not the correct way to fix it but should work). If it complains about more libraries, do the same for them. Just don't forget to remove the symlinks from /usr/lib again if you decide to install distro packages again.

      Delete
    2. thanks for the reply man.

      the file exists inside local build directory but kdevelop somehow can't find it.

      so as you suggested i linked all the kdev files inside /usr/lib64

      and things running fine , but after parsing a few python files for autocomplete SEGFAULT! happened:

      ====> AST ====> building abstract syntax tree for "/home/v3ss/workspace/icluster/classify.py"
      ====> DUCHAIN ====> building duchain for "/home/v3ss/workspace/icluster/classify.py"
      ====> AST ====> building abstract syntax tree for "/home/v3ss/workspace/icluster/clustering.py"
      ====> DUCHAIN ====> building duchain for "/home/v3ss/workspace/icluster/clustering.py"
      *** glibc detected *** ./kdevelop: double free or corruption (fasttop): 0x00007f74a8083090 ***
      ======= Backtrace: =========
      /lib64/libc.so.6(+0x7b836)[0x7f75335dc836]
      /lib64/libc.so.6(+0x7e3f8)[0x7f75335df3f8]
      /lib64/libc.so.6(realloc+0xee)[0x7f75335e0fee]
      /usr/lib64/qt4/libQtCore.so.4(_ZN9QListData7reallocEi+0x26)[0x7f753553d4f6]
      /usr/lib64/qt4/libQtCore.so.4(_ZN9QListData6appendEi+0x67)[0x7f753553d5a7]
      /usr/lib64/libkdev4pythonduchain.so(+0x41a8d)[0x7f750317da8d]
      ............7f7501347000-7f7501546000 ---p 0000a000 08:05 3287203 /home/v3ss/kdev/lib64/kde4/kdevmakebuilder.so
      7f7501546000-7f7501547000 r--p 00009000 08:05 3287203 /home/v3ss/kdev/lib64/kde4/kdevmakebuilder.soKCrash: Application 'kdevelop' crashing...
      KCrash: Attempting to start /usr/lib64/kde4/libexec/drkonqi from kdeinit
      sock_file=/home/v3ss/.kde4/socket-localhost/kdeinit4__0
      kdevelop: Fatal IO error: client killed

      Any ideas! Getting close now!!

      Delete
    3. Sorry, I can't do anything about it, unless you post the backtrace and/or a way to reproduce it (which project was it parsing?).

      Optimally, such issues should be reported to the bugtracker directly ;)

      Delete
    4. For some reason, your reply won't show up here. I got it by email though. Good to know it's working now -- maybe the 1.4 cache doesn't like working together with 1.5? I'll look after it.

      Delete
  8. http://www.youtube.com/watch?v=xMRhM4igA4o

    When I type `import random`:
    1. It shows me two suggestions - the same name, two different meanings? Maybe leave one name?
    2. If I press `Enter` it treats it as suggestion selection, so:
    a) It doesn't change anything in the string i entered
    b) I have to press `Enter` second time to actually enter new line.

    ReplyDelete
    Replies
    1. The duplication is indeed an issue, I got to fix that some day. ;)
      The two suggestions indeed have different meanings, but it's an implementation detail and should not be visible to the user.

      The other thing seems like sort of a non-issue to me... that's how code completion always works in kdev/kate. It's the same with variable names or anything. If you want to write the suggested word, you can just press enter -- problem solved ;)
      About automatically adding newlines when executing completion items, I have considered it in many places and I have decided against it. You might well be adding a new import between some more imports, in which case you wouldn't want the extra newline.

      Delete
    2. > If you want to write the suggested word, you can just press enter -- problem solved ;)

      But what if the suggested word is already entered? I typed `import array` and it suggests me `array`?

      Delete
    3. Ah, two more notes about this: You can always close the completion widget with Esc; and also, you can turn automatic completion invocation off in the settings if it annoys you.

      Delete
    4. > But what if the suggested word is already entered? I typed
      > `import array` and it suggests me `array`?
      I see the problem, but the workflow which it is designed for is "you look at the screen, type "import ar", see "array" suggested, and press enter to complete it".
      Users typing out the whole word which is already suggested in completion is sort of a rare case, which -- for me personally -- almost never happens. You can however specify a minimum length of words you don't want automatic completion to appear for, the default is 3, maybe you want to set it to 7 or so.

      Delete
    5. I use autocompletion and it's very useful. Ok, it's a small issue - no one will change this anyway. Thank you for the feedback

      Delete
    6. Yeah, of course you don't want to turn autocompletion off ;)
      But you can turn off the widget opening automatically. Then it'll only open if you press Ctrl+Space. If you have a lot of cases like the one you described, this might be preferable for you.

      Delete
    7. I mean this a more general question - should suggestion be shown at all if it contains the same word?

      Delete
    8. Yes, it's a valid question. I personally like having it there for various reasons (no flickering, confirmation that what I typed is valid, match quality and type of the thing I typed visible, ...). But I can understand why you wouldn't.

      I am indeed noticing that the kate text completion hides all entries when one exactly matches the word already typed. But, hmm, that wouldn't work well in kdevelop I think...
      Consider, for example, this case: http://i.imgur.com/eHbCZXL.png
      For classes such as those, I type "DU", then I press tab to complete it to "DUChain", and type a few more characters to select the entry I want. Your suggestion would hide the widget after pressing tab (because there's an entry which matches the word), which would be bad.

      Neverthereless, feel free to open a bug report about this so it can be discussed in public.

      Delete
    9. Yes, sure you are right. I just meant to not show a SINGLE suggestion which contains the word i just entered.

      Delete
    10. Aah, ok. That sounds reasonable. I've put it on the wish list ;)
      https://bugs.kde.org/show_bug.cgi?id=319018

      Delete
  9. How u guys build it? I am rebuilding several times and even wrote a build script editing victor's build script. (i do not use git tho , git repo seems to be down)


    here is my build script:
    # http://techbase.kde.org/Projects/KDevelop4/HowToCompile

    # paths
    INSTALL_PATH=$HOME/kdev
    SRC=$HOME/kdev

    cd $SRC/kdevplatform/build/
    cmake -DCMAKE_INSTALL_PREFIX=$INSTALL_PATH ../
    make -j8
    make install

    cd $SRC/kdevelop/build/
    cmake -DCMAKE_PREFIX_PATH=$INSTALL_PATH -DCMAKE_INSTALL_PREFIX=$INSTALL_PATH ../
    make -j8
    make install

    cd $SRC/kdevelop-pg-qt/build/
    cmake -DCMAKE_INSTALL_PREFIX=$INSTALL_PATH -DCMAKE_MODULE_PATH=/usr/share/cmake/modules ../
    make -j8 parser
    make -j8 install

    cd $SRC/kdev-python/build/
    cmake -DCMAKE_INSTALL_PREFIX=$INSTALL_PATH -DCMAKE_MODULE_PATH=/usr/share/cmake/modules ../
    make -j8 parser
    make -j8 install


    # paths for KDE
    PATHS_FILE="$HOME/.kde/env/kdevelop.sh"
    echo "export KDEDIRS=\$KDEDIRS:$INSTALL_PATH" > $PATHS_FILE
    echo "export PATH=\$PATH:$INSTALL_PATH/bin" >> $PATHS_FILE

    # Rebuild the system configuration cache
    export KDEDIRS=$KDEDIRS:$INSTALL_PATH
    kbuildsycoca4

    ReplyDelete