{"id":13491663,"url":"https://github.com/marcwebbie/auto-virtualenv","last_synced_at":"2025-03-02T04:32:56.198Z","repository":{"id":44995129,"uuid":"51458408","full_name":"marcwebbie/auto-virtualenv","owner":"marcwebbie","description":"Automatically activate python virtualenv on Emacs","archived":false,"fork":false,"pushed_at":"2024-11-12T20:05:27.000Z","size":55,"stargazers_count":50,"open_issues_count":2,"forks_count":13,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-12T17:11:28.733Z","etag":null,"topics":["development-environment","emacs","emacs-package","pyenv","python","virtualenv"],"latest_commit_sha":null,"homepage":"https://github.com/marcwebbie/auto-virtualenv","language":"Emacs Lisp","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/marcwebbie.png","metadata":{"files":{"readme":"README.org","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-02-10T17:36:35.000Z","updated_at":"2024-12-04T16:39:48.000Z","dependencies_parsed_at":"2024-11-08T03:28:27.448Z","dependency_job_id":"07aea2bd-817f-4f92-ba11-62074d8e5b93","html_url":"https://github.com/marcwebbie/auto-virtualenv","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marcwebbie%2Fauto-virtualenv","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marcwebbie%2Fauto-virtualenv/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marcwebbie%2Fauto-virtualenv/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marcwebbie%2Fauto-virtualenv/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/marcwebbie","download_url":"https://codeload.github.com/marcwebbie/auto-virtualenv/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241460058,"owners_count":19966511,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["development-environment","emacs","emacs-package","pyenv","python","virtualenv"],"created_at":"2024-07-31T19:00:59.149Z","updated_at":"2025-03-02T04:32:56.178Z","avatar_url":"https://github.com/marcwebbie.png","language":"Emacs Lisp","readme":"#+TITLE: auto-virtualenv.el - Seamless Python Virtualenv Activation in Emacs\n#+AUTHOR: Marcwebbie\n#+URL: https://github.com/marcwebbie/auto-virtualenv\n#+DESCRIPTION: Automatically activate Python virtual environments in Emacs\n\n* Introduction\nauto-virtualenv.el is an Emacs package that automatically activates Python virtual environments based on the project you're working in. It detects both local (e.g., `.venv`) and global (e.g., `~/.pyenv/versions/`) environments, simplifying the process of switching between projects with distinct environments. It provides minimal mode line updates to maintain Emacs performance.\n\n* Features\n- **Automatic Environment Activation**: Activates the appropriate virtual environment upon entering a project.\n- **Pyright and LSP Integration**: Optionally reloads `pyright` or `lsp-mode` after environment activation to resolve broken imports and ensure correct environment settings.\n- **Clear Mode Line Indicators**: Displays the active environment in the mode line or shows \"Venv: N/A\" when none is active.\n- **Customizable Directories**: Searches both local and global directories for virtual environments.\n- **Minimal Mode Line Updates**: Avoids frequent resets for smoother Emacs performance.\n\n* Installation\n\n** From MELPA\nTo install from MELPA, use the following command:\n#+BEGIN_SRC emacs-lisp\n(package-install 'auto-virtualenv)\n#+END_SRC\n\n** Manual Installation\nClone the repository and add ~auto-virtualenv.el~ to your load path:\n#+BEGIN_SRC shell\ngit clone https://github.com/marcwebbie/auto-virtualenv.git\n#+END_SRC\nThen add it to your Emacs configuration:\n#+BEGIN_SRC emacs-lisp\n(add-to-list 'load-path \"/path/to/auto-virtualenv\")\n(require 'auto-virtualenv)\n#+END_SRC\n\n** Using ~use-package~\nSet up ~auto-virtualenv.el~ with ~use-package~:\n#+BEGIN_SRC emacs-lisp\n(use-package auto-virtualenv\n  :load-path \"path/to/auto-virtualenv\"\n  :config\n  (setq auto-virtualenv-verbose t)\n  (auto-virtualenv-setup))\n#+END_SRC\n\n** Using ~straight.el~\nIf you use ~straight.el~, configure it as follows:\n#+BEGIN_SRC emacs-lisp\n(straight-use-package\n  '(auto-virtualenv :type git :host github :repo \"marcwebbie/auto-virtualenv\"))\n\n(require 'auto-virtualenv)\n(setq auto-virtualenv-verbose t)\n(auto-virtualenv-setup)\n#+END_SRC\n\n* LSP and Pyright Integration\nThe package provides optional integration with `lsp-mode` and `pyright`, automatically reloading the language server when changing virtual environments. This ensures that the Python environment settings are correctly updated, avoiding issues with unresolved imports.\n\nTo enable this feature, set ~auto-virtualenv-reload-lsp~ to ~t~ (the default setting):\n#+BEGIN_SRC emacs-lisp\n(setq auto-virtualenv-reload-lsp t)\n#+END_SRC\n\n* Customization Options\nThe package provides customizable options to adapt to your project structure:\n- ~auto-virtualenv-global-dirs~: Directories to search for virtual environments by project name.\n- ~auto-virtualenv-python-project-files~: Files that identify a Python project (e.g., ~requirements.txt~, ~setup.py~).\n- ~auto-virtualenv-activation-hooks~: Hooks that trigger virtual environment activation (default: ~find-file-hook~ and ~projectile-after-switch-project-hook~).\n- ~auto-virtualenv-verbose~: Enable verbose output for debugging.\n- ~auto-virtualenv-reload-lsp~: Automatically reloads `lsp-mode` or `pyright` upon virtual environment change to ensure consistent environment settings.\n\nExample configuration:\n#+BEGIN_SRC emacs-lisp\n(setq auto-virtualenv-global-dirs\n      '(\"~/.virtualenvs/\" \"~/.pyenv/versions/\" \"~/.envs/\" \"~/.conda/\" \"~/.conda/envs/\"))\n(setq auto-virtualenv-python-project-files\n      '(\"requirements.txt\" \"Pipfile\" \"pyproject.toml\" \"setup.py\" \"manage.py\" \"tox.ini\" \".flake8\"))\n#+END_SRC\n\n* Related Projects and Inspirations\nauto-virtualenv.el was inspired by several other projects, including:\n- [[https://github.com/jorgenschaefer/pyvenv][pyvenv]]: Manually activates and deactivates virtual environments.\n- [[https://github.com/purcell/exec-path-from-shell][exec-path-from-shell]]: Syncs Emacs environment variables with the shell.\n- [[https://github.com/bbatsov/projectile][projectile]]: A project management and navigation tool for Emacs.\n\n* License\nThis project is licensed under the GPLv3.\n\n* Contributions\nContributions are welcome! Feel free to open issues, submit pull requests, or suggest improvements.\n","funding_links":[],"categories":["Emacs Lisp"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarcwebbie%2Fauto-virtualenv","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmarcwebbie%2Fauto-virtualenv","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarcwebbie%2Fauto-virtualenv/lists"}