stash icon indicating copy to clipboard operation
stash copied to clipboard

Do not work in pythonista 3.5 (TestFlight)

Open o-murphy opened this issue 5 months ago • 18 comments

Don't launch because of imp module removed

o-murphy avatar Aug 02 '25 01:08 o-murphy

I've looked into this a couple of weeks ago. The problem isn't really the imp module - replacing it is trivial - it's the missing six module. StaSh was originally written for py2 and later ported to py3. However, several functions of StaSh, for example git, were never ported. As a interim solution, we instead ported StaSh to support both py2 and py3 simultaneously, so that if anyone needed a py2-only feature they could still use it. This required us to make extensive use of the six module for improved compatibility. Now, however, the six module is no longer included in pythonista3, so someone would have to rewrite all that code again.

Anyway, we could simply fix the imp problem, but until someone removes six (or, preferably, six would be included in pythonista again) it wouldn't actually fix anything. That would likely involve dropping py2 support, which in turn should involve a change in the update strategy (see https://github.com/ywangd/stash/pull/463#issuecomment-1407885936).

bennr01 avatar Aug 02 '25 01:08 bennr01

I've looked into this a couple of weeks ago. The problem isn't really the imp module - replacing it is trivial - it's the missing six module. StaSh was originally written for py2 and later ported to py3. However, several functions of StaSh, for example git, were never ported. As a interim solution, we instead ported StaSh to support both py2 and py3 simultaneously, so that if anyone needed a py2-only feature they could still use it. This required us to make extensive use of the six module for improved compatibility. Now, however, the six module is no longer included in pythonista3, so someone would have to rewrite all that code again.

Anyway, we could simply fix the imp problem, but until someone removes six (or, preferably, six would be included in pythonista again) it wouldn't actually fix anything. That would likely involve dropping py2 support, which in turn should involve a change in the update strategy (see https://github.com/ywangd/stash/pull/463#issuecomment-1407885936).

I got you. Btw, there also pip not works if I replace imp with importlib. I think we able to use original pip, as it already done in pipTerminal

o-murphy avatar Aug 02 '25 11:08 o-murphy

@bennr01 Do we can take six from pip/github? Looks like sources are there and we able to download it for stash

o-murphy avatar Aug 02 '25 11:08 o-murphy

I have pyterminal original pip 25 installed with pipTerminal and then six installed with this pip, but there issuess with cli arguments handling in stash

image

image

image

o-murphy avatar Aug 02 '25 11:08 o-murphy

Use this to install modern pip https://github.com/CrossDarkrix/Pythonista3_pip_Configration_Tool

o-murphy avatar Aug 02 '25 11:08 o-murphy

I used pipTerminal v2.0.8 with lib2to3 requirements commented

image

o-murphy avatar Aug 02 '25 11:08 o-murphy

I thought the Beta had a built in way to install third party modules. That would make StaSH unnecessary.

cclauss avatar Aug 03 '25 19:08 cclauss

I thought the Beta had a built in way to install third party modules. That would make StaSH unnecessary.

In my opinion, either this should support regular pip, or given the lack of venv support, there should be support for resolvers like in poetry or uv, which would guarantee full compatibility of all installed modules with each other.

o-murphy avatar Aug 03 '25 22:08 o-murphy

Apple Security Guidelines only allow users to install pure Python modules, so equivalence with Poetry/uv is not going to happen.

cclauss avatar Aug 04 '25 04:08 cclauss

We need a PR that removes the six dependency because lib2to3 was deprecated in Python 3.11 and removed in 3.13.

  • https://docs.python.org/3/whatsnew/3.13.html

Python 2 died 2042 days ago on 1/1/2020, so removing support for it is not controversial.

cclauss avatar Aug 04 '25 05:08 cclauss

We need a PR that removes the six dependency because lib2to3 was deprecated in Python 3.11 and removed in 3.13.

  • https://docs.python.org/3/whatsnew/3.13.html

Python 2 died 2042 days ago on 1/1/2020, so removing support for it is not controversial.

Agreed, but we need sollution to manage packages anyway

o-murphy avatar Aug 04 '25 06:08 o-murphy

We need a PR that removes the six dependency because lib2to3 was deprecated in Python 3.11 and removed in 3.13.

  • https://docs.python.org/3/whatsnew/3.13.html

Python 2 died 2042 days ago on 1/1/2020, so removing support for it is not controversial.

pipTerminal updated for 3.5 support

o-murphy avatar Aug 04 '25 13:08 o-murphy

so, six is just single file module, I mean it simply can be added inside stash. Also I started revisiting stash sources, that's not looks too hard to update, possibly I will do it

o-murphy avatar Aug 04 '25 15:08 o-murphy

Six requires lib2to3 which was removed in Python >= 3.13.

cclauss avatar Aug 04 '25 15:08 cclauss

Six requires lib2to3 which was removed in Python >= 3.13.

Seem like six on pypi not require it. I'll check it again tooday soon.

Second one thing, I can replace stash/bin/pip.py (current does not work). With the bind to common pip, and add pip installation from pypa bootstrap to get-stash (it simple as f*uck), so after stash installation we will have at least common pip installed to site-packages (user) and binding in bin/. I already tested it and it works pretty fine. And it allow pip install --upgrade pip

image

Lots of stash tools are not require six or lib2to3. So it can be replaced simply. Other tools I can try to update to use common modern requirements instead of deprecated.

o-murphy avatar Aug 04 '25 15:08 o-murphy

@cclauss @bennr01 I just started

  • #524

o-murphy avatar Aug 04 '25 20:08 o-murphy

@cclauss I understand that it is difficult to review such a massive PR

After this PR I will add separate small PRs with refactoring, as a lot of code requires removal of obsolete fragments and optimization

o-murphy avatar Aug 05 '25 11:08 o-murphy

This PR is great because stash is very connected and many modules depend on each other

o-murphy avatar Aug 05 '25 12:08 o-murphy