Skip to content

Conversation

@o-murphy
Copy link
Contributor

@o-murphy o-murphy commented Aug 4, 2025

Important

This PR does not offer backward compatibility with py2! However, it resolves problems for many commands. Possibly we
have to remove py2 support

Install to test using this command

import requests as r; exec(r.get('https://gist.githubusercontent.com/o-murphy/ad7bcee38551d24ec172032792a2bf8f/raw/158346c958601cc29a9cc8070d6e501111562e52/get-stash-py3.10-beta.py').content)

WIP: updating to py3, removing deprecated requirements

  • Completely removed Python 2 support. StaSh now uses only Python 3 and compatible with Pythonista 3.4 or higher.
    • Removed all Python 2 patches
    • Removed deprecated wheels support. StaSh now uses a common pip approach for installing Python wheels
    • The StaSh python alias has been set to python3 since Python 2 is no longer supported.
    • The man page_5.txt file has been updated to reflect the end of Python 2 support.
    • removed dependencies from six
    • removed dependencies from imp (replaced with importlib)

build-system

features

Updating core

Module State Tested Comment
core 🟢 updated
launch_stash 🟢 updated
getstash 🟢 actual just a wrapper around __main__ o-murphy#1
__main__.py 🟢 new main entry point

Updating system/

Module State Tested Comment
dummyconsole 🟢 actual
dummyobjc_util 🟢 actual
shcommon 🟢 updated
shhistory 🟢 actual
shio 🟢 actual
shiowrapper 🟢 updated
shparsers 🟢 updated
shruntime 🟢 updated
shscreens 🟢 updated
shstreams 🟢 updated
shthreads 🟢 actual
shureactionproxy 🟢 actual
shui/__init__ 🟢 updated
shui/base 🟢 updated
shui/dummyui 🟢 actual
shui/pythonistaui 🟢 actual
shui/stubui 🟢 actual
shui/tkui 🟢 updated

Updating lib/

  • git
  • mlpatches (not-tested)
  • stashutils (not-tested)
    • fsi
    • wheels
    • wakeonlan
  • libcompleter
  • libcore
  • libdist
  • libversion
  • pythonista_add_action

Updating bin/

Command State Tested Comment
alias 🟢 actual 🟢 (manually) Can be refactored
cat 🟢 actual 🟢 (manually) Can be refactored
cd 🟢 actual 🟢 (manually) Can be refactored
clear 🟢 actual 🟢 (manually) Can be refactored
cowsay 🟢 actual 🟢 (manually) Can be refactored
cp 🟢 actual 🟢 (manually) Can be refactored
crypt 🟢 updated 🟢 (manually) using pyaes-whl
curl 🟢 updated 🟢 (manually)
cut 🟢 actual 🟢 (manually)
diff 🟢 updated 🟢 (manually)
dropbox_setup 🟢 actual 🔴
du 🟢 actual 🟢 (manually)
easy_config 🟢 updated 🟢 (manually) Fixed incomplete shortcut creation with pinstash command
echo 🟢 actual 🟢 (manually)
edit 🟢 actual 🟢 (manually)
exit 🟢 actual 🟡 (manually) Seems like working
fg 🟢 actual 🔴
find 🟢 actual 🟢 (manually)
ftpserver 🟢 actual 🔴
gci 🟢 actual 🔴
gh 🔴 unsupported 🔴 lots of changes needed
git 🔴 unsupported 🔴 lots of changes needed, possibly should use dulwich from pypi
grep 🟢 actual 🟢 (manually)
head 🟢 actual 🟢 (manually)
httpserver 🟢 updated 🟢 (manually)
jobs 🟢 undone 🔴
kill 🟢 actual 🔴
latte 🟢 actual 🔴
ln 🟢 updated 🟢 (manually)
logout 🟢 actual 🔴
ls 🟢 updated 🟢 (manually)
mail 🟢 updated 🔴 Not works
man 🟢 actual 🟢 (manually)
mc 🟢 updated 🔴
md5sum 🟢 updated 🟢 (manually/pytest)
mkdir 🟢 actual 🟢 (manually)
monkeylord 🟢 updated 🟢 (manually)
more 🟢 actual 🟢 (manually)
mount 🟢 updated 🔴
mv 🟢 actual 🟢 (manually)
openin 🟢 actual 🟢 (manually)
pbcopy 🟢 actual 🟢 (manually)
pbpaste 🟢 updated 🟢 (manually)
ping 🟢 updated 🟢 (manually)
pinstash 🟢 new 🟢 (manually)
pip 🟢 updated 🟢 (manually) uses cmmon pip installation from bootstrap.pypa.io
printenv 🟢 actual 🟢 (manually)
printhex 🟢 updated 🟢 (manually)
ptinstaller 🟢 actual 🔴
pwd 🟢 actual 🟢 (manually)
python ❌ removed Replaced with alias to python3
python3 🟢 updated 🟢 (manually)
quicklook 🟢 actual 🟢 (manually)
rm 🟢 updated 🟢 (manually)
rmdir 🟢 actual 🟢 (manually)
scp 🟢 updated 🔴
selfupdate 🟢 actual 🟢 (manually)
sha1sum 🟢 updated 🟢 (manually/pytest)
sha256sum 🟢 updated 🟢 (manually/pytest)
sort 🟢 actual 🔴
source 🟢 actual 🔴
sqlite 🟢 actual 🔴
ssh 🟢 updated 🔴 resolved with monkeypatch
ssh-keygen 🟢 updated 🟢 (manually) resolved with monkeypatch
stashconf 🟢 actual 🟢 (manually)
tail 🟢 updated 🟢 (manually)
tar 🟢 actual 🟢 (manually)
telnet 🟢 updated 🔴 replacing telnetlib with standard-telnetlib
touch 🟢 actual 🟢 (manually)
tree 🟢 new 🟢 (manually)
umount 🟢 actual 🔴
uniq 🟢 actual 🟢 (manually)
unzip 🟢 actual 🟢 (manually)
version 🟢 updated 🟢 (manually)
wc 🟢 actual 🟢 (manually)
webviewer 🟢 actual 🟢 (manually)
wget 🟢 updated 🟢 (manually)
whatis 🟢 updated 🟢 (manually)
which 🟢 actual 🟢 (manually)
wol 🟢 actual 🔴
xargs 🟢 actual 🔴
zip 🟢 actual 🟢 (manually)

Known issues:

  • ImportError pwd not in Pythonista builtins
  • AttributeError os.system()
  • fsi require dropbox installed and it is not optional
  • bin/telnet should be reimplemented with telnetlib3 or Exscript and asyncio in future
  • It happen once in CI: FAILED tests/system/test_threads.py::ThreadsTests::test_101 - AssertionError: output not identical assert '[stash]$ sleeping ... 0\n[stash]$ sleeping ... 1\n' == '[stash]$ [stash]$ sleeping ... 0\nsleeping ... 1\n'
  • Crypto is outdated #544
  • Common pip can not build packages on installation, even if it pure-python. It allows only .whl. The possible fix for it is implementing subprocess patches for Py3
  • Common pip can't remove entry-points from ~/Documents/bin on package uninstalling, it's due to absent possibility to add --prefix path to PYTHONPATH globally, so the packages tree is not match PEP-370

@o-murphy o-murphy changed the title Refactoring, removing deprecated requirements, updating for py>=3.10 pythonista>=3.4 / py>=3.10 Refactoring, removing deprecated requirements, updating for Aug 4, 2025
@o-murphy o-murphy changed the title pythonista>=3.4 / py>=3.10 Refactoring, removing deprecated requirements, updating for pythonista>=3.4/py>=3.10: Refactoring, removing deprecated requirements, updating for Aug 4, 2025
@cclauss
Copy link
Collaborator

cclauss commented Aug 5, 2025

Please rebase on the current master branch.

@cclauss cclauss mentioned this pull request Aug 5, 2025
@o-murphy o-murphy force-pushed the master branch 2 times, most recently from 04e5e3f to c4b4aa6 Compare August 5, 2025 09:06
@o-murphy
Copy link
Contributor Author

o-murphy commented Aug 5, 2025

Please rebase on the current master branch.

Done

@cclauss
Copy link
Collaborator

cclauss commented Aug 5, 2025

Can you please pull in the changes to

  1. .github/workflows/check-code-and-run-tests.yml ("3.13") and
  2. setup.py (standard-imghdr) in

@o-murphy
Copy link
Contributor Author

o-murphy commented Aug 5, 2025

Can you please pull in the changes to

  1. .github/workflows/check-code-and-run-tests.yml ("3.13") and
  2. setup.py (standard-imghdr) in
  1. which changes do you want?
  2. standard-imghdr - is not neccesary, i already removed all deps to it, i use mimetypes instead

@cclauss
Copy link
Collaborator

cclauss commented Aug 5, 2025

Please add import sys to bin/whatis.py

Error: bin/whatis.py:23:5: F821 Undefined name sys

@cclauss
Copy link
Collaborator

cclauss commented Aug 5, 2025

Do you use the tools uv or pipx or brew?

@o-murphy o-murphy force-pushed the master branch 2 times, most recently from c47c414 to 413b0d0 Compare August 5, 2025 10:33
@o-murphy
Copy link
Contributor Author

o-murphy commented Aug 5, 2025

Do you use the tools uv or pipx or brew?

I use uv + ruff + pytest

@o-murphy
Copy link
Contributor Author

o-murphy commented Aug 5, 2025

Please add import sys to bin/whatis.py

Error: bin/whatis.py:23:5: F821 Undefined name sys

Done

@cclauss
Copy link
Collaborator

cclauss commented Aug 5, 2025

uv is awesome! In the project root directory, please run:

uv tool install pre-commit
pre-commit install
pre-commit run --all-files

@o-murphy o-murphy force-pushed the master branch 2 times, most recently from 4012739 to 6636e15 Compare August 5, 2025 10:54
@o-murphy
Copy link
Contributor Author

o-murphy commented Aug 5, 2025

@cclauss for some reason stacks on
tests/pbcopy_pbpaste/test_pbcopy_pbpaste.py::CopyPasteTests::test_pbpaste_help

but pbtest -h on pytonista works

@cclauss
Copy link
Collaborator

cclauss commented Aug 5, 2025

test_pbpaste_help passes.

I think it is getting hung up on the next file which is tests/pip/test_pip.py

EDIT: Confirmed at https://github.com/ywangd/stash/pull/524/commits

o-murphy and others added 21 commits August 19, 2025 22:16
* if no scripts found in BIN_PATH will search in `site-packages/bin`
* updated scripts matching logics, now able to find console-scripts installed with `pip` in `site-packages/bin` even with NON-`.py` extension
* check python syntax with ast.parse() for non NON-`.py` files (maybe blacklist needed)
* added `site-packages/bin` scripts completions (by checks only first 100 NON-`.py` files, to take < 1 second)
* avoid the KeyboardInterrupt error in Pythonista 3.4..3.5: fix from ywangd#499
… compatible with Pythonista 3.4 or higher.

* Removed all Python 2 patches
* Removed deprecated wheels support. StaSh now uses a standard pip approach for installing Python wheels
* The StaSh python alias has been set to python3 since Python 2 is no longer supported.
* The man page_5.txt file has been updated to reflect the end of Python 2 support.
…miko`

* Patched `time.clock()` (required by Crypto)
* Allow patch undefined attributes
* Apply patch to `bin/ssh.py`
* Apply patch to `bin/ssh-keygen.py`
httpserver.py update and fixes
diff.py update and fixes
… `pip` (#14)

pip.py update and fixes (resolving packages installation path)
* wc.py update and fixes
* сut.py update and fixes
@o-murphy
Copy link
Contributor Author

I just rebased this PR onto master
Guys I need your help with testing utils that was not yet tested.
Also I have some additional improvements for commands and tests in o-murphy#17

@o-murphy o-murphy requested a review from cclauss August 25, 2025 10:49
@sloanlance
Copy link

sloanlance commented Aug 29, 2025

I'm glad to see updates to make StaSh work with Pythonista 3.5 are progressing. I'm testing the app and I was disappointed that the latest release of StaSh didn't work with it. Then I saw your discussion in the Pythonista repo, so I thought I'd look into the PRs on this repo and I was happy to find this one. I've tried testing your StaSh updates and I have some feedback…

  1. The install command above didn't work. I had to remove some line-breaks before it would work.
  2. My main interest in StaSh is as a Git client. I had trouble using other Git apps (e.g., Working Copy) with Pythonista, so I thought using this Git client within the Pythonista sandbox would work better.
    1. I tried running git. I was prompted to download dulwich, to which I agreed. I received the following output…
      Opening: https://github.com/jsbain/dulwich/archive/ForStaSH_0.12.2.zip
      
      Save as: /Users/lsloan/Library/Containers/EA93F707-40FDurlparse87-94167EAB2298/Data/tmp//dulwich.zip (??? bytes)
      991.1KiB          
      /Users/lsloan/Library/Group Containers/group.pythonista/Pythonista3/Documents/site-packages/stash/lib/dulwich.old: does not exist
      mv: /Users/lsloan/Library/Group Containers/group.pythonista/Pythonista3/Documents/site-packages/stash/lib/dulwich: no such file or directory
      /Users/lsloan/Library/Group Containers/group.pythonista/Pythonista3/Documents/site-packages/stash/lib/dulwich.old: does not exist
      Opening: https://github.com/jsbain/gittle/archive/master.zip
      
      Save as: /Users/lsloan/Library/Containers/EA93F707-40FD-4486-AE87-94167EAB2298/Data/tmp//gittle.zip (??? bytes)
      27.7KiB          
      Opening: https://github.com/FriendCode/funky/archive/master.zip
      
      Save as: /Users/lsloan/Library/Containers/EA93F707-40FD-4486-AE87-94167EAB2298/Data/tmp//funky.zip (??? bytes)
      8.3KiB          
      stash: <class 'ModuleNotFoundError'>: No module named 'urlparse'
    2. After the error about urlparse, I tried running git again. It tried to download gittle and funky again, complained that they each already existed, then gave the same error about urlparse.

I feel encouraged that progress is being made and I'm happy to help with testing again.


[After I wrote the following, I realized it may not be directly related to this PR. I can move it to an issue if you'd like…]

I should mention a usability problem, too. I find it difficult to read the screen. Some of the dark blue text, like the welcome message and the flashing cursor, are almost invisible on the black background. The font is also rather small, too. (FWIW, I'm primarily testing on a MacBook Pro and an iPad.) When I try to select text, I can't see that it's selected, but I found that if I do it blind and copy it, the text does appear on the clipboard. I saw that easy_config.py was mentioned in some issues as a way to configure the appearance. I tried that, but I got this miniscule UI that was mostly impossible to use…

Screenshot 2025-08-29 at 10 17 48

If there's another way I could change colors and font, please tell me. Thanks in advance!

@o-murphy
Copy link
Contributor Author

o-murphy commented Sep 1, 2025

@sloanlance

  1. I guess I fixed it
  2. git is not working now cause of lots of incompatible things I did not resolved yet.
    The dulwich directly works as a cli tool, just install it with pip pip install dulwich, then run dulwich
    And actualy I don't think it should be resolved in current PR, it is already massive

P.S.: I already said I need a help with testing and porting, I'll be glad to see if someone will contribute

@fschaeck
Copy link
Collaborator

fschaeck commented Sep 1, 2025 via email

@o-murphy
Copy link
Contributor Author

o-murphy commented Sep 1, 2025

If I remember correctly, there was a pull request with a python 3 compatible git implementation. Either the pull request is still there or it might be merged into the dev branch already

This branch was never be the git implementation update. It was created to resolve incompatibility of the stash itself with the newest Pythonista and Python. This branch removes deprecated support and compatibility layer for py2 (lib2to3 and six). It fixes most of commands and core issues to make it working on py3.

For now git command not yet updated. And I have not anough time to complete git porting.

The list of updated and tested commands are in the first post in this PR discussion.

My proposal is making git command realisation not as much bounded with stash.

@cclauss
Copy link
Collaborator

cclauss commented Sep 1, 2025

@bennr01 This repo has a dev and a master branch. What is your opinion of creating a new main branch that contains this code? This would give us different branches for different audiences. Those who desperately want to cling to the long dead legacy Py2 can use dev or master while those who want to collaborate to fix real world problems can work on the main branch.

@o-murphy
Copy link
Contributor Author

o-murphy commented Sep 1, 2025

@bennr01 This repo has a dev and a master branch. What is your opinion of creating a new main branch that contains this code? This would give us different branches for different audiences. Those who desperately want to cling to the long dead legacy Py2 can use dev or master while those who want to collaborate to fix real world problems can work on the main branch.

looks like a sollution, one thing is needed is py2 guard

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants