{"action":"created","issue":{"url":"https://api.github.com/repos/Nuitka/Nuitka/issues/149","repository_url":"https://api.github.com/repos/Nuitka/Nuitka","labels_url":"https://api.github.com/repos/Nuitka/Nuitka/issues/149/labels{/name}","comments_url":"https://api.github.com/repos/Nuitka/Nuitka/issues/149/comments","events_url":"https://api.github.com/repos/Nuitka/Nuitka/issues/149/events","html_url":"https://github.com/Nuitka/Nuitka/issues/149","id":363158895,"node_id":"MDU6SXNzdWUzNjMxNTg4OTU=","number":149,"title":"How to modify the environment of script compiled in non-standalone mode?","user":{"login":"brupelo","id":18058492,"node_id":"MDQ6VXNlcjE4MDU4NDky","avatar_url":"https://avatars3.githubusercontent.com/u/18058492?v=4","gravatar_id":"","url":"https://api.github.com/users/brupelo","html_url":"https://github.com/brupelo","followers_url":"https://api.github.com/users/brupelo/followers","following_url":"https://api.github.com/users/brupelo/following{/other_user}","gists_url":"https://api.github.com/users/brupelo/gists{/gist_id}","starred_url":"https://api.github.com/users/brupelo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/brupelo/subscriptions","organizations_url":"https://api.github.com/users/brupelo/orgs","repos_url":"https://api.github.com/users/brupelo/repos","events_url":"https://api.github.com/users/brupelo/events{/privacy}","received_events_url":"https://api.github.com/users/brupelo/received_events","type":"User","site_admin":false},"labels":[{"id":37041251,"node_id":"MDU6TGFiZWwzNzA0MTI1MQ==","url":"https://api.github.com/repos/Nuitka/Nuitka/labels/enhancement","name":"enhancement","color":"84b6eb","default":true},{"id":722438254,"node_id":"MDU6TGFiZWw3MjI0MzgyNTQ=","url":"https://api.github.com/repos/Nuitka/Nuitka/labels/help%20wanted","name":"help wanted","color":"b1e059","default":true},{"id":929687529,"node_id":"MDU6TGFiZWw5Mjk2ODc1Mjk=","url":"https://api.github.com/repos/Nuitka/Nuitka/labels/needs_example","name":"needs_example","color":"94bbe0","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2018-09-24T13:58:40Z","updated_at":"2018-09-25T06:45:34Z","closed_at":null,"author_association":"CONTRIBUTOR","body":"Hi,\r\n\r\nExperiment: Consider this little [hello world example](https://www.dropbox.com/s/0fvnzacb8grvrpr/hello_world.7z?dl=1). If you uncompress and run `x.bat` you'll see how `x.exe` will run ok. That example is using embedded python with `x.py` compiled in non-standalone mode.\r\n\r\n`x.py`:\r\n\r\n    import os\r\n\r\n    os.environ[\"PATH\"] = f\"python;{os.environ['path']}\"\r\n    os.environ[\"PYTHONPATH\"] = f\"python\"\r\n    print('-'*80)\r\n    print(os.environ[\"PATH\"])\r\n    print(os.environ[\"PYTHONPATH\"])\r\n    print('-'*80)\r\n    print('hello world')\r\n\r\n    import encodings\r\n\r\n    print(encodings)\r\n\r\nGoal: I'm trying to figure out how to run `x.exe` without relying on any batch file though. As you can see, I've already tried modifying the environment from `x.py` itself but that won't work... so my question would be, is there any way to modify `x.exe` environment without using any additional batch files? It'd be great if there was any, by doing so I'd be able to have a final tidy package with all my external libraries living on their own folders, embedded python living on their own, etc...\r\n\r\nIf anyone knows a proper way to improve this little experiement please let me know.\r\n\r\nPs. I've googled quite a lot about this stuff but haven't found any satisfactory solution so far.\r\n\r\nThanks in advance.\r\nBruno."},"comment":{"url":"https://api.github.com/repos/Nuitka/Nuitka/issues/comments/424225972","html_url":"https://github.com/Nuitka/Nuitka/issues/149#issuecomment-424225972","issue_url":"https://api.github.com/repos/Nuitka/Nuitka/issues/149","id":424225972,"node_id":"MDEyOklzc3VlQ29tbWVudDQyNDIyNTk3Mg==","user":{"login":"kayhayen","id":4226920,"node_id":"MDQ6VXNlcjQyMjY5MjA=","avatar_url":"https://avatars1.githubusercontent.com/u/4226920?v=4","gravatar_id":"","url":"https://api.github.com/users/kayhayen","html_url":"https://github.com/kayhayen","followers_url":"https://api.github.com/users/kayhayen/followers","following_url":"https://api.github.com/users/kayhayen/following{/other_user}","gists_url":"https://api.github.com/users/kayhayen/gists{/gist_id}","starred_url":"https://api.github.com/users/kayhayen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kayhayen/subscriptions","organizations_url":"https://api.github.com/users/kayhayen/orgs","repos_url":"https://api.github.com/users/kayhayen/repos","events_url":"https://api.github.com/users/kayhayen/events{/privacy}","received_events_url":"https://api.github.com/users/kayhayen/received_events","type":"User","site_admin":false},"created_at":"2018-09-25T06:45:34Z","updated_at":"2018-09-25T06:45:34Z","author_association":"COLLABORATOR","body":"So are you trying to re-invent minimal standalone Python distributions?\r\n\r\nThere are a few like those already, MiniConda somes to mind now, but I recall seeing a presentation from people who had one like that for at least Linux alikes. I think CPython might be a relatively bad choice for these things.\r\n\r\nAs for linking against CPython, I totally dislike what's going on for Windows there. For accelerated and standalone binaries on other platforms, I can specifify \"rpath\" and make the binary load from binary relative paths any DLL that I want to. On Windows, only binary directory will work in my probing.\r\n\r\nUsing the \".LIB\" of Python is to blame mostly there, because it immediately loads the DLL from well, the configured spots. I don't think the \".bat\" can influence that. Maybe manifests embedded in a binary could, but I believe that has limitations too, like absolute paths, and it's cumbersome to learn all that just to find it not working, although I partially tried and failed.\r\n\r\nHaving our own \".LIB\" and loading CPython DLL dynamically would totally solve the issue. A binary once running can change its load paths. It could add what I am thinking of the rpath at run time in C code, rather than through the linker. Not sure what it means for ultimate performance, but it annoys the hell of of me, that for uninstalled Python I need to copy the Python.DLL along the binary to it to work."}}
{"actor":{"display_login":"kayhayen"}}