Skip to content
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

Print all env vars in pipx environment #1073

Merged
merged 1 commit into from
Oct 6, 2023
Merged

Print all env vars in pipx environment #1073

merged 1 commit into from
Oct 6, 2023

Conversation

TomiBelan
Copy link
Contributor

  • I have added an entry to docs/changelog.md

Summary of changes

  • Add PIPX_DEFAULT_PYTHON and USE_EMOJI to pipx environment
  • Print both original environment and pipx computed values
  • Remove "Only PIPX_HOME and PIPX_BIN_DIR can be set by users in the above list." (not true)

Test plan

Tested by running

$ pipx environment
Environment variables (set by user):

PIPX_HOME=
PIPX_BIN_DIR=
PIPX_SHARED_LIBS=
PIPX_DEFAULT_PYTHON=
USE_EMOJI=

Derived values (computed by pipx):

PIPX_HOME=/home/user/.local/share/pipx
PIPX_BIN_DIR=/home/user/.local/bin
PIPX_SHARED_LIBS=/home/user/.local/share/pipx/shared
PIPX_LOCAL_VENVS=/home/user/.local/share/pipx/venvs
PIPX_LOG_DIR=/home/user/.local/state/pipx/log
PIPX_TRASH_DIR=/home/user/.local/share/pipx/trash
PIPX_VENV_CACHEDIR=/home/user/.cache/pipx
PIPX_DEFAULT_PYTHON=/usr/bin/python3
USE_EMOJI=true
$ PIPX_HOME=~/otherhome pipx environment
Environment variables (set by user):

PIPX_HOME=/home/user/otherhome
PIPX_BIN_DIR=
PIPX_SHARED_LIBS=
PIPX_DEFAULT_PYTHON=
USE_EMOJI=

Derived values (computed by pipx):

PIPX_HOME=/home/user/otherhome
PIPX_BIN_DIR=/home/user/.local/bin
PIPX_SHARED_LIBS=/home/user/otherhome/shared
PIPX_LOCAL_VENVS=/home/user/otherhome/venvs
PIPX_LOG_DIR=/home/user/otherhome/logs
PIPX_TRASH_DIR=/home/user/otherhome/.trash
PIPX_VENV_CACHEDIR=/home/user/otherhome/.cache
PIPX_DEFAULT_PYTHON=/usr/bin/python3
USE_EMOJI=true
$ USE_EMOJI=n pipx environment
Environment variables (set by user):

PIPX_HOME=
PIPX_BIN_DIR=
PIPX_SHARED_LIBS=
PIPX_DEFAULT_PYTHON=
USE_EMOJI=n

Derived values (computed by pipx):

PIPX_HOME=/home/user/.local/share/pipx
PIPX_BIN_DIR=/home/user/.local/bin
PIPX_SHARED_LIBS=/home/user/.local/share/pipx/shared
PIPX_LOCAL_VENVS=/home/user/.local/share/pipx/venvs
PIPX_LOG_DIR=/home/user/.local/state/pipx/log
PIPX_TRASH_DIR=/home/user/.local/share/pipx/trash
PIPX_VENV_CACHEDIR=/home/user/.cache/pipx
PIPX_DEFAULT_PYTHON=/usr/bin/python3
USE_EMOJI=false
$ PIPX_DEFAULT_PYTHON=python3.11 pipx environment
Environment variables (set by user):

PIPX_HOME=
PIPX_BIN_DIR=
PIPX_SHARED_LIBS=
PIPX_DEFAULT_PYTHON=python3.11
USE_EMOJI=

Derived values (computed by pipx):

PIPX_HOME=/home/user/.local/share/pipx
PIPX_BIN_DIR=/home/user/.local/bin
PIPX_SHARED_LIBS=/home/user/.local/share/pipx/shared
PIPX_LOCAL_VENVS=/home/user/.local/share/pipx/venvs
PIPX_LOG_DIR=/home/user/.local/state/pipx/log
PIPX_TRASH_DIR=/home/user/.local/share/pipx/trash
PIPX_VENV_CACHEDIR=/home/user/.cache/pipx
PIPX_DEFAULT_PYTHON=/usr/bin/python3.11
USE_EMOJI=true
$ PIPX_DEFAULT_PYTHON=foo pipx environment
Traceback (most recent call last):
  File "/home/user/.local/bin/pipx", line 5, in <module>
    from pipx.main import cli
  File "/home/user/.local/lib/python3.11/site-packages/pipx/main.py", line 23, in <module>
    from pipx import commands, constants
  File "/home/user/.local/lib/python3.11/site-packages/pipx/commands/__init__.py", line 2, in <module>
    from pipx.commands.environment import environment
  File "/home/user/.local/lib/python3.11/site-packages/pipx/commands/environment.py", line 15, in <module>
    from pipx.interpreter import DEFAULT_PYTHON
  File "/home/user/.local/lib/python3.11/site-packages/pipx/interpreter.py", line 87, in <module>
    DEFAULT_PYTHON = _get_absolute_python_interpreter(env_default_python)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/.local/lib/python3.11/site-packages/pipx/interpreter.py", line 78, in _get_absolute_python_interpreter
    raise PipxError(f"Default python interpreter '{env_python}' is invalid.")
pipx.util.PipxError: Default python interpreter 'foo' is invalid.

src/pipx/main.py Outdated Show resolved Hide resolved
@dukecat0 dukecat0 merged commit b489691 into pypa:main Oct 6, 2023
11 checks passed
@dukecat0
Copy link
Member

dukecat0 commented Oct 6, 2023

Thanks!

@TomiBelan TomiBelan deleted the fullenvironment branch October 6, 2023 10:40
@TomiBelan
Copy link
Contributor Author

Thanks for your review!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants