corpnewt / ProperTree

Cross platform GUI plist editor written in python.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Main ProperTree running shell script (ProperTree.command) doesn't work

opened this issue · comments

When i try to open the ProperTree from the main shell script, it run for a second causes Python to crash and exit afterwards.

When i test to build the app, it built successfully and worked well

Version is 0.2.9 with Python 2.7.18 on macOS Monterey 12.7.4

It looks like it's actually trying to load python 3.9 that comes with Xcode - which has a known-to-be-broken tkinter implementation. The ProperTree.command file attempts to locate all installed versions of py and then picks the highest version number and pipes ProperTree.py to that - so it makes sense that it would choose that over pythyon 2.7.18 as 3.9 is newer.

If you want it to only ever use a specific build of python (i.e. 2.7.18), you'll need to either build the .app targeting that specific python version - or set up your own .command starter that pipes ProperTree.py to whichever python version you want it to use.

-CorpNewt

OK, then is there a way you can commit to list all available versions of Python installed and let the user to choose which one (like when building the app) ?

What you can do is rename ProperTree.py to ProperTree.command, and ensure the shebang points to whatever python version you want to start it (that's how the buildapp-select.command script does it).

ProperTree.py has a holdover shebang that gets python from the user's env. It currently looks like:

#!/usr/bin/env python

If you replace that /usr/bin/env python with the full path to whatever python version you want, and keep the #! prefix, it should work as expected.

OK, gimme a moment...

I can not commit to the repo.
So please add this line to "get_local_python_version()" method in the main script (ProperTree.command):

if [ -z "$py_name" ]; then py_name="python3" else py_name="python2" fi

and remove the old code that looks like below:

if [ -z "$py_name" ]; then py_name="python3" fi

An it should work correctly.

Also try running it before committing to the repo.

Just apply the solution above without changing anything else, and it should work.

This is a change that specifically affects your setup - but the way I have it written in the repo is currently how I would like to keep it unless there's a global reason to do otherwise. In the vast majority of cases, if there are multiple python versions installed, it makes sense to use the latest.

You are certainly welcome to make those changes on your machine locally, or to maintain your own fork that contains them if you like though.

OK.

Thank you a lot, @corpnewt

Not a problem - please reach out if you find other issues!

I reopened the issue to let the users know how to fix this issue if they found it.

And also because this issue has not been really fixed yet.

Well, ProperTree.command is doing what it was designed to do - so I don't think it makes sense to keep this issue open, as it's not an issue with the script, but more of an exception for a specific use-case. The buildapp-select.command script is intended to be the solution, as it allows you to customize the shebang in a packaged .app to target a specific python build - and writing code for the .command to do the same seems redundant.

As mentioned before, it's not something I plan to implement - so I'll leave this issue closed unless there's a global reason to change the behavior of the .command starter.

OK, as you want, @corpnewt

And thank you for your help on that issue ( #178 )
And this also ( #179 ).

I forgot that I added the ability to restrict which python versions are checked within the .command starter. If you look at lines 10-14:

# use_py3:
#   TRUE  = Use if found, use py2 otherwise
#   FALSE = Use py2
#   FORCE = Use py3
use_py3="TRUE"

You can change use_py3="TRUE" to use_py3="FALSE" to force it to use python 2. It still requires a file edit to accomplish that - but it's cleaner than overriding an existing method. Also - if you don't absolutely need to use python 2, you can either install the latest python 3 from here, or pass --install-python to ProperTree.command to have it download and install it for you - then it will prioritize that over python 2 and the python 3.9 from Xcode.

Hopefully that gives you some more options to consider.

-CorpNewt

I can not commit to the repo. So please add this line to "get_local_python_version()" method in the main script (ProperTree.command):

if [ -z "$py_name" ]; then py_name="python3" else py_name="python2" fi

and remove the old code that looks like below:

if [ -z "$py_name" ]; then py_name="python3" fi

An it should work correctly.

Also try running it before committing to the repo.

OK, and my solution is also works for me.

Ah, i almost forgot, you can also replace the value of py_name in that solution with 'python' only without any numbers, and it should also works.

Thanks a lot, @corpnewt

I stuck at this old version of python2 (2.7.18) because i use some old stuff, which is hard to convert them to python3 (and also because that version is the latest of python2).

So i would prefer if the ProperTree.command script lists the available versions of python and let me choose one of them (just like the buildapp-select.command script does)

Ah - gotcha. Yeah, adding extra steps before running the script doesn't make sense for the vast majority of users, so I still won't be changing the code there. If the ProperTree.app built with buildapp-select.command works fine for what you need, you may have the best luck just using that. Alternatively you can make the use_py3="FALSE" edit on your end - but as it doesn't make sense for everyone else to prompt for the py version or force py2, I'll leave the code in the repo as-is.

-CorpNewt

I can not commit to the repo. So please add this line to "get_local_python_version()" method in the main script (ProperTree.command):

if [ -z "$py_name" ]; then py_name="python3" else py_name="python2" fi

and remove the old code that looks like below:

if [ -z "$py_name" ]; then py_name="python3" fi

An it should work correctly.

Also try running it before committing to the repo.

OK, thank you a lot, @corpnewt

For my case, any solution of the above ones worked for me (building an app, my solution in the mentioned comment, your solution mentioned above (use_py3="FALSE"), all works well)

I prefer building the app, put it in the Apps folder and forget it.

Thanks again...