Comments (5)
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.
Should probably also make sure the help and man page are clear on the format.
from python-launcher.
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.
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.
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)
- Document the release process
- Add a FAQ entry about how to turn off `.venv` usage HOT 1
- No configurations support (or undocumentd) aka py.ini
- Manpage wording around `--list` and virtual environments confusing HOT 6
- Manpage typos HOT 3
- Local virtualenv not found on WSL2 HOT 2
- Support PEP 723 HOT 1
- Update `docs/requirements.txt`
- Add Repology badge to website
- Update installation instructions for NixOS package HOT 1
- Docs point to mousebender HOT 1
- Clarify how interpreters are found on PATH HOT 1
- Fix Clippy warning about dead code
- tag a new release? HOT 6
- Add a justfile recipe for running cog on `docs/install.md`
- Update `docs-venv` justfile recipe to delete any preexisting virtual environment
- Drop use of `actions-rs` actions
- Typo in FAQ
- Check cargo-wizard for optimizations
- Add artifact attestation to release process
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from python-launcher.