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

pyenv integration #141

Open
jamesstidard opened this issue Apr 11, 2018 · 8 comments
Open

pyenv integration #141

jamesstidard opened this issue Apr 11, 2018 · 8 comments

Comments

@jamesstidard
Copy link

I currently use pyenv and pipenv on my machine to manage python versions and package dependencies - I assume people that use pipsi are quite likely to do the same. I feel like it would be nice to build the virtual environment for installed packages using pipenv - if it's present on the system.

pipenv already has an integration with pyenv where it'll download the python interpreter via pyenv, if it's not already. Currently you can specify a specific python interpreter with --python, but before this you need to:

  1. Check on the application you're installing which versions of python it supports from it's setup.py/Pipfile/pypi listing
  2. Download one of those versions in pyenv
  3. Set that as the global python or hand it's path as the --python argument

I think by using pipenv to create the virtual environment on install and update pipsi could remove those steps as well as automatically upgrade python interpreters for each application as a package owner depreciates them.

Would there be anything inherently sinful about this feature? I'm happy to have a go at implementing this if this seems like a feature pipsi would benefit from.

@digitalresistor
Copy link

Doesn't pipenv suggest the use of pipsi to do its installation? Isn't that a bit like a chicken and egg problem?

Also pipenv is all for developers and managing dependencies, whereas pipsi is about installing a tool and making it available in a stable bin path with managed virtualenvs. You don't need 90% of what pipenv provides in pipsi.

@jamesstidard
Copy link
Author

@bertjwregeer that's a good point. Now you mention it, I think I got carried away getting to pipenv. It would really only be a pyenv integration that would be needed to do what I was after - selecting/installing the right interpreter for the tool and making the virtual environment as normal.

Does that sound a little more sensible?

@jamesstidard jamesstidard changed the title pipenv integration pyenv integration Apr 11, 2018
@Code0x58
Copy link

I just came across this thinking that I'd be able to type/think less in the future if pipsi realised that I don't have a python that matches the requirements of black (3.6) so went ahead and installed/used on in the virtualenv it made for it. Maybe I should just use containers for everting 🤔

@gwerbin
Copy link

gwerbin commented Jul 19, 2018

@bertjwregeer @jamesstidard I don't think it's a chicken/egg problem.

  1. Install some version of Python system-wide using your system package manager
  2. Bootstrap-install Pipsi under the system Python (ideally also using your system package manager)
  3. Install Pyenv using your system package manager
  4. Install Pipenv using your system package manager
  5. Use Pipsi to install additional system-wide packages, making use of Pipenv
  6. Use Pipenv to manually create environments for projects
  7. rm -rf ~/.anaconda3

I personally think Pyenv, Pipsi, and Pipenv serve different purposes and should be installed as "siblings". One manages Python installations, another is a secondary package manager for system-wide Python applications, and the third is a virtual environment manager. All three are "top-level" in my mind, just below the system package manager in terms of management authority.

@RonnyPfannschmidt
Copy link
Contributor

pyenv integration is tricky - it needs support in both the package and the installer + a new release - im not familiar with pyenv myself and dont use it

@gwerbin
Copy link

gwerbin commented Jul 19, 2018

it needs support in both the package and the installer + a new release

@RonnyPfannschmidt what do you mean by that?

Currently you have:

pipsi/pipsi/__init__.py

Lines 310 to 316 in 16b6820

if isinstance(python, int):
python_exe = 'python{}'.format(python)
python = distutils.spawn.find_executable(python_exe)
if not python:
raise ValueError('Can not find {} in PATH'.format(python_exe))
if not python:
python = sys.executable

In this case you would change it to something like

if isinstance(python, int):
    python_version = python
    python_exe = get_executable_name(python_version)
    python = get_executable_path(python_exe)
    if not python:
        raise ValueError('Can not find {} in PATH'.format(python_exe))
elif python == 'auto':
    python_version = get_minimum_python_version(package)
    executable_name = get_executable_name(python_version)
    python = get_executable_path(executable_name)
elif python and PYENV_INSTALLED:
    pyenv = Pyenv()
    pyenv_installed = pyenv.list_installed()
    if not check_if_in_path(python) and python not in pyenv_installed:
        pyenv.install(python, ask_confirmation=True)
        python = pyenv_installed[python].get_path()
else:
    python = sys.executable

Pyenv is just shell scripts. The hardest part would be writing wrapper methods to that parse its output.

@RonnyPfannschmidt
Copy link
Contributor

i wouldn't change it at all since i'm not at all fluent in pyenv and dont use it myself - this has to come from someone that knows the details enough not to make a broken mess

@gwerbin
Copy link

gwerbin commented Jul 19, 2018

That's fine. When I have some more time maybe I can experiment with this.

I will have to figure out testing, I've never written any tests for a piece of software like this before.

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

No branches or pull requests

5 participants