~nicoco/messlidger#3: 
setuptools_scm

To adopt the fix in #8 I tried to update using pip install -U but it failed.

pip install -U
[slidge@example ~]$ . slidge-env/bin/activate
(slidge-env) [slidge@example ~]$ pip install -U git+https://git.sr.ht/~nicoco/messlidger
Collecting git+https://git.sr.ht/~nicoco/messlidger
  Cloning https://git.sr.ht/~nicoco/messlidger to /tmp/pip-req-build-u7m8zyiy
  Running command git clone --filter=blob:none --quiet 'https://git.sr.ht/~nicoco/messlidger' /tmp/pip-req-build-u7m8zyiy
  warning: filtering not recognized by server, ignoring
  Resolved https://git.sr.ht/~nicoco/messlidger to commit 99c5beb508976d11a48ab9a8429ec6bc1271f345
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
Collecting slidge@ git+https://git.sr.ht/~nicoco/slidge@master
  Cloning https://git.sr.ht/~nicoco/slidge (to revision master) to /tmp/pip-install-vw5ny1il/slidge_8dc71373214e42faa9bb245c6badb686
  Running command git clone --filter=blob:none --quiet 'https://git.sr.ht/~nicoco/slidge' /tmp/pip-install-vw5ny1il/slidge_8dc71373214e42faa9bb245c6badb686
  warning: filtering not recognized by server, ignoring
  Resolved https://git.sr.ht/~nicoco/slidge to commit da14a27bbb65c2cc198e6154abe3ef81e347a728
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
Requirement already satisfied: mautrix-facebook<0.6.0,>=0.5.0 in ./slidge-env/lib/python3.11/site-packages (from messlidger==0.0.0.dev0) (0.5.0)
Requirement already satisfied: aiohttp<4,>=3 in ./slidge-env/lib/python3.11/site-packages (from mautrix-facebook<0.6.0,>=0.5.0->messlidger==0.0.0.dev0) (3.8.5)
Requirement already satisfied: asyncpg<0.28,>=0.20 in ./slidge-env/lib/python3.11/site-packages (from mautrix-facebook<0.6.0,>=0.5.0->messlidger==0.0.0.dev0) (0.27.0)
Requirement already satisfied: commonmark<0.10,>=0.8 in ./slidge-env/lib/python3.11/site-packages (from mautrix-facebook<0.6.0,>=0.5.0->messlidger==0.0.0.dev0) (0.9.1)
Requirement already satisfied: mautrix<0.20,>=0.19.16 in ./slidge-env/lib/python3.11/site-packages (from mautrix-facebook<0.6.0,>=0.5.0->messlidger==0.0.0.dev0) (0.19.16)
Requirement already satisfied: paho-mqtt<2,>=1.5 in ./slidge-env/lib/python3.11/site-packages (from mautrix-facebook<0.6.0,>=0.5.0->messlidger==0.0.0.dev0) (1.6.1)
Requirement already satisfied: pycryptodome<4,>=3 in ./slidge-env/lib/python3.11/site-packages (from mautrix-facebook<0.6.0,>=0.5.0->messlidger==0.0.0.dev0) (3.18.0)
Requirement already satisfied: python-magic<0.5,>=0.4 in ./slidge-env/lib/python3.11/site-packages (from mautrix-facebook<0.6.0,>=0.5.0->messlidger==0.0.0.dev0) (0.4.27)
Requirement already satisfied: ruamel.yaml<0.18,>=0.15.94 in ./slidge-env/lib/python3.11/site-packages (from mautrix-facebook<0.6.0,>=0.5.0->messlidger==0.0.0.dev0) (0.17.32)
Requirement already satisfied: yarl<2,>=1 in ./slidge-env/lib/python3.11/site-packages (from mautrix-facebook<0.6.0,>=0.5.0->messlidger==0.0.0.dev0) (1.9.2)
Requirement already satisfied: zstandard in ./slidge-env/lib/python3.11/site-packages (from mautrix-facebook<0.6.0,>=0.5.0->messlidger==0.0.0.dev0) (0.21.0)
Requirement already satisfied: attrs>=17.3.0 in ./slidge-env/lib/python3.11/site-packages (from aiohttp<4,>=3->mautrix-facebook<0.6.0,>=0.5.0->messlidger==0.0.0.dev0) (23.1.0)
Requirement already satisfied: charset-normalizer<4.0,>=2.0 in ./slidge-env/lib/python3.11/site-packages (from aiohttp<4,>=3->mautrix-facebook<0.6.0,>=0.5.0->messlidger==0.0.0.dev0) (3.2.0)
Requirement already satisfied: multidict<7.0,>=4.5 in ./slidge-env/lib/python3.11/site-packages (from aiohttp<4,>=3->mautrix-facebook<0.6.0,>=0.5.0->messlidger==0.0.0.dev0) (6.0.4)
Requirement already satisfied: async-timeout<5.0,>=4.0.0a3 in ./slidge-env/lib/python3.11/site-packages (from aiohttp<4,>=3->mautrix-facebook<0.6.0,>=0.5.0->messlidger==0.0.0.dev0) (4.0.3)
Requirement already satisfied: frozenlist>=1.1.1 in ./slidge-env/lib/python3.11/site-packages (from aiohttp<4,>=3->mautrix-facebook<0.6.0,>=0.5.0->messlidger==0.0.0.dev0) (1.4.0)
Requirement already satisfied: aiosignal>=1.1.2 in ./slidge-env/lib/python3.11/site-packages (from aiohttp<4,>=3->mautrix-facebook<0.6.0,>=0.5.0->messlidger==0.0.0.dev0) (1.3.1)
Requirement already satisfied: ruamel.yaml.clib>=0.2.7 in ./slidge-env/lib/python3.11/site-packages (from ruamel.yaml<0.18,>=0.15.94->mautrix-facebook<0.6.0,>=0.5.0->messlidger==0.0.0.dev0) (0.2.7)
Requirement already satisfied: idna>=2.0 in ./slidge-env/lib/python3.11/site-packages (from yarl<2,>=1->mautrix-facebook<0.6.0,>=0.5.0->messlidger==0.0.0.dev0) (3.4)

[notice] A new release of pip available: 22.3.1 -> 23.2.1
[notice] To update, run: pip install --upgrade pip
(slidge-env) [slidge@example ~]$
(slidge-env) [slidge@example ~]$ less ~/slidge-env/lib/python3.11/site-packages/messlidger/group.py 
[...]  # **this is the old version of the code:**
    async def get_thread(self):
        thread = self.thread
        if not thread:
            thread = self.session.bookmarks.threads.pop(self.legacy_id, None)

        if not thread:
            thread = (await self.session.api.fetch_thread_info(self.legacy_id))[0]
        self.thread = thread
        return thread
[...]

I was able to upgrade only by erasing it first:

pip uninstall -y && pip install -U
(slidge-env) [slidge@example ~]$ pip uninstall -y messlidger
Found existing installation: messlidger 0.0.0.dev0
Uninstalling messlidger-0.0.0.dev0:
  Successfully uninstalled messlidger-0.0.0.dev0
(slidge-env) [slidge@example ~]$ pip install -U git+https://git.sr.ht/~nicoco/messlidger
Collecting git+https://git.sr.ht/~nicoco/messlidger
  Cloning https://git.sr.ht/~nicoco/messlidger to /tmp/pip-req-build-r1ws0wtg
  Running command git clone --filter=blob:none --quiet 'https://git.sr.ht/~nicoco/messlidger' /tmp/pip-req-build-r1ws0wtg
  warning: filtering not recognized by server, ignoring
  Resolved https://git.sr.ht/~nicoco/messlidger to commit 99c5beb508976d11a48ab9a8429ec6bc1271f345
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
Collecting slidge@ git+https://git.sr.ht/~nicoco/slidge@master
  Cloning https://git.sr.ht/~nicoco/slidge (to revision master) to /tmp/pip-install-wwjl8ba2/slidge_25b766ea35cb4bf5ad039727bc46e9bc
  Running command git clone --filter=blob:none --quiet 'https://git.sr.ht/~nicoco/slidge' /tmp/pip-install-wwjl8ba2/slidge_25b766ea35cb4bf5ad039727bc46e9bc
  warning: filtering not recognized by server, ignoring
  Resolved https://git.sr.ht/~nicoco/slidge to commit da14a27bbb65c2cc198e6154abe3ef81e347a728
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
Requirement already satisfied: mautrix-facebook<0.6.0,>=0.5.0 in ./slidge-env/lib/python3.11/site-packages (from messlidger==0.0.0.dev0) (0.5.0)
Requirement already satisfied: aiohttp<4,>=3 in ./slidge-env/lib/python3.11/site-packages (from mautrix-facebook<0.6.0,>=0.5.0->messlidger==0.0.0.dev0) (3.8.5)
Requirement already satisfied: asyncpg<0.28,>=0.20 in ./slidge-env/lib/python3.11/site-packages (from mautrix-facebook<0.6.0,>=0.5.0->messlidger==0.0.0.dev0) (0.27.0)
Requirement already satisfied: commonmark<0.10,>=0.8 in ./slidge-env/lib/python3.11/site-packages (from mautrix-facebook<0.6.0,>=0.5.0->messlidger==0.0.0.dev0) (0.9.1)
Requirement already satisfied: mautrix<0.20,>=0.19.16 in ./slidge-env/lib/python3.11/site-packages (from mautrix-facebook<0.6.0,>=0.5.0->messlidger==0.0.0.dev0) (0.19.16)
Requirement already satisfied: paho-mqtt<2,>=1.5 in ./slidge-env/lib/python3.11/site-packages (from mautrix-facebook<0.6.0,>=0.5.0->messlidger==0.0.0.dev0) (1.6.1)
Requirement already satisfied: pycryptodome<4,>=3 in ./slidge-env/lib/python3.11/site-packages (from mautrix-facebook<0.6.0,>=0.5.0->messlidger==0.0.0.dev0) (3.18.0)
Requirement already satisfied: python-magic<0.5,>=0.4 in ./slidge-env/lib/python3.11/site-packages (from mautrix-facebook<0.6.0,>=0.5.0->messlidger==0.0.0.dev0) (0.4.27)
Requirement already satisfied: ruamel.yaml<0.18,>=0.15.94 in ./slidge-env/lib/python3.11/site-packages (from mautrix-facebook<0.6.0,>=0.5.0->messlidger==0.0.0.dev0) (0.17.32)
Requirement already satisfied: yarl<2,>=1 in ./slidge-env/lib/python3.11/site-packages (from mautrix-facebook<0.6.0,>=0.5.0->messlidger==0.0.0.dev0) (1.9.2)
Requirement already satisfied: zstandard in ./slidge-env/lib/python3.11/site-packages (from mautrix-facebook<0.6.0,>=0.5.0->messlidger==0.0.0.dev0) (0.21.0)
Requirement already satisfied: attrs>=17.3.0 in ./slidge-env/lib/python3.11/site-packages (from aiohttp<4,>=3->mautrix-facebook<0.6.0,>=0.5.0->messlidger==0.0.0.dev0) (23.1.0)
Requirement already satisfied: charset-normalizer<4.0,>=2.0 in ./slidge-env/lib/python3.11/site-packages (from aiohttp<4,>=3->mautrix-facebook<0.6.0,>=0.5.0->messlidger==0.0.0.dev0) (3.2.0)
Requirement already satisfied: multidict<7.0,>=4.5 in ./slidge-env/lib/python3.11/site-packages (from aiohttp<4,>=3->mautrix-facebook<0.6.0,>=0.5.0->messlidger==0.0.0.dev0) (6.0.4)
Requirement already satisfied: async-timeout<5.0,>=4.0.0a3 in ./slidge-env/lib/python3.11/site-packages (from aiohttp<4,>=3->mautrix-facebook<0.6.0,>=0.5.0->messlidger==0.0.0.dev0) (4.0.3)
Requirement already satisfied: frozenlist>=1.1.1 in ./slidge-env/lib/python3.11/site-packages (from aiohttp<4,>=3->mautrix-facebook<0.6.0,>=0.5.0->messlidger==0.0.0.dev0) (1.4.0)
Requirement already satisfied: aiosignal>=1.1.2 in ./slidge-env/lib/python3.11/site-packages (from aiohttp<4,>=3->mautrix-facebook<0.6.0,>=0.5.0->messlidger==0.0.0.dev0) (1.3.1)
Requirement already satisfied: ruamel.yaml.clib>=0.2.7 in ./slidge-env/lib/python3.11/site-packages (from ruamel.yaml<0.18,>=0.15.94->mautrix-facebook<0.6.0,>=0.5.0->messlidger==0.0.0.dev0) (0.2.7)
Requirement already satisfied: idna>=2.0 in ./slidge-env/lib/python3.11/site-packages (from yarl<2,>=1->mautrix-facebook<0.6.0,>=0.5.0->messlidger==0.0.0.dev0) (3.4)
Building wheels for collected packages: messlidger
  Building wheel for messlidger (pyproject.toml) ... done
  Created wheel for messlidger: filename=messlidger-0.0.0.dev0-py3-none-any.whl size=24310 sha256=6fa7b33ef3087660fb831c0d47007a6943dd9568c39984e0ba4a400a1e741a65
  Stored in directory: /tmp/pip-ephem-wheel-cache-ovvu23ow/wheels/be/67/ce/1ec0d6f9d5e2c03e94895e46828a0d46f596a8cf0be101d004
Successfully built messlidger
Installing collected packages: messlidger
Successfully installed messlidger-0.0.0.dev0

[notice] A new release of pip available: 22.3.1 -> 23.2.1
[notice] To update, run: pip install --upgrade pip
(slidge-env) [slidge@example ~]$ 
(slidge-env) [slidge@example ~]$ less ~/slidge-env/lib/python3.11/site-packages/messlidger/group.py
# [...] This is the fixed code
    async def get_thread(self):
        thread = self.thread
        if not thread:
            thread = self.session.bookmarks.threads.pop(self.legacy_id, None)

        if not thread:
            try:
                threads = await self.session.api.fetch_thread_info(self.legacy_id)
            except Exception as e:
                raise XMPPError(
                    "internal-server-error", f"This group chat cannot be fetched: {e}"
                )
            if not threads:
                raise XMPPError("item-not-found")
            if not isinstance(threads, list) or len(threads) != 1:
                self.log.warning("Weird fetch_thread_info response: %s", threads)
                raise XMPPError(
                    "internal-server-error", f"Bad response from maufbapi: {threads}"
                )

            thread = threads[0]
        self.thread = thread
        return thread
# [...]

Have you heard of https://pypi.org/project/setuptools-scm/ ? It handles this case well, naming in-between bleeding-edge versions like v0.0.1.dev52+gda14a27 and ensuring your code is always installable whether from pypi or git or a tarball. I use it a lot, I recommend it!

Status
REPORTED
Submitter
~kousu
Assigned to
No-one
Submitted
9 months ago
Updated
7 months ago
Labels
No labels applied.

~kousu 9 months ago

Sorry, in #2. I got confused about which repo I was looking at.

~nicoco 9 months ago

Thanks for the recommendation, I wonder if that plays nice with poetry though. Maybe I should ditch poetry at some point, I'm not entirely sure if that's a good idea since I am used to it. Packaging issues never end…

~kousu 9 months ago

It looks like poetry has a different plugin for this: https://github.com/mtkennerly/poetry-dynamic-versioning

I'm unclear how to install properly from source. All your build docs say to use pipx, which, I think, means..pip? poetry is for building wheels, so pipx/pip should be able to install that, but from source you say to use docker-compose which I guess means it has to first run poetry. I guess I don't understand poetry so maybe I'm assuming working with that on code you're doing a lot of edits to would be more annoying than it is.

~nicoco 9 months ago

There are packages installable with pip(x) as artifacts of this build job. Releases will be uploaded to PyPI at some point, and I plan to someday automate uploading build job artifacts to https://slidge.im/repo/ that can be used as "alternative pypi" sources for the bleeding edge. A lot of plans, not much done yet. :) The docs always need improvements, I agree…

~nicoco 8 months ago

I think this is fixed by the newish way I recommended in the "legacy modules" READMEs, eg:

pipx install messlidger --pip-args='--extra-index-url https://slidge.im/repo'

Can you confirm?

~nicoco 7 months ago

Bump! Did you try updating with the brand new pipx recommended way?

Register here or Log in to comment, or comment via email.