tdsmith / homebrew-pypi-poet

Generates Homebrew resource stanzas for Python packages.
MIT License
140 stars 30 forks source link

Graceful fallback when sdist is not available #57

Closed zmwangx closed 6 years ago

zmwangx commented 6 years ago
$ poet mitmproxy
/Users/zmwang/.pyenv/virtualenvs/tmp-a855353f32c7ddc/lib/python3.6/site-packages/poet/poet.py:97: PackageVersionNotFoundWarning: Could not find an exact version match for mitmproxy version 3.0.0; using newest instead
  format(name, version), PackageVersionNotFoundWarning)
Traceback (most recent call last):
  File "/Users/zmwang/.pyenv/virtualenvs/tmp-a855353f32c7ddc/bin/poet", line 11, in <module>
    sys.exit(main())
  File "/Users/zmwang/.pyenv/virtualenvs/tmp-a855353f32c7ddc/lib/python3.6/site-packages/poet/poet.py", line 250, in main
    print(resources_for([package] + args.also))
  File "/Users/zmwang/.pyenv/virtualenvs/tmp-a855353f32c7ddc/lib/python3.6/site-packages/poet/poet.py", line 175, in resources_for
    nodes = merge_graphs(make_graph(p) for p in packages)
  File "/Users/zmwang/.pyenv/virtualenvs/tmp-a855353f32c7ddc/lib/python3.6/site-packages/poet/poet.py", line 182, in merge_graphs
    for g in graphs:
  File "/Users/zmwang/.pyenv/virtualenvs/tmp-a855353f32c7ddc/lib/python3.6/site-packages/poet/poet.py", line 175, in <genexpr>
    nodes = merge_graphs(make_graph(p) for p in packages)
  File "/Users/zmwang/.pyenv/virtualenvs/tmp-a855353f32c7ddc/lib/python3.6/site-packages/poet/poet.py", line 142, in make_graph
    package_data = research_package(package, dependencies[package]['version'])
  File "/Users/zmwang/.pyenv/virtualenvs/tmp-a855353f32c7ddc/lib/python3.6/site-packages/poet/poet.py", line 105, in research_package
    d['url'] = artefact['url']
TypeError: 'NoneType' object is not subscriptable

The problem here is that mitmproxy 3.0.0 doesn't have an sdist, only a none-any bdist_wheel.[1] This is not great on their part, but we don't really care since we fetch the sdist from GitHub.

Maybe instead of failing right there, a more graceful approach could be taken here, e.g. print a warning and ignore the package?

[1] https://pypi.python.org/pypi/mitmproxy/3.0.0#downloads

tdsmith commented 6 years ago

Thanks for the report, Zhiming. This is also tracked as #29; I agree it's not optimal.