Coder Social home page Coder Social logo

pyenv-mode-auto's Introduction

pyenv-mode-auto

image

Automatically activate pyenv version from Emacs with pyenv-mode.

It traverse directories up until .python-version file will be found and activates pyenv version defined there.

Installation

You can simply install package from Melpa.

(add-to-list 'package-archives
       '("melpa" . "http://melpa.org/packages/") t)

And then M-x package-install [RET] pyenv-mode-auto [RET]. After Installing you should require this package:

(require 'pyenv-mode-auto)

Usage

Just open any file within you project (with .python-version file in the same directory or above) and you pyenv version will be activated.

pyenv-mode-auto's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

pyenv-mode-auto's Issues

Question : Is this replacement for pyvenv-workon ?

I was earlier using pyvenv and when I manually set pyvenv-workon to the same virtualenv, everything used to work, but there was always this manual step to select the virtualenv. So I came here looking for "automation"

I (think) I have installed pyenv-mode-auto correctly (It is really simple) yet, I am not sure it is working for me.
.python-version exists in the parent folder of the file I have opened.

To troubleshoot, I even manually pyenv-mode-set to the correct virtualenv - yet after doing that M-! which python reports /usr/local/bin/python not the one from my virtualenv.

What am I doing wrong ? (or may be I am expecting something that is not supposed to work)

Also, what are the steps to troubleshoot ?

License

Hey,

I'd like to contribute a couple of patches to the code, but my employer requires that the projects have a license. Would you considerer adding a license explicitly to the project?

Thanks!

Support multiple active environments

Currently, pyenv-mode-auto assumes that any .python-version file will contain one line with one active version. However, pyenv allows for the cascade of environments (I presume via the shims looking through one and falling back to the next configured environment if a given command doesn't exist in the first environment, but I have not checked this). This cascading setup is relatively common for tox-oriented workflows, but currently breaks pyenv-mode-auto.

I'm not sure how such a simple library could emulate this behavior fully, but I have a small change that fixes it in all of my cases: simply activate the first listed environment.

This looks as follows:

(defun pyenv-mode-auto-hook ()
  "Automatically activates pyenv version if .python-version file exists."
  (f-traverse-upwards
   (lambda (path)
     (let ((pyenv-version-path (f-expand ".python-version" path)))
       (if (f-exists? pyenv-version-path)
           (progn
             (pyenv-mode-set (car (s-lines (s-trim (f-read-text pyenv-version-path 'utf-8)))))
             t))))))

Note the addition of the use of car and s-lines.

If you'd like, I'll happily work this into a PR. I wanted to open the floor for some discussion before I did that, however.

Format of the .python-version file

I am trying to use this package for my python development on emacs.
I have a .python-version file inside my project folder, at the same level as the source code I am working on. This is the content of the .python-version file, a one-liner that indicates the location of the pinns virtual environment that I want to use for my code.

/home/dromero/.virtualenvs/pinns

However, the pyenv-mode-auto package does not automatically activate this environment.
Can you please help? What am I doing wrong?

Thanks!

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.