Skip to main content
This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (
Help us improve Python packaging - Donate today!

No project description provided.

Project Description

CodeGenLoader is a Python import hook that transparently runs a code generator at import time, allowing the use of generated code without a separate compilation step. The package includes an extensible base class as well as implementations for the Protocol Buffer and Thrift code generators.


pip install codegenloader


CodeGenLoader runs on Python 2 (2.5+) and 3, including pypy and jython. The base class does not have any external dependencies, but to use the Thrift or Protocol Buffer subclasses you will need the thrift or protobuf packages installed. Note that protobuf 3.0.0 (currently in alpha) is required to use protobuf on Python 3.


Add the following two lines to mypackage/proto/

import codegenloader.protobuf
__path__ = codegenloader.protobuf.make_path(__name__, ".")

Now, assuming foo.proto exists in in mypackage/proto/, you can do:

from mypackage.proto.foo_pb2 import Foo

More info

The source code is hosted at Detailed documentation can be found at

Release History

This version
History Node


History Node


Download Files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

File Name & Hash SHA256 Hash Help Version File Type Upload Date
(5.0 kB) Copy SHA256 Hash SHA256
Source Mar 15, 2015

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting