Code Monkey home page Code Monkey logo

pacman-venv's Introduction

Pacman Virtual Environment

A tool to create isolated virtual environments for Pacman. This tool is inspired by Python's virtualenv and therefore works similarly.

Note: pacman-venv is still in its development and testing phase. Not all changes will be backwards compatible. To stay updated with the latest changes, check out the Changelog. Additionally, each update may require you to reinstall your virtual environment for the changes to be applied.

Table of Contents

Overview

Isolating system packages is beneficial for a few reasons:

  • Having two applications with conflicting requirements (one application requires gcc<=11.1.0 while another requires gcc>=12.1.0).
  • Creating isolated development environments for different projects
  • Keeping only necessary packages available system-wide (e.g. not needing to keep track of which packages to remove after testing them)

How It Works

After sourcing the activation script, pacman-venv configures your current environment to correctly use the isolated environment.

  • Most notably, your PATH is configured to look for commands to run in the virtual environment before system-wide commands.
  • Additionally, wrappers are created for all supported package managers and AUR helpers (see Supported AUR Helpers). These wrappers execute their respective package managers with the --root argument pointing to the location of the virtual environment.
  • Last, the name of the virtual environment will appear in the prompt to indicate that the virtual environment is active (similarly to virtualenv).

Installation

The recommended way to install pacman-venv is with an AUR helper. Here is an example with Yay:

yay -S pacman-venv

The development version of this package can be installed with the pacman-venv-git package.

From Source

Pacman-venv can also be installed by cloning the PKGBUILD and building with makepkg:

pacman -S --needed git
git clone https://aur.archlinux.org/pacman-venv.git
cd pacman-venv
makepkg -si

Usage

Create a virtual environment in the current directory:

pacman-venv [name]

Note: If name is not specified, the default name will be used (pacman-venv)

To enter the virtual environment, source the {name}/bin/pacman-venv-active file (Add the .fish extension if you are using the Fish shell). Here is an example for Bash:

source pacman-venv/bin/pacman-venv-activate

Exit the virtual environment by either executing deactivate or exit.

For the full usage of the tool, run:

pacman-venv --help

Additional information on how to use pacman-venv can be found in the man page (man pacman-venv)

Supported Software

Below is a list of all shells and AUR helpers that pacman-venv currently supports

Shells

AUR Helpers

Contributing

If you run into any issues, please file it via GitHub Issues. Additionally, if you have any questions or discussion topics, start a GitHub Discussion.

Contributions are always welcome. Please read Contributing.md if you are considering making contributions.

pacman-venv's People

Contributors

jdholtz avatar

Stargazers

 avatar Micheal Caracciolo avatar Alonso Rodriguez avatar Mateus Orsoni avatar alaska avatar Seyed Sajad Kahani avatar  avatar andy avatar  avatar Cody's Scripts avatar Jeff Barfield avatar Louis Raymond avatar Alex Ruger avatar

Watchers

James Cloos avatar Cody's Scripts avatar  avatar  avatar

pacman-venv's Issues

Support for non-Bash shells

Description

Hey, thanks for taking the time to make this awesome tool.

I'm unable to activate a virtual environment when using any shell other than bash. This is really more of a minor annoyance (I can just switch to bash easily enough), but I wasn't sure if this was identified by you and/or intentional for some reason.

I'm happy to provide you with any additional information you might need from my configuration.

To Reproduce

  1. Ensure a non-bash environment is activated: - zsh
  2. Create a new virtual environment: pacman-venv test-env
  3. Activate the virtual environment: source test-venv/bin/pacman-venv-activate
  4. Observe stderr stream:
realpath: '': No such file or directory
create_path:read:2: bad option: -a
  1. Observe stderr of pacman command: zsh: no such file or directory: ./.pacman-venv-pacman
  2. Activate bash shell: bash
  3. Observe virtual environment is properly activated with source test-venv/bin/pacman-venv-activate
  4. Observe successful execution of test command: pacman -Qs

Expected Behavior

A pacman-venv virtual environment can be successfully created regardless of the active shell environment

Version

pacman-venv --version: Pacman Virtual Environment v0.1

Additional context

No response

Virtual env name doesn't appear in prompt when using Starship

Description

First of all, thanks SO MUCH for this project! I was looking for something exactly like this, being a Python's virtualenv enthusiast.

Small issue I found: When I activate a new pacman-venv, the name of the virtual environment will not appear in the prompt to indicate it's active.

It still seems to be working fine, since both pacman and yay binaries are the ones from the venv.

❯ which yay
/home/matmat/dev/3d-gaussian-splat/pacvenv/pacman-venv-shims/yay

❯ which pacman
/home/matmat/dev/3d-gaussian-splat/pacvenv/pacman-venv-shims/pacman

For the record, python's virtualenv show up as expected in the prompt.

❯ python3 -m virtualenv python-venv-test
❯ source python-venv-test/bin/activate

Screenshot from 2023-10-13 20-43-10

To Reproduce

Create new virtual env pacvenv: pacman-venv pacvenv
Activate it running source pacvenv/bin/pacman-venv-activate
Notice that the virtual env name does not show up in the prompt (although it's active).

Expected Behavior

No response

Version

No response

Additional context

No response

Add the Ability to Use Without Root

Description

running pacman-venv venv asks for sudo password for "Installing base environment"

can it be rootless?

Same for installing packages in the venv, it asks for sudo password.

What alternatives have you considered?

No response

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.