Concatenates python scripts into one ugly behemoth
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


Tries to concatenate several python modules into a single script. Does this by creating module-like objects and sticking them in sys.modules for each module found to be a dependency.

As done as I'm going to make it for a while, since acheived the goal of concatenating my toy bittorrent client.

This is obviously a terrible idea! Don't use this!


  • clone repo (git clone

  • navigate to the script with dependencies you're trying to concatenate

  • run python ../../../pyconcat/

See also

pybreeder [] by @BjarniRunar looks like a more sensible way to go about this, instead of building fake modules.


  • Going to start with my files, then packages and dependencies, maybe down the line compiled stuff?

I bet this would really screw up a lot of things; pickle comes to mind immediately

  • todo: check out modulefinder and modulegraph for the dependencies step

We need to do some name modifying, and some other things probably too

First: figure out dependencies

We could do this the same way (just dynamically recreate all the modules from big strings) or we could do something more interesting

Don't conditionally import things! Or at least don't do it after code that would fail in a parser