Filed Under (Python) by Marcin Kuźmiński on August-6-2009

python -m compileall .

This simple command will enforce all files in the current directory will be compiled to .pyc files. Python by default creates .pyc files only on imported modules.
(python -B option is not to compile them at all)
You can also compile in python code using the py_compile module

import py_compile
py_compile.compile("somemodule.py")

You can used it for speed or to protect your source code from being changed.
Compiled python files (.pyc) are little harder( but not impossible) to edit. You would have to decompile it first to edit.



Filed Under (Editors, Python) by Marcin Kuźmiński on June-25-2009

Today is Eclipse Galileo release day. So i made my new PyDev + eclipse compilation with some customizations.

I remove all the unnecessary stuff for java IDE since we program in python we don’t need java stuff in there( and it loads faster to :D )
replaced splash screen with the one from pyDev site, and throw some nice (Python) window icons.

Here’s the main window:
Screenshot-Pydev - Eclipse

Here’s what you have to do to have my setup:

  • Get the newest version of eclipse for java IDE (not the EE) use this direct link if you want download eclipse
  • extract folder eclipse to you hard drive and rename it to let’s say PyDev ;]
  • DON’T RUN ECLIPSE !! please
  • Ok here’s what you have to remove to get rid of all the java stuff
    (i have nothing against java, but we’re talking python here)
  • from folder features remove org.eclipse.jdt_3.5.0.v20090527-2000-7r88FEeFJePyvYeA33DjZ_c1
  • from folder plugins remove
    org.eclipse.jdt.debug_3.5.0.v20090526
    org.eclipse.jdt.apt.core_3.3.200.v20090528-1135.jar
    org.eclipse.jdt.apt.pluggable.core_1.0.200.v20090526-2130.jar
    org.eclipse.jdt.apt.ui_3.3.200.v20090528-1135.jar
    org.eclipse.jdt.compiler.apt_1.0.200.v20090528-1135.jar
    org.eclipse.jdt.compiler.tool_1.0.100.v_963.jar
    org.eclipse.jdt.core.manipulation_1.3.0.v20090603.jar
    org.eclipse.jdt.core_3.5.0.v_963.jar
    org.eclipse.jdt.debug.ui_3.4.0.v20090527.jar
    org.eclipse.jdt.doc.user_3.5.0.v20090603-1530.jar
    org.eclipse.jdt.junit.runtime_3.4.100.v20090513-2000.jar
    org.eclipse.jdt.junit4.runtime_1.1.0.v20090513-2000.jar
    org.eclipse.jdt.junit_3.5.0.v20090526-2000.jar
    org.eclipse.jdt.launching_3.5.0.v20090527.jar
    org.eclipse.jdt.ui_3.5.0.v20090604.jar
    org.eclipse.jdt_3.5.0.v200906111540.jar
  • Firstly i decided to remove epp.package.java but this really screws up eclipse and the icons so don’t do it
  • Now download this pydev icons  package pydev_icons and extract it somewhere
    if you don’t need the eclipse icon replacement you can skip this.
  • Copy and replace splash.bmp to folder plugins/org.eclipse.platform_3.3.200.v200906111540
    and paste rest of images to folder in plugins/org.eclipse.epp.package.java_1.2.0.20090619-0620
  • In case of newer eclipse builds (3.5.2) just copy everything to plugins/org.eclipse.platform_*.*(version number) and remove the gifs, so eclipse will load png
  • Your done !

Now run eclipse save you workspace and setup pydev as in this post:

http://www.python-blog.com/index.php/2009/06/20/python-ide-pydev-best-choice/

Enjoy lighter version of newest eclipse galileo with Pydev and some nice icons :)

UPDATE: I changed the splash screen in pydev icons to be the same size as original one.