GithubHelp home page GithubHelp logo

Comments (5)

brettcannon avatar brettcannon commented on September 26, 2024 1

Here is the solution I'm planning on unless people object.

Without PYLAUNCH_DEBUG.

❯ PY_PYTHON3=3.8.10 cargo run -- -3 --version
   Compiling python-launcher v0.16.0 (/Users/brettcannon/Repositories/brettcannon/python-launcher)
    Finished dev [unoptimized + debuginfo] target(s) in 1.84s
     Running `target/debug/py -3 --version`
Error parsing '8.10' as an integer: invalid digit found in string

With PYLAUNCH_DEBUG

❯ PY_PYTHON3=3.8.10 PYLAUNCH_DEBUG=1 cargo run -- -3 --version
    Finished dev [unoptimized + debuginfo] target(s) in 0.07s
     Running `target/debug/py -3 --version`
Checking the PY_PYTHON3 environment variable
PY_PYTHON3 = '3.8.10'
Error parsing '8.10' as an integer: invalid digit found in string

You can see the referenced PR for the planned documentation changes.

from python-launcher.

brettcannon avatar brettcannon commented on September 26, 2024

Should probably also make sure the help and man page are clear on the format.

from python-launcher.

brettcannon avatar brettcannon commented on September 26, 2024

No error in the normal case.

❯ PY_PYTHON=3.8.10 py --version
Python 3.9.5

Nothing obvious in the debug log case either:

❯ PYLAUNCH_DEBUG=1 PY_PYTHON=3.8.10 py --version
Checking for VIRTUAL_ENV environment variable
Searching for a venv in /private/tmp and parent directories
Checking /private/tmp/.venv/bin/python
Checking /private/.venv/bin/python
Checking /.venv/bin/python
Checking "--version" for a shebang
Checking for PY_PYTHON environment variable
PY_PYTHON set to 3.8.10
Checking PATH environment variable
PATH: ["/usr/local/sbin", "/Users/brettcannon/.local/bin", "/Users/brettcannon/.cargo/bin", "/usr/local/bin", "/usr/local/opt/[email protected]/bin", "/usr/local/opt/[email protected]/bin", "/usr/bin", "/bin", "/usr/sbin", "/sbin"]
Found executables: ["/usr/local/opt/[email protected]/bin/python3.8", "/usr/bin/python2.7", "/usr/local/opt/[email protected]/bin/python3.7", "/usr/local/bin/python3.9"]
Executing /usr/local/bin/python3.9 with ["--version"]

Neither --help or the man page explicitly state what the format should be.

from python-launcher.

brettcannon avatar brettcannon commented on September 26, 2024

OK, there are a couple of ways to play this. Let me know opinions.

Print a message with PYLAUNCH_DEBUG, but continue on

❯ PY_PYTHON3=3.8.10 PYLAUNCH_DEBUG=1 cargo run -- -3 --version
    Finished dev [unoptimized + debuginfo] target(s) in 0.07s
     Running `target/debug/py -3 --version`
Checking for PY_PYTHON3 environment variable
PY_PYTHON3 = '3.8.10'
'3.8.10' cannot be parsed (must be formatted as 'X.Y')
Checking PATH environment variable
PATH: ["/Users/brettcannon/.cargo/bin", "/usr/local/sbin", "/Users/brettcannon/.local/bin", "/Users/brettcannon/.cargo/bin", "/usr/local/bin", "/usr/local/opt/[email protected]/bin", "/usr/local/opt/[email protected]/bin", "/usr/bin", "/bin", "/usr/sbin", "/sbin"]
Found executables: ["/usr/local/bin/python3.9", "/usr/local/opt/[email protected]/bin/python3.8", "/usr/local/opt/[email protected]/bin/python3.7", "/usr/bin/python2.7"]
Executing /usr/local/bin/python3.9 with ["--version"]
Python 3.9.5

Print a message about the error, but continue on

❯ PY_PYTHON3=3.8.10 cargo run -- -3 --version
    Finished dev [unoptimized + debuginfo] target(s) in 0.07s
     Running `target/debug/py -3 --version`
PY_PYTHON3 cannot be parsed; must be formatted as 'X.Y', not '3.8.10'
Python 3.9.5

Error message shows up, more details with PYLAUNCH_DEBUG

I can enhance the initial error message to suggest running with PYLAUNCH_DEBUG for more details.

❯ PY_PYTHON3=3.8.10 cargo run -- -3 --version
   Compiling python-launcher v0.16.0 (/Users/brettcannon/Repositories/brettcannon/python-launcher)
    Finished dev [unoptimized + debuginfo] target(s) in 1.83s
     Running `target/debug/py -3 --version`
Error parsing a version component: invalid digit found in string

python-launcher on  main [!] is 📦 v0.16.0 via 🐍 v3.9.5 via 🦀 v1.52.1 
❯ PY_PYTHON3=3.8.10 PYLAUNCH_DEBUG=1 cargo run -- -3 --version
    Finished dev [unoptimized + debuginfo] target(s) in 0.07s
     Running `target/debug/py -3 --version`
Checking the PY_PYTHON3 environment variable
Error parsing a version component: invalid digit found in string

Error message that is custom to this situation

Not shown because I have not coded it up. 😄

from python-launcher.

treyhunner avatar treyhunner commented on September 26, 2024

I'd vote for either the second or third one because it would have been easier for me to quickly guess that the format wasn't right. 👍

I assume having an invalid PY_PYTHON variable wouldn't have any use so I see no reason not to at least note the error before continuing on.

from python-launcher.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.