Dyalog / pynapl

Dyalog APL ←→ Python interface
MIT License
76 stars 12 forks source link

Installing as administrator and running as regular user raises `PermissionError`. #13

Open rodrigogiraoserrao opened 3 years ago

rodrigogiraoserrao commented 3 years ago

After using setup.py to install pynapl, with administrator permissions, in a Windows 10 system, pynapl is installed in the standard location for Python modules, in a “protected” folder.

Hence, when a regular user tries to start pynapl, it fails, because Python will try to write the WinPort.dyalog file in a protected location.

Here's the traceback we get after a script tries to import pynapl and run the APL function in APL.py:

  File "C:\Users\rodri\Documents\Dyalog\pynapl\pynapl\demos\game_of_life\game_of_life.py", line 5, in <module>
    apl = APL.APL()
  File "C:\Program Files\Python39\lib\site-packages\py_n_apl-0.1.0-py3.9.egg\pynapl\APL.py", line 29, in APL
    return APLPyConnect.Connection.APLClient(DEBUG=debug, dyalog=dyalog, forceTCP=forceTCP)
  File "C:\Program Files\Python39\lib\site-packages\py_n_apl-0.1.0-py3.9.egg\pynapl\APLPyConnect.py", line 437, in APLClient
    if not DEBUG: RunDyalog.dystart(outarg, inarg, dyalog=dyalog)
  File "C:\Program Files\Python39\lib\site-packages\py_n_apl-0.1.0-py3.9.egg\pynapl\RunDyalog.py", line 175, in dystart
    with open(to_bytes(os.path.dirname(SCRIPTFILE))+b'/WinPort.dyalog', "wb") as f:
PermissionError: [Errno 13] Permission denied: b'C:\\Program Files\\Python39\\Lib\\site-packages\\Py_n_APL-0.1.0-py3.9.egg\\pynapl/WinPort.dyalog'
rodrigogiraoserrao commented 3 years ago

The original code comments that using the auxiliary WinPort.dyalog file ”is dumb, but works, but is still dumb”.

Either try to write the WinPort.dyalog file in a location appropriate for temp files, or try to remove this “hack” altogether (no idea how!).