Uploaded image for project: 'Apache Avro'
  1. Apache Avro
  2. AVRO-2635

Guidance on how to properly invoke tools.py

    XMLWordPrintableJSON

Details

    • Task
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 1.10.0
    • python
    • None

    Description

      We need to move the deprecated StringIO.StringIO and cStringIO.StringIO usages in the Python codebase to modern io.BytesIO. Weirdly, if we do that, the interop tests will fail, because we shadow Python's builtin io module with avro.io by invoking tool.py directly from within the python package with e.g. python lang/py/build/src/avro/tool.py rpcsend.

      When you invoke a python script directly, Python prepends the script's path to the sys.path. Since avro's io.py is in the same path as tool.py, the standard library's io module becomes inaccessible.

      There are a couple of ways we can resolve this, but none are entirely transparent to end users:

      1. Move tool.py into a subdirectory so it isn't in the same path as io.py}}.
      2. Guide users not to invoke tool.py directly, but instead to call python -m avro.tool.
      3. Install tool.py into the PATH via setuptools' console_scripts entrypoint.

      Option #1 would require a significant code change and still require updating documentation and unconfusing users.
      Option #3 would be tricky to implement given how our current codebase expects to install with both and and setuptools.

      So my suggestion is that we go with Option #2, and introduce a warning into tool.py so that folks get a helpful message right before the crash.

      Attachments

        Issue Links

          Activity

            People

              kojiromike Michael A. Smith
              kojiromike Michael A. Smith
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: