Repository: mitmproxy/mitmproxy

Issue:
mitmproxy depends on `pkg_resources` at runtime but does not specify `install_requires=setuptools`
#### Problem Description
A clear and concise description of what the bug is.

https://github.com/mitmproxy/mitmproxy/blob/0ca458fd6475ee48728147f3b529467a75e912a4/mitmproxy/contrib/kaitaistruct/exif.py#L7

the `pkg_resources` module is provided by `setuptools`

installation into a minimal environment (for example, bazel) will break without also needing to specify `setuptools`

mitmproxy should depend on `setuptools`


#### Steps to reproduce the behavior:

1. simulate a minimal environment:

```
virtualenv venv
venv/bin/pip install mitmproxy
venv/bin/pip uninstall setuptools
venv/bin/pip install mitmproxy  # make sure we actually have its deps even after uninstalling
```

2. run `mitmproxy --help`

```console
$ venv/bin/mitmproxy --help
Traceback (most recent call last):
  File "venv/bin/mitmproxy", line 5, in <module>
    from mitmproxy.tools.main import mitmproxy
  File "/tmp/y/venv/lib/python3.8/site-packages/mitmproxy/tools/main.py", line 8, in <module>
    from mitmproxy import exceptions, master
  File "/tmp/y/venv/lib/python3.8/site-packages/mitmproxy/master.py", line 10, in <module>
    from mitmproxy import eventsequence
  File "/tmp/y/venv/lib/python3.8/site-packages/mitmproxy/eventsequence.py", line 8, in <module>
    from mitmproxy.proxy import layers
  File "/tmp/y/venv/lib/python3.8/site-packages/mitmproxy/proxy/layers/__init__.py", line 1, in <module>
    from . import modes
  File "/tmp/y/venv/lib/python3.8/site-packages/mitmproxy/proxy/layers/modes.py", line 9, in <module>
    from mitmproxy.proxy.layers import tls
  File "/tmp/y/venv/lib/python3.8/site-packages/mitmproxy/proxy/layers/tls.py", line 8, in <module>
    from mitmproxy.net import tls as net_tls
  File "/tmp/y/venv/lib/python3.8/site-packages/mitmproxy/net/tls.py", line 18, in <module>
    from mitmproxy.contrib.kaitaistruct import tls_client_hello
  File "/tmp/y/venv/lib/python3.8/site-packages/mitmproxy/contrib/kaitaistruct/tls_client_hello.py", line 7, in <module>
    from pkg_resources import parse_version
ModuleNotFoundError: No module named 'pkg_resources'
```

#### System Information
Paste the output of "mitmproxy --version" here.

```console
$ venv/bin/mitmproxy --version
Traceback (most recent call last):
  File "venv/bin/mitmproxy", line 5, in <module>
    from mitmproxy.tools.main import mitmproxy
  File "/tmp/y/venv/lib/python3.8/site-packages/mitmproxy/tools/main.py", line 8, in <module>
    from mitmproxy import exceptions, master
  File "/tmp/y/venv/lib/python3.8/site-packages/mitmproxy/master.py", line 10, in <module>
    from mitmproxy import eventsequence
  File "/tmp/y/venv/lib/python3.8/site-packages/mitmproxy/eventsequence.py", line 8, in <module>
    from mitmproxy.proxy import layers
  File "/tmp/y/venv/lib/python3.8/site-packages/mitmproxy/proxy/layers/__init__.py", line 1, in <module>
    from . import modes
  File "/tmp/y/venv/lib/python3.8/site-packages/mitmproxy/proxy/layers/modes.py", line 9, in <module>
    from mitmproxy.proxy.layers import tls
  File "/tmp/y/venv/lib/python3.8/site-packages/mitmproxy/proxy/layers/tls.py", line 8, in <module>
    from mitmproxy.net import tls as net_tls
  File "/tmp/y/venv/lib/python3.8/site-packages/mitmproxy/net/tls.py", line 18, in <module>
    from mitmproxy.contrib.kaitaistruct import tls_client_hello
  File "/tmp/y/venv/lib/python3.8/site-packages/mitmproxy/contrib/kaitaistruct/tls_client_hello.py", line 7, in <module>
    from pkg_resources import parse_version
ModuleNotFoundError: No module named 'pkg_resources'
```


Discussion:

Resolving patch:
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -86,6 +86,8 @@
         "pyparsing>=2.4.2,<2.5",
         "pyperclip>=1.6.0,<1.9",
         "ruamel.yaml>=0.16,<0.17.17",
+        # Kaitai parsers depend on setuptools, remove once https://github.com/kaitai-io/kaitai_struct_python_runtime/issues/62 is fixed
+        "setuptools",
         "sortedcontainers>=2.3,<2.5",
         "tornado>=6.1,<7",
         "urwid>=2.1.1,<2.2",


Test patch: