-
-
Notifications
You must be signed in to change notification settings - Fork 244
argv[0] is None #307
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I have the same problem. I'll see if I can come up with a minimal example. @nnovikov would you please post your |
You can see pyoxidizer.bzl here: |
Using what @nnovikov posted, I've got a minimal working and non-working examples below. The critical thing seems to be the use of the Aside: specification of
|
Thank you for the detailed reports and investigation, @nnovikov and @wkschwartz! I haven't yet looked at this in detail, but as of PyOxidizer 0.9, the run-time code should only be calling into the Python C APIs for running a {code, module, file}. So any behavior here is likely the behavior of CPython. What could be in play is that unless you set the Python interpreter config profile to Something else at play is |
I think pyoxidizer should copy own argv[0] to CPython argv[0] if possible. Also create a parameter to change this behavior. |
Response to @nnovikov
Is there any reason "pyoxidizer['s] own argv[0]" would differ from Response to @indygreg
I'm guessing that line 620 in the preview below is the key line? PyOxidizer/pyembed/src/interpreter.rs Lines 618 to 620 in fea0562
If so, then I think that confirms the "Diagnosis" section in #307 (comment)
That's not the case. The config values don't affect how @@ -1,6 +1,7 @@
python_config = dist.make_python_interpreter_config()
+ python_config.config_profile = "python"
python_config.run_mode = 'module:foo'
In the case of
The rules are documented in Interface Options. Here's a short version. In a normal Python executable, there are 5 ways of starting the interpreter, each with its own
Here is where I think you get control over this situation: ProposalWhen AlternativeIf you don't like that plan, you can monkey patch |
Come to think of it, maybe this ticket represents a bug in the Python library specification. We already know that a module's Does this warrant a ticket on bpo? UPDATE: |
I created bpo-42315 for this. I still think a PyOxidizer-specific workaround is warranted in the meantime. I might be able to help if I get some pointers about where the relevant code/tests/docs would go. |
Just wanted to chime in -- this seems to be the cause of a problem that is preventing a small project of mine from building with 0.10.3, which interesting was building fine on 0.6 and 0.7. The error I'm seeing, to hopefully lead future searchers this way, is when running
It looks like argparse relies on sys.argv if I think this will be a common issue for CLI apps, which often use argparse, and will often rely on the default behavior to populate the progname. |
The problem with $ terminalvelocity.exe badargs
Usage: terminalvelocity.cli [-h] goodargs
Unknown argument for terminalvelocity.cli: "badargs"
$ terminalvelocity.cli goodargs
Unknown command: "terminalvelocity.cli" I would recommend instead, as I did in #307 (comment), to use |
Huh. I guess that's fair if EDIT: On second look, you're correct -- using $ python -m terminalvelocity -h
usage: terminalvelocity [-h] [-c CONFIG] [-e EDITOR] [-x EXTENSION] [--extensions EXTENSIONS]
[--exclude EXCLUDE] [-d] [-l LOG_FILE] [-p]
[notes_dir]
A fast note-taking app for the UNIX terminal $ tv -h
usage: terminalvelocity [-h] [-c CONFIG] [-e EDITOR] [-x EXTENSION] [--extensions EXTENSIONS]
[--exclude EXCLUDE] [-d] [-l LOG_FILE] [-p]
[notes_dir]
A fast note-taking app for the UNIX terminal Using the $ python -m terminalvelocity -h
usage: /Users/me/git/terminalvelocity/.venv/bin/python [-h] [-c CONFIG] [-e EDITOR] [-x EXTENSION]
[--extensions EXTENSIONS] [--exclude EXCLUDE] [-d]
[-l LOG_FILE] [-p]
[notes_dir]
A fast note-taking app for the UNIX terminal $ tv -h
usage: /Users/me/git/terminalvelocity/.venv/bin/python [-h] [-c CONFIG] [-e EDITOR] [-x EXTENSION]
[--extensions EXTENSIONS] [--exclude EXCLUDE] [-d]
[-l LOG_FILE] [-p]
[notes_dir]
A fast note-taking app for the UNIX terminal |
Sorry, I was referring specifically to using |
There were 2 problems: - pyyaml cannot be included It has been removed from requirements.txt and pip install is called with the --no-deps option, which installs everything else. pyyaml is not required anyway - indygreg/PyOxidizer#307 which is solved by using the python_config.run_filename option instead of python_config.run_module
I am using |
@indygreg I am thinking of an alternative way of solving this issue:
Step 1 is simple. Can you help with step 2, please. Have gone through the entire pyoxidizer documentation and unable to find a start. Hope you can help. @wkschwartz @n8henrie. Any pointers will be great. Thanks |
Same here. Is there any update on this? |
I think this comes down ultimately to an ambiguity in Python's specification: |
I have problem with pyoxidizer 0.9.0 and sys.argv. I make simple test app (via pyoxidizer init-config-file pyapp)
and run it with parameters
As you can see, first element in argv is None.
May be I need some config options for pyoxidizer.bzl?
The text was updated successfully, but these errors were encountered: