2

I'm just now branching out into python packaging after using proprietary packaging methods for over a decade.

I have a data file that is used to generate python code that is a part of my package that runs on Windows and Linux. I'm trying to integrate it into my build process (tox / TravisCI) for generating my package and uploading to PyPI. Think of the data files as something similar to .proto files for protobuf though the generator is written in python.

Options I've thought of but rejected

  • Dynamically create objects by reading the data file at import time
    • Con: Harder to debug the build process because you can't read the code
    • Con: Limits the usefulness of static analysis (flake8, mypy)
  • Check the generated code in (what I currently do)
    • Con: More manual steps means more chances for making mistakes
    • Con: Contributors missing the code-gen and modifying the generated output

Ideally, the solution would be easy for any of our Windows or Linux users to get up to speed on to remove barriers to contributing back.

Ed Page
  • 46
  • 2
  • Depends on when you need to generate that data. I suggest looking into setuptools. You could override the build step for example and add your generation then. – Oliver Bestwalter Jul 06 '17 at 17:32
  • The generator is pure python code. I'd rather not be required to vendor it but am willing to consider it. I think I've heard of this being possible with setuptools but I can't find any documentation for it. If its in setuptools docs, I must have missed it. Doing searches python and code-gen tend to give results for code-genning with python rather than integrating it into a python build process. – Ed Page Jul 07 '17 at 17:05
  • Docs won't help you much here. Use the source Luke :) – Oliver Bestwalter Jul 07 '17 at 18:17

0 Answers0