takluyver / pynsist

Build Windows installers for Python applications
https://pynsist.readthedocs.io/
Other
883 stars 119 forks source link

setting PATH requires admin level #167

Closed gsemet closed 5 years ago

gsemet commented 5 years ago

Hi.

I have a cli that I would like to add to the PATH in PyNSIST (using console=True), but it cannot do it in the installation process. It kind of fail setting the PATH in the registry key, and simply ignore the error. It is possible to modify the PATH manually afterward, but would be cool if the installer, when run in user mode (non-admin), would patch the user's PATH instead of the system's PATH.

Thx!

takluyver commented 5 years ago

It looks like the code to do this in _system_path.py has parameters allusers=True to modify PATH for the user or the whole system, but it's always used in system mode. Do you want to make a pull request? To keep the command-line parsing simple, I'd just split the add option to something like add-system and add-user.

gsemet commented 5 years ago

And this would be exposed in the configuration file? Not sure to see how you want to handle this?

takluyver commented 5 years ago

The installers created can already do a per-user install if the user chooses (or if they don't have admin access). It would have to choose the script's behaviour based on that. So it doesn't know until the installer is run.

Here's an example of how to check in the installer which mode it's being run in:

https://github.com/takluyver/pynsist/blob/cb11b502758fde5765588781233d12ad00f25279/nsist/pyapp.nsi#L66

gsemet commented 5 years ago

is there a feature to ask the user if he wishes an single user install or or multi user (ex: like python installer, where the multi user checkbox is grayed if the installer is not run as an super-super)?

takluyver commented 5 years ago

Yes, if the user has permission to install for all users, they should see a page in the installer asking whether they want to do that. Pynsist uses the MultiUser.nsh header file, documented here:

http://nsis.sourceforge.net/Docs/MultiUser/Readme.html

takluyver commented 5 years ago

Can you test pull request #170? I've left notes there on how to test it.

gsemet commented 5 years ago

Thanks for your PR. I didn't has time to test it. I will try to do it !

takluyver commented 5 years ago

Thanks! The PR is merged and released now (as Pynsist 2.3), so it should be easy to test.