question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Request for `PIPENV_ONLY_USE_PYENV` environment variable.

See original GitHub issue

Is your feature request related to a problem? Please describe.

We are using a combination of linuxbrew, pipenv and pyenv on our linux agents in our CI system. Unfortunately due to reasons, homebrew removed all installation options. This means that on Linux, all Pythons installed with brew do not have Tkinter support enabled.

It’s an issue because, depending on what version is requested by the devs, they may or may not get a working Python and since brew usually has the most up to date releases, these are often the ones requested. This could be (and probably will be) worked around with much difficulty by creating our own Python formula on our own brew tap.

Describe the solution you’d like

I would love another environment variable that would force pipenv to only use pythons provided by pyenv. This would help make our CI system far more deterministic and predictable. Basically the opposite to PIPENV_DONT_USE_PYENV, maybe PIPENV_ONLY_USE_PYENV.

I could also see it being beneficial to those working on an older system like CentOS 6 who might only specify python 2 in their Pipfile. Currently the behaviour would be to use the system python (which I believe is 2.6) but I think most developers who write that in their Pipfile are working around the lack of version specifiers available for the Python version and mostly just want to use one of the most recent versions of Python 2.

Describe alternatives you’ve considered

For our particular CI system, we have resorted to refusing to allow many of our Python applications to be tested on our Linux agents. As mentioned above, we are considering creating our own Python formula with tk support hard coded.

Another option could be to provide a blacklist of Python executables that will not be considered available to pipenv like PIPENV_EXCLUDE_PYTHONS=/home/linuxbrew/.linuxbrew/bin/python:/home/linuxbrew/.linuxbrew/bin/python2:/home/linuxbrew/.linuxbrew/bin/python3.

Potentially this could also be a list of directories where any python executable found in within is removed from the list of available Python installations.

Additional context

We have everything working on our Mac agents since they have indeed hard coded tk support into the brew formula but it would still be nice to be able to say for sure that all Pythons available to pipenv in our CI system were created with pyenv.

This has been tested on both Ubuntu (18.04) and CentOS (7) but after looking at the linuxbrew python formula, it should be true of all linuxbrew installations.


$ pipenv --support

Pipenv version: '2018.11.26'

Pipenv location: '/home/linuxbrew/.linuxbrew/Cellar/pipenv/2018.11.26_2/libexec/lib/python3.7/site-packages/pipenv'

Python location: '/home/linuxbrew/.linuxbrew/Cellar/pipenv/2018.11.26_2/libexec/bin/python3.7'

Python installations found:

  • 3.6.7: /usr/bin/python3.6m
  • 3.6.7: /usr/bin/python3.6
  • 2.7.15: /usr/bin/python

PEP 508 Information:

{'implementation_name': 'cpython',
 'implementation_version': '3.7.4',
 'os_name': 'posix',
 'platform_machine': 'x86_64',
 'platform_python_implementation': 'CPython',
 'platform_release': '4.15.0-54-generic',
 'platform_system': 'Linux',
 'platform_version': '#58-Ubuntu SMP Mon Jun 24 10:55:24 UTC 2019',
 'python_full_version': '3.7.4',
 'python_version': '3.7',
 'sys_platform': 'linux'}

System environment variables:

  • PATH
  • PIPENV_VENV_IN_PROJECT
  • LS_COLORS
  • SSH_CONNECTION
  • LESSCLOSE
  • _
  • LANG
  • PYENV_ROOT
  • PIPENV_MAX_DEPTH
  • XDG_SESSION_ID
  • USER
  • PWD
  • HOME
  • SSH_CLIENT
  • XDG_DATA_DIRS
  • PIPENV_YES
  • PIPENV_NOSPIN
  • HOMEBREW_REPOSITORY
  • SSH_TTY
  • MAIL
  • SHELL
  • TERM
  • SHLVL
  • PYENV_SHELL
  • HOMEBREW_PREFIX
  • MANPATH
  • LOGNAME
  • XDG_RUNTIME_DIR
  • PIPENV_COLORBLIND
  • HOMEBREW_CELLAR
  • INFOPATH
  • LESSOPEN
  • PIP_DISABLE_PIP_VERSION_CHECK
  • PYTHONDONTWRITEBYTECODE
  • PIP_SHIMS_BASE_MODULE
  • PIP_PYTHON_PATH
  • PYTHONFINDER_IGNORE_UNSUPPORTED

Pipenv–specific environment variables:

  • PIPENV_VENV_IN_PROJECT: 1
  • PIPENV_MAX_DEPTH: 5
  • PIPENV_YES: 1
  • PIPENV_NOSPIN: 1
  • PIPENV_COLORBLIND: 1

Debug–specific environment variables:

  • PATH: /home/linuxbrew/.linuxbrew/Cellar/pipenv/2018.11.26_2/libexec/tools:/home/REDACTED/.pyenv/shims:/home/linuxbrew/.linuxbrew/bin:/home/linuxbrew/.linuxbrew/sbin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
  • SHELL: /bin/bash
  • LANG: en_US.UTF-8
  • PWD: /home/REDACTED

Issue Analytics

  • State:open
  • Created 4 years ago
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

3reactions
BrennanGitcommented, Sep 2, 2019

Hi guys, just hoping maybe you could change the label from “question” to “enhancement” so this doesn’t get lost. Once I have a little more time, I’d be happy to implement this myself and do a PR.

I’d just like to check that this is functionality that is understood and wanted by anyone other than myself.

0reactions
matteiuscommented, Sep 12, 2022

I’d prefer if the environment variable were called PIPENV_PYENV_ONLY or something less verbose than PIPENV_ONLY_USE_PYENV. Also what if someone wants to only use asdf (I’ve never used this)? Maybe something more thoughtful to different modes for searching for Python, since there are still a number of issue reports about python finding logic floating around. Just some thoughts as I comb through the backlog again.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Advanced Usage of Pipenv - Read the Docs
Pipenv will expand environment variables (if defined) in your Pipfile. Quite useful if you need to authenticate to a private PyPI:.
Read more >
Is it possible to use environment variables from “.env” in ...
It's not clear from the documentation but from testing it appears .env is only read during pipenv run and pipenv shell .
Read more >
Cannot use environment variables defined in . ...
I want to use environment variables defined in .env in pipenv run and scripts in Pipfile . For example, when FOO=SPAM is in...
Read more >
pipenv Documentation
Pipenv uses a set of commands to manage your Project's dependencies and custom scripts. ... just check the PIPENV_SHELL environment variable, which $...
Read more >
pipenv Documentation
Use pip to install Pipenv: $ pip install --user pipenv NOTE: This does a user installation to prevent breaking any system-wide packages. If...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found