Search code examples
python-3.xpackagingdebsoftware-packaging

Packaging Multiple Python Files


I currently am using this guide to package up my project wasp. However currently everything lives inside of the wasp file.

That's not ideal. I would rather have all the classes in separate files so it can be more effectively managed. I have the series of files needed in the debian directory. But I'm not sure how to configure the packaging to package multiple files.

Is there a way to change my packaging to package more than just the one script file?


Solution

  • I'm not a debian package or Python expert, but one way would be to copy the various source files to another location (outside of /usr/bin), and then have /usr/bin/wasp call out to them.

    Say you put all of your python code in src/ in the root of your repo. In the debian/install file, you'd have:

    wasp usr/bin
    src/* usr/lib/wasp/
    

    You'd then just need /usr/bin/wasp to call some entry point in src. For example,

    #!/usr/bin/python3
    
    import sys
    sys.path.append('/usr/lib/wasp/')
    
    import wasp # or whatever you expose in src
    
    # ...
    

    Again, I don't know the best practices here (either in directory or python usage) but I think this would at least work!