Skip to content

Drop dependecy pkg_resources required by kaitaistruct autogenerated code #5401

Closed

Description

@PavelICS

Problem Description

pkg_resources is used here only to check kaitaistruct installed version. Kaitaistruct by itself doesn't use this package.

But this package also on import do a lot of other stuff, that slows down the code startup time and causes a lot of other problems in my project. So I've dropped it from mitmproxy at my local version.
Also, as I know, you build executable files. This would help to increase startup speed and decrease exe file size.

I know that there were already a lot of topics about this problem. But I don't see anything that stops us from this step (drop pkg_resources).

Starting from the kaitaistruct version 0.10, they've already dropped pkg_resources dependency.
You can read the related issue here:
kaitai-io/kaitai_struct#804

This issue also solved your issue
kaitai-io/kaitai_struct_python_runtime#62

Proposal

Drop pkg_resources dependency.

Alternatives

Because it's used only to check an installed kaitaistruct version there are some proposals:

  1. Drop this checks and don't check kaitaistruct version at all. In the wheel it said: kaitaistruct (<0.10,>=0.7). So it would be strange if you try to use mitmproxy with some other kaitaistruct versions. For me it's a bit strange why do we check kaitaistruct package version, but don't check other dependencies versions.

  2. Use our own version checker.
    It would be better to check the version only once by moving it to the nearest init file. I'm ready to write a simple version checker based on regexp.

I'm ready to create a PR for any chosen alternative.

Additional context

There is only one minor issue. If you decide to recompile these files with an old version kaitaistruct (<0.10), this patch should be applied again. But if we're going to recompile them, shouldn't we use a newer version.

So let's finally solve this problem :)

Activity

  1. added
    kind/feature
    on Jun 5, 2022
  2. mhils commented on Jun 6, 2022

    @mhils
    Member

    Thanks for raising this! Ideally we'd just wait for a kaitai 0.10 release and then recompile, but not sure when this happens. For now I'd be happy to merge a PR that just removes the checks. As you say, we check the version anyway. We can add a

    # manually removed version check, see https://github.com/mitmproxy/mitmproxy/issues/5401
    

    comment instead to make sure it's not inadvertently reintroduced when someone recompiles with 0.9.

  3. PavelICS commented on Jun 7, 2022

    @PavelICS
    ContributorAuthor

    Closed by #5403

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/feature

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions