Skip to content

Alternative to Version from distutils/packaging #364

@tony

Description

@tony
Member

This is necessary in libtmux and tmuxp.

tmuxp uses this for tmux versions (via git and 3.0b, etc)

Needs to be flexible and ideally have no dependency

  • LegacyVersion deprecation

    In packaging, LegacyVersion (the supercessor to LooseVersion) will be deprecated, we won't be able to support 2.4-openbsd (like what is seen on OpenBSD's tmux versions

      /home/t/work/python/libtmux/.venv/lib/python3.10/site-packages/packaging/version.py:127: 
        DeprecationWarning: Creating a LegacyVersion has been deprecated and will be removed in the next major release
        warnings.warn(
    
    -- Docs: https://docs.pytest.org/en/stable/warnings.html
    

    tmux versions

     To the above, consider subclassing `Version` for tmux versions to handle git builds, platform builds, etc. then keeping `Version` for supporting pypi releases
    

    Version Assure that libtmux.__version__ / tmuxp.__version__ supports git refs / local match groups

Activity

bszonye

bszonye commented on Dec 11, 2022

@bszonye

Today I hit a tmuxp that looks related to this work. I've been moving my pip --user installs to use pipx instead, and I hit this error in startup:

$ ssh-agent tmuxp load wsl
Traceback (most recent call last):
  File "/home/bradd/.local/bin/tmuxp", line 5, in <module>
    from tmuxp import cli
  File "/home/bradd/.local/pipx/venvs/tmuxp/lib/python3.11/site-packages/tmuxp/__init__.py", line 11, in <module>
    from . import cli, util
  File "/home/bradd/.local/pipx/venvs/tmuxp/lib/python3.11/site-packages/tmuxp/cli/__init__.py", line 14, in <module>
    from libtmux.__about__ import __version__ as libtmux_version
  File "/home/bradd/.local/pipx/venvs/tmuxp/lib/python3.11/site-packages/libtmux/__init__.py", line 12, in <module>
    from .pane import Pane
  File "/home/bradd/.local/pipx/venvs/tmuxp/lib/python3.11/site-packages/libtmux/pane.py", line 12, in <module>
    from libtmux.common import tmux_cmd
  File "/home/bradd/.local/pipx/venvs/tmuxp/lib/python3.11/site-packages/libtmux/common.py", line 17, in <module>
    from ._compat import LooseVersion, console_to_str, str_from_console
  File "/home/bradd/.local/pipx/venvs/tmuxp/lib/python3.11/site-packages/libtmux/_compat.py", line 40, in <module>
    from packaging.version import Version
ModuleNotFoundError: No module named 'packaging'

It looks like libtmux depends on "packaging" as an undeclared dependency. That package is ubiquitous, so it's fine when installed globally or with --user, but in a fresh virtualenv (e.g. with pipx) the Version call crashes the utility. Probably libtmux should include the dependency in pyproject.toml until you find a replacement.

tony

tony commented on Dec 12, 2022

@tony
MemberAuthor

@bszonye Good catch! Taking a closer look now

tony

tony commented on Dec 12, 2022

@tony
MemberAuthor

@bszonye Fixed in libtmux v0.16.1, tmuxp v1.19.1

If you try now, any better?

See also #461

bszonye

bszonye commented on Dec 12, 2022

@bszonye

Works for me with tmuxp v1.191, thanks!

tony

tony commented on Dec 12, 2022

@tony
MemberAuthor

@bszonye Excellent!

I will close this for now per tmuxp 1.19.1 (via libtmux 0.16.1) handling the packaging dependency!

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

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @tony@bszonye

        Issue actions

          Alternative to `Version` from `distutils`/`packaging` · Issue #364 · tmux-python/libtmux