Programming and writing about it.

echo $RANDOM

Category: nbpython

DTrace + NetBeans IDE + Python

The DTrace plugin for NetBeans brings the DTrace Toolkit and DTrace Chime to NetBeans on OpenSolaris. The DTrace toolkit ships with some utility scripts to talk with the Python DTrace providers.

Once you have installed the DTrace plugin, open Window > DTrace and in the Toolkit tab, choose Python:


You can see the various D scripts there. Let us take the script, ‘py_calltime.d‘, which will collect and display the time in us taken by each function call for a particular running Python process, whose PID you can supply during the run of the script, or start a Python process.

Here is a sample output:


With the ever developing Python support for NetBeans, you can start having some fun with Python, NetBeans and DTrace.

Advertisement

Disco + NetBeans IDE

Disco is a Open-Source implementation of the Map-Reduce framework, written in Erlang. Where as the framework is written in Erlang, Python is used to write the jobs (See glossary) for the framework. That is the link between NetBeans and Disco- Python. Agreed, there is another link, (http://wiki.netbeans.org/Erlang), but I will take the first.

After you have got your setup ready,  (which is pretty damn simple), fire up NetBeans IDE with the Python bits installed:

  • Create a New Python Project, say PyDisco. Name the main file as ‘wc-py.py‘ 
  • Right-Click on the project > Properties > Sources, and add the pydisco, directory which you can find in the Disco tarball (‘pydisco’ is the Python package in which the Python API for Disco is defined)

In the output window, you should see this message:

Starting Disco job..
Go to http://localhost:7000 to see status of the job.

When you open the browser, you will see something like this:

Of course, this was just a way to show you how you can use NetBeans IDE for your development using Disco.

Hatching Python Eggs from NetBeans

Support for building Python eggs  (IZ #150283) from NetBeans IDE is now available in the repository. (Refer this link to see how you can clone the repository and build the Python bits). Please try it and file bugs and suggestions here

Now, I would like to talk a bit of Python Eggs and how to use the NetBeans IDE to build Eggs for your Python packages.

A Python Egg is to Python as JAR is to Java or a ‘gem’ is to Ruby. It comprises of your code, resources and all important metadata- version, dependency information, etc. All the gory details are here at http://peak.telecommunity.com/DevCenter/PythonEggs

Use case in NetBeans

  • Right-click on the Python project name and select ‘Build Egg’
  • If you already have a setup.py file (Please refer the ‘assumptions‘ section below) , and a do a ‘Build Egg’ it uses that. (Do a ‘Clean & Build Egg’ to create a default setup.py file. If you don’t have a setup.py, one is created for you
  • The process can be tracked in the ‘Output’ Tab
  • Once the build process is over, you will see the the ‘egg’ has been deposited in the ‘dist’ directory (accessible in the ‘Files’ View)

It is not viewable from the ‘Projects’ view as it unnecessarily clutters the view.

Egg Formats

As you can see from the above view, there is also a file, EggDemo.egg-info, which is another format for Python Eggs as mentioned in http://peak.telecommunity.com/DevCenter/EggFormats

The wiki page has some more information.

Assumptions

These have to assumed, because that is the way it has to be:

  1. You have setuptools installed
  2. Your setup.py file lives in the top level directory- src or your existing sources’ root directory
  3. Your packages or sub-packages (those containing __init.py__) are actually in the sub-(sub)-directories under your top-level directory, in which setup.py lives

Sample Python Projects in NetBeans IDE

I have pushed some basic sample projects in Python/Jython to help you in Python development with NetBeans.

For details, please see the page at http://wiki.netbeans.org/Nbpysamples

Python modules in the NetBeans 6.5 UC


You can now install the Python support for NetBeans from the NetBeans 6.5 Update Center provided you have the Beta UC added (which should exist by default)

Doing more with the New Project Samples tutorial

You can create and distribute project samples of existing project types , by following this tutorial at http://platform.netbeans.org/tutorials/nbm-projectsamples.html

Actually, with no work at all, you can use the above procedure to do (at least) 2 things more:

  1. If you have the need to create a new project category, that uses a project structure similar to any of the existing project types then, just choose the category appropriately. For eg. instead of Samples, just put it under a project category such as Java and your new project type will be displayed there (Assuming your code will use the Java project structure with Ant)
  2. Say, the project category doesn’t exist under Samples, then all you need to do is add an extra folder tag to your layer.xml. For eg. if the IDE does not yet have any Python samples category (it actually doesn’t, see Issue #15365), you just need to add the appropriate line in your layer.xml

NetBeans IDE for Python: my blog posts

Hi Folks,

These are the posts I have done so far on the NetBeans IDE for Python support:

Now, you can track all my posts on the Python support at: http://amitksaha.blogspot.com/search/label/nbpython

Working with the NetBeans IDE for Python EA release

Update: The Python support modules can now be installed from the NetBeans 6.5 Update Center

The NetBeans IDE for Python is a EA release. Hence you will not be able to install the Python bits from the NetBeans IDE update center. So, you are left with a couple of options:

  1. Use the NetBeans IDE for Python EA standalone installer, which works great. You can then use the update center to add other bits- Java, C/C++, Ruby..
  2. If you already have a NetBeans IDE 6.5 installation, then install the Python bits into the same location wich also contains the other NetBeans 6.5 installation. I have found this working fine on Linux. For Mac OSX, this post at http://blogs.steeplesoft.com/netbeans-65-python-support-and-mac-os-x/ will help you (No Idea about Windows; If you have found it working, please leave a comment)

PS: The project page is at http://wiki.netbeans.org/Python