Giter VIP home page Giter VIP logo

raghav3112 / codegenloader Goto Github PK

View Code? Open in Web Editor NEW

This project forked from bdarnell/codegenloader

0.0 1.0 0.0 15 KB

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.

License: MIT License

Python 99.83% Thrift 0.17%

codegenloader's Introduction

CodeGenLoader

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.

Installation

pip install codegenloader

Prerequisites

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.

Example

Add the following two lines to mypackage/proto/__init__.py:

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 https://github.com/bdarnell/codegenloader Detailed documentation can be found at http://codegenloader.readthedocs.org

codegenloader's People

Contributors

bdarnell avatar lowks avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.