You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@avro.apache.org by "Michael A. Smith (Jira)" <ji...@apache.org> on 2019/11/20 01:38:00 UTC

[jira] [Assigned] (AVRO-2635) Guidance on how to properly invoke tools.py

     [ https://issues.apache.org/jira/browse/AVRO-2635?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Michael A. Smith reassigned AVRO-2635:
--------------------------------------

    Assignee: Michael A. Smith

> Guidance on how to properly invoke tools.py
> -------------------------------------------
>
>                 Key: AVRO-2635
>                 URL: https://issues.apache.org/jira/browse/AVRO-2635
>             Project: Apache Avro
>          Issue Type: Task
>          Components: python
>            Reporter: Michael A. Smith
>            Assignee: Michael A. Smith
>            Priority: Major
>
> 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|https://github.com/apache/avro/blob/fd80ae5939270a4af993465ca625f50f46a791b6/share/test/interop/bin/test_rpc_interop.sh#L27] 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:
> # Move tool.py into a subdirectory so it isn't in the same path as io.py}}.
> # Guide users not to invoke tool.py directly, but instead to call {{python -m avro.tool}}.
> # 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.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)