Skip to content

Slightly Nicer Windows Experience - #22

Closed
jlpoltrack wants to merge 11 commits into
olliw42:mainfrom
jlpoltrack:slightly-nicer-windows
Closed

jlpoltrack wants to merge 11 commits into
olliw42:mainfrom
jlpoltrack:slightly-nicer-windows

Conversation

@jlpoltrack

Copy link
Copy Markdown
Contributor

Adds the virtualenv back with a pyinstaller exe. Benefits:

  • User only needs Python installed, all modules will be handled with the virtualenv
  • Process is all handled by an exe, no command line
  • No extra command prompts, they should only appear when flashing

@olliw42

olliw42 commented Apr 13, 2025

Copy link
Copy Markdown
Owner

I guess I am not understanding this

first off, if we require py to be isntalled, I see no benefit of an .exe ... rather to the contrary, because a user may think it's ok to just call the .exe

what is the pyinstaller doing here

as regards venv, I like using it somehow ... however I don#t like it as it is for the mac ... I think it could be possible to somehow add it into mLRSFlasher.py, so that it is setup also as part of that py, and a user just needs to run that one)
I btw looked at how Tom did it for the dronecan py and got quite puzzled why it looks there so differently (even different localtions, 'Scripts' vs 'bin') olliw42/mLRS#228

@jlpoltrack

Copy link
Copy Markdown
Contributor Author

I guess I am not understanding this

As I see it - for a user, the only steps are installing Python then running the exe - one isn't left to install all of the necessary modules or deal with .py file associations.

what is the pyinstaller doing here

It is used for the venv script and produces a 'slightly nicer' experience by:

  • dealing with all of the modules
  • not having to worry about file associations when trying to launch any .py files
  • hiding the command prompt

I would also ask that you try this to see if the user experience is how you want - with only command prompts being present when someone is actively flashing a device, would be good to confirm.

I btw looked at how Tom did it for the dronecan py and got quite puzzled why it looks there so differently (even different localtions, 'Scripts' vs 'bin') olliw42/mLRS#228

This is another OS thing - bin folder is used for Mac/Linux (Tom did on Linux), scripts is for Win.

@olliw42

olliw42 commented Apr 14, 2025

Copy link
Copy Markdown
Owner

MANY THX, looks very nice
have not had a chance yet to try but will the next days
the "archive" folder isn't needed, right? If so I'd like to have it removed (git does that for us)
few comments in the follwoing

Comment thread mLRS_Flasher.py
import apInitPassthru as appassthru
import edgetxInitPassthru as radio

'''

@olliw42 olliw42 Apr 14, 2025 •

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess I would like to have the venev section be moved to the last before the if main

Comment thread mLRS_Flasher.py
#--------------------------------------------------

if __name__ == "__main__":
if os.path.isdir("venv"):

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think a if not os.path.dir('venv') is sufficient

(btw I prefer using '' over "" when possible)

Comment thread mLRS_Flasher.py
if os.path.isdir("venv"):
print("Virtual environment found, running flasher script...")
else:
if platform.system() == 'Windows':

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we please separate that by os.name == 'posix' and then do the subselection using platform.system()

reason is that in other parts of the code it splices by os.name, want to keep it coherent

Comment thread mLRS_Flasher.py
--------------------------------------------------
'''

def setup_virtualenv_win():

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it seems to me that the three can be largely slimmed down to essentially only one
if. e.g. one would set a variable
python_exe = os.path.join('venv','Scripts','python') or python_exe = os.path.join('venv','bin','python')
and use that.
Siedeffect is that I btw also very much like using os.path.join better when possible as it really helps to avoid the / vs \ thing.
the functions could have then an argument, or you do it in that function itself

pl don't use """ or ''' for inline comments (I often use that to uncomment blocks and it just makes things screwy)

Comment thread README.md
- Run ```mLRS_Flasher.py```.

> [!NOTE]
> - The first launch will take approximately 1 minute as the virtual environment is being created.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe

  • On first launch the start can take approximately 1 minute as a virtual environment is being created and some libraries are installed (don't worry, doesn't affect your system). An internet connection is needed.

@olliw42

olliw42 commented Apr 14, 2025

Copy link
Copy Markdown
Owner

ok, thinking more over it I realize I don't understand how that would work ... have you explicitely tried it on a system with no py install at all?

(on my system it is not sufficient tp remove all py from the PATH, it somehow nevertheless finds it, might be in the regestry or so)

@jlpoltrack

Copy link
Copy Markdown
Contributor Author

ok, thinking more over it I realize I don't understand how that would work ... have you explicitely tried it on a system with no py install at all?

All of this still requires a python system install, the main job is to install all of the modules. Are you trying to understand what kind of error is generated when there is no system install?

@olliw42

olliw42 commented Apr 14, 2025

Copy link
Copy Markdown
Owner

ah, sorry, I was misleading
did you try it with a system with just a basic install (no additional pip's)?
it's not ovious to me that/how the modules in the venv are actually called/found when there is nothing in the PATH pointing at them.

@jlpoltrack

Copy link
Copy Markdown
Contributor Author

it's not ovious to me that/how the modules in the venv are actually called/found when there is nothing in the PATH pointing at them.

Yes, you're right - this can't work being part of mLRS_Flasher as this would call the system python without any of the modules, exiting immediately.

One idea is to just have a separate script for launching with all of the OSs but not sure if you want to go this path. Let me know.

@jlpoltrack jlpoltrack closed this Nov 7, 2025
@jlpoltrack
jlpoltrack deleted the slightly-nicer-windows branch November 16, 2025 15:42
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.

2 participants