Giter Site home page Giter Site logo

pew's Introduction

Pew - Python Env Wrapper

PyPi version CI test status PyPi

Releases & changelog

Python Env Wrapper is a set of commands to manage multiple virtual environments. Pew can create, delete and copy your environments, using a single command to switch to them wherever you are, while keeping them in a single (configurable) location.

Virtualenvs makes it easier to work on more than one project at a time without introducing conflicts in their dependencies.

Pew is completely shell-agnostic and thus works on bash, zsh, fish, powershell, etc.

Installation

Nix (Linux and Macos)

You can use Nix to install Pew on Nixos as well as other Linux distributions or Macos:

nix-env --install --attr pew

Arch linux

For Archlinux, there's an AUR package

Pypi

Pew and its dependencies rely on a couple of features of pip/setuptools which might not be available on old versions. In case your distribution doesn't ship with one recent enough, you'll probably want to run pip install --upgrade pip before the installation.

If you cannot upgrade the version of setuptools on your system, and one of the packages listed below is of no use to you, I suggest to use pipsi rather than plain pip

pipsi install pew

See the troubleshooting section, if needed.

Usage

Which SHELL is Pew going to use?

Ok, Pew is shell-agnostic, but how is your shell going to be selected?

Look for the SHELL environment variable: on most unix-like systems it's already defined in a login shell, and you can verify it with commands like:

env | grep SHELL

or

python3 -c 'import os;print(os.environ.get("SHELL","No shell defined"))'

Since that variable is not commonly used on Windows, we're detecting the parent process from which pew has been invoked and use that as the user's preferred shell. If CMDER_ROOT is defined this will select Cmder (a custom configuration of cmd.exe).

In all other cases we default instead to sh.

Windows/Cygwin notes

A python installed from the normal .exe file behaves differently from a python installed inside Cygwin. For this reason if you want to use Pew inside a Cygwin shell, you should use a Cygwin python, and if you want to use it inside Powershell, you should use your normal Python install, and avoid a Cygwin one.

Common workflow

You can create a new virtualenv, with a non-default python and specifying some packages to be installed in it, like this:

~> pew new --python=pypy3 -i django myproject
created virtual environment PyPy3.6.9.final.0-64 in 817ms
creator PyPy3Posix(dest=/home/tadej/.local/share/virtualenvs/myproject, clear=False, global=False)
seeder FromAppData(extra_search_dir=/usr/share/python-wheels,download=False, pip=bundle, setuptools=bundle, wheel=bundle, via=copy, app_data_dir=/home/tadej/.local/share/virtualenv)
    added seed packages: pip==21.2.1, setuptools==57.4.0, wheel==0.36.2
activators BashActivator,CShellActivator,FishActivator,PowerShellActivator,PythonActivator,XonshActivator
Collecting django
Downloading Django-3.2.7-py3-none-any.whl (7.9 MB)
    |████████████████████████████████| 7.9 MB 1.8 MB/s
Collecting asgiref<4,>=3.3.2
Downloading asgiref-3.4.1-py3-none-any.whl (25 kB)
Collecting pytz
Downloading pytz-2021.1-py2.py3-none-any.whl (510 kB)
    |████████████████████████████████| 510 kB 10.6 MB/s
Collecting sqlparse>=0.2.2
Downloading sqlparse-0.4.2-py3-none-any.whl (42 kB)
    |████████████████████████████████| 42 kB 833 kB/s
Collecting typing-extensions
Downloading typing_extensions-3.10.0.2-py3-none-any.whl (26 kB)
Installing collected packages: typing-extensions, sqlparse, pytz, asgiref, django
Successfully installed asgiref-3.4.1 django-3.2.7 pytz-2021.1 sqlparse-0.4.2 typing-extensions-3.10.0.2
WARNING: You are using pip version 21.2.1; however, version 21.2.4 is available.
You should consider upgrading via the '/home/tadej/.local/share/virtualenvs/myproject/bin/pypy3 -m pip install --upgrade pip' command.
Launching subshell in virtual environment. Type 'exit' or 'Ctrl+D' to return.

Once inside, you can check the current Python version, list the packages present in its python's site-packages directory, and install additional packages like this:

myproject ~> python -V
Python 3.6.9 (831ff17f8cd1, May 26 2021, 11:41:48)
[PyPy 7.3.1 with GCC 10.3.1 20210422 (Red Hat 10.3.1-1)]
myproject ~> pew lssitepackages
/home/tadej/.local/share/virtualenvs/myproject/site-packages/Django-3.2.7.dist-info
/home/tadej/.local/share/virtualenvs/myproject/site-packages/__pycache__
/home/tadej/.local/share/virtualenvs/myproject/site-packages/_distutils_hack
/home/tadej/.local/share/virtualenvs/myproject/site-packages/_virtualenv.pth
/home/tadej/.local/share/virtualenvs/myproject/site-packages/_virtualenv.py
/home/tadej/.local/share/virtualenvs/myproject/site-packages/asgiref
/home/tadej/.local/share/virtualenvs/myproject/site-packages/asgiref-3.4.1.dist-info
/home/tadej/.local/share/virtualenvs/myproject/site-packages/backports
/home/tadej/.local/share/virtualenvs/myproject/site-packages/backports.entry_points_selectable-1.1.0.dist-info
/home/tadej/.local/share/virtualenvs/myproject/site-packages/clonevirtualenv.py
/home/tadej/.local/share/virtualenvs/myproject/site-packages/distlib
/home/tadej/.local/share/virtualenvs/myproject/site-packages/distlib-0.3.3.dist-info
/home/tadej/.local/share/virtualenvs/myproject/site-packages/distutils-precedence.pth
/home/tadej/.local/share/virtualenvs/myproject/site-packages/django
/home/tadej/.local/share/virtualenvs/myproject/site-packages/easy-install.pth
/home/tadej/.local/share/virtualenvs/myproject/site-packages/filelock
/home/tadej/.local/share/virtualenvs/myproject/site-packages/filelock-3.1.0.dist-info
/home/tadej/.local/share/virtualenvs/myproject/site-packages/importlib_metadata
/home/tadej/.local/share/virtualenvs/myproject/site-packages/importlib_metadata-4.8.1.dist-info
/home/tadej/.local/share/virtualenvs/myproject/site-packages/importlib_resources
/home/tadej/.local/share/virtualenvs/myproject/site-packages/importlib_resources-5.2.2.dist-info
/home/tadej/.local/share/virtualenvs/myproject/site-packages/pew.egg-link
/home/tadej/.local/share/virtualenvs/myproject/site-packages/pip
/home/tadej/.local/share/virtualenvs/myproject/site-packages/pip-21.2.1.dist-info
/home/tadej/.local/share/virtualenvs/myproject/site-packages/pip-21.2.1.virtualenv
/home/tadej/.local/share/virtualenvs/myproject/site-packages/pkg_resources
/home/tadej/.local/share/virtualenvs/myproject/site-packages/platformdirs
/home/tadej/.local/share/virtualenvs/myproject/site-packages/platformdirs-2.4.0.dist-info
/home/tadej/.local/share/virtualenvs/myproject/site-packages/pytz
/home/tadej/.local/share/virtualenvs/myproject/site-packages/pytz-2021.1.dist-info
/home/tadej/.local/share/virtualenvs/myproject/site-packages/setuptools
/home/tadej/.local/share/virtualenvs/myproject/site-packages/setuptools-57.4.0.dist-info
/home/tadej/.local/share/virtualenvs/myproject/site-packages/setuptools-57.4.0.virtualenv
/home/tadej/.local/share/virtualenvs/myproject/site-packages/six-1.16.0.dist-info
/home/tadej/.local/share/virtualenvs/myproject/site-packages/six.py
/home/tadej/.local/share/virtualenvs/myproject/site-packages/sqlparse
/home/tadej/.local/share/virtualenvs/myproject/site-packages/sqlparse-0.4.2.dist-info
/home/tadej/.local/share/virtualenvs/myproject/site-packages/typing_extensions-3.10.0.2.dist-info
/home/tadej/.local/share/virtualenvs/myproject/site-packages/typing_extensions.py
/home/tadej/.local/share/virtualenvs/myproject/site-packages/virtualenv
/home/tadej/.local/share/virtualenvs/myproject/site-packages/virtualenv-20.8.1.dist-info
/home/tadej/.local/share/virtualenvs/myproject/site-packages/virtualenv_clone-0.5.7.dist-info
/home/tadej/.local/share/virtualenvs/myproject/site-packages/wheel
/home/tadej/.local/share/virtualenvs/myproject/site-packages/wheel-0.36.2.dist-info
/home/tadej/.local/share/virtualenvs/myproject/site-packages/wheel-0.36.2.virtualenv
/home/tadej/.local/share/virtualenvs/myproject/site-packages/zipp-3.6.0.dist-info
/home/tadej/.local/share/virtualenvs/myproject/site-packages/zipp.py
myproject ~> pip install pdbpp
Collecting pdbpp
Downloading pdbpp-0.10.3-py2.py3-none-any.whl (23 kB)
Collecting fancycompleter>=0.8
Downloading fancycompleter-0.9.1-py3-none-any.whl (9.7 kB)
Collecting wmctrl
Downloading wmctrl-0.4.tar.gz (5.4 kB)
Collecting pygments
Downloading Pygments-2.10.0-py3-none-any.whl (1.0 MB)
    |████████████████████████████████| 1.0 MB 2.4 MB/s
Collecting pyrepl>=0.8.2
Downloading pyrepl-0.9.0.tar.gz (48 kB)
    |████████████████████████████████| 48 kB 3.0 MB/s
Building wheels for collected packages: pyrepl, wmctrl
Building wheel for pyrepl (setup.py) ... done
Created wheel for pyrepl: filename=pyrepl-0.9.0-py3-none-any.whl size=59906 sha256=de1c4017634f07823025e3cd6db0221c5ec6eafaade32f48c306b4774809c0db
Stored in directory: /home/tadej/.cache/pip/wheels/bd/32/c9/a638d4a50ae3bf39e8d6ac32f889746687f858794f2a841f84
Building wheel for wmctrl (setup.py) ... done
Created wheel for wmctrl: filename=wmctrl-0.4-py3-none-any.whl size=3858 sha256=e5aee6309b7b919a44423b524b6d0b66a238e6efdcafcefee34757cf2057f408
Stored in directory: /home/tadej/.cache/pip/wheels/1c/8e/da/50ccb9bb858eb7462f6047965be9badfa6f4d36d707ac5c5a2
Successfully built pyrepl wmctrl
Installing collected packages: pyrepl, wmctrl, pygments, fancycompleter, pdbpp
Successfully installed fancycompleter-0.9.1 pdbpp-0.10.3 pygments-2.10.0 pyrepl-0.9.0 wmctrl-0.4
myproject ~> pip freeze
asgiref==3.4.1
backports.entry-points-selectable==1.1.0
cffi==1.14.0
distlib==0.3.3
Django==3.2.7
fancycompleter==0.9.1
filelock==3.1.0
greenlet==0.4.13
importlib-metadata==4.8.1
importlib-resources==5.2.2
pdbpp==0.10.3
platformdirs==2.4.0
Pygments==2.10.0
pyrepl==0.9.0
pytz==2021.1
readline==6.2.4.1
six==1.16.0
sqlparse==0.4.2
typing-extensions==3.10.0.2
virtualenv==20.8.1
virtualenv-clone==0.5.7
wmctrl==0.4
zipp==3.6.0
myproject ~> ^D

You can also specify a requirements file, to be passed on to pip, and activate another virtualenv with workon:

~> pew new -r ~/Projects/topaz/requirements.txt topaz
New python executable in topaz/bin/python
[SNIP]
Successfully installed rply pytest invoke requests py
Cleaning up...
Launching subshell in virtual environment. Type 'exit' or 'Ctrl+D' to return.
topaz ~> ^D

~> pew workon myproject
Launching subshell in virtual environment. Type 'exit' or 'Ctrl+D' to return.
myproject ~>

Since 0.1.16, Pew integrates Pythonz, which allows you to easily install a new python version (only on linux and macosx):

~> pew install 2.6.1 --type pypy
WARNING: Linux binaries are dynamically linked, as is usual, and thus might not be usable due to the sad story of linux binary    compatibility,  check the PyPy website for more information
Downloading pypy-2.6.1-linux64.tar.bz2 as /home/dario/.pythonz/dists/pypy-2.6.1-linux64.tar.bz2
########################################################################## 100%
Extracting pypy-2.6.1-linux64.tar.bz2 into /home/dario/.pythonz/build/PyPy-2.6.1
Installing PyPy-2.6.1 into /home/dario/.pythonz/pythons/PyPy-2.6.1

Installed PyPy-2.6.1 successfully.
~> pew new --python=$(pythonz locate 2.6.1 --type pypy) latest_pypy
Running virtualenv with interpreter /home/dario/.pythonz/pythons/PyPy-2.6.1/bin/python
New pypy executable in latest_pypy/bin/python
Also creating executable in latest_pypy/bin/pypy
Installing setuptools, pip, wheel...done.
Launching subshell in virtual environment. Type 'exit' or 'Ctrl+D' to return.
latest_pypy ~> python -V
Python 2.7.10 (f3ad1e1e1d62, Aug 28 2015, 10:45:29)
[PyPy 2.6.1 with GCC 4.8.4]

Command Reference

When invoked without arguments pew will output the list of all commands with each one's description

new

Create a new environment, in the WORKON_HOME.

usage: pew new [-hd] [-p PYTHON] [-i PACKAGES] [-a PROJECT] [-r REQUIREMENTS] envname

The new environment is automatically activated after being initialized.

The -a option can be used to associate an existing project directory with the new environment.

The -i option can be used to install one or more packages (by repeating the option) after the environment is created.

The -r option can be used to specify a text file listing packages to be installed. The argument value is passed to pip -r to be installed.

workon

List or change working virtual environments.

usage: pew workon [-h] [--no-cd] [envname]

If no envname is given the list of available environments is printed to stdout. If -n or --no-cd is provided, current directory is not changed even if a project path is associated with envname.

mktmpenv

Create a temporary virtualenv.

usage: pew mktmpenv [-h] [-p PYTHON] [-i PACKAGES] [-a PROJECT] [-r REQUIREMENTS]

ls

List all of the environments.

usage: pew ls [-h] [-b | -l]

The --long options will print each virtualenv side-by-side with its Python version and the contents of its site-packages

show

usage: pew show [env]

inall

Run a command in each virtualenv.

usage: pew inall [command]

in

Run a command in the given virtualenv.

usage: pew in [env] [command]

rm

Remove one or more environments, from the WORKON_HOME.

usage: pew rm envs [envs ...]

You have to exit from the environment you want to remove.

install

Use Pythonz to download and build a Python vm

usage: pew install [options] version

To install Python3.8.0

pew install 3.8.0

To install Pypy:

pew install 2.6.1 --type pypy

list_pythons

List the pythons installed by Pythonz

usage: pew list_pythons [options]

You can list all the Pythons available to install with -a or --all-versions

locate_python

Locate the path for the python version installed by Pythonz

usage: pew locate_python [options] version

cp

Duplicate an existing virtualenv environment. The source can be an environment managed by virtualenvwrapper or an external environment created elsewhere.

Copying virtual environments is not well supported. Each virtualenv has path information hard-coded into it, and there may be cases where the copy code does not know to update a particular file. Use with caution.

usage: pew cp [-hd] source [targetenvname]

Target environment name is required for WORKON_HOME duplications. However, target environment name can be omitted for importing external environments. If omitted, the new environment is given the same name as the original.

sitepackages_dir

Returns the location of the currently active's site-packages

lssitepackages

Equivalent to ls $(sitepackages_dir).

add

Adds the specified directories to the Python path for the currently-active virtualenv.

usage: pew add [-h] [-d] dirs [dirs ...]

Sometimes it is desirable to share installed packages that are not in the system site-packages directory and which should not be installed in each virtualenv. One possible solution is to symlink the source into the environment site-packages directory, but it is also easy to add extra directories to the PYTHONPATH by including them in a .pth file inside site-packages using pew add.

The -d flag removes previously added directories.

The directory names are added to a path file named _virtualenv_path_extensions.pth inside the site-packages directory for the environment.

toggleglobalsitepackages

Controls whether the active virtualenv will access the packages in the global Python site-packages directory.

usage: pew toggleglobalsitepackages [-q]

mkproject

Create a new virtualenv in the WORKON_HOME and project directory in PROJECT_HOME.

usage: pew mkproject [-hd] [-p PYTHON] [-i PACKAGES] [-a PROJECT] [-r REQUIREMENTS] [-t TEMPLATES] [-l] envname

The template option may be repeated to have several templates used to create a new project. The templates are applied in the order named on the command line. All other options are passed to pew new to create a virtual environment with the same name as the project.

A template is simply an executable to be found in WORKON_HOME, it will be called with the name of the project, and the project directory as first and second argument, respectively. A template_django script is given as an example inside the pew package.

setproject

Bind an existing virtualenv to an existing project.

usage: pew setproject [virtualenv_path] [project_path]

When no arguments are given, the current virtualenv and current directory are assumed.

getproject

Return a virtualenv's project directory.

usage: pew getproject [env]

When no arguments are given, the current virtualenv is assumed.

restore

Try to restore a broken virtualenv by reinstalling the same python version on top of it

usage: pew restore env

rename

Rename a virtualenv (by copying it over to the new name, and deleting the old one)

usage: pew rename source target

wipeenv

Remove all installed packages from the current (or supplied) env.

usage: pew wipeenv [env]

shell_config

Prints the path for the current $SHELL helper file

usage: pew shell_config

dir

Prints the path for the supplied env

usage: pew dir env

Configuration

You can customize pew's virtualenvs directory location, with the $XDG_DATA_HOME or $WORKON_HOME environment variables, and the locations of new projects created with mkproject by setting $PROJECT_HOME (otherwise, the current directory will be selected).

Troubleshooting

The environment doesn't seem to be activated

If you've defined in your shell rc file to export a PATH location that might shadow the executables needed by pew (or your project), you might find that when getting into the environment, they will still be at the head of the PATH.

There're multiple way to overcome this issue:

  • Move your export statements into the profile (.bash_profile and .zprofile for bash and zsh respectively, or in fish wrap your statements in a if status --is-login block ) and set up your terminal emulator to launch your shell as a login shell
  • Change your exports to put the new location at the tail, instead of the head of the PATH, e.g.: export PATH=${PATH}:/usr/bin
  • Change the files your OS provides to setup the base environment (it might be useful to look into /etc/paths.d, /etc/profile, and environment.plist)

If you're running the zsh configuration tool prezto, and/or you're on MacOSX, you might want to read this (it's about another project for handling dotfiles, but the misconfiguration described is quite similar to one witnessed on other OSX/prezto systems).

pkg_resources.DistributionNotFound: virtualenv

This might happen after a Python update, especially on MacOSX, upgrading setuptools might fix that (you should need superuser permissions to do it)

easy_install -U setuptools

or

pip install --upgrade setuptools

Other issues

Congratulations! You found a bug, please let me know :)

Running Tests

The test suite for pew uses tox. Most tests are actually integration tests that will fork shells, create virtualenvs and in some cases even download python packages from Pypi. The whole test suite takes around 1 minute to run on a single interpreter.

With every commit and pull request, the test suite is run over all supported interpreters on GitHub Actions (which runs tests on Linux and Windows).

To run individual test scripts, run from the top level directory of the repository a command like:

tox tests/test_setproject.py

To run tests under a single version of Python, specify the appropriate environment when running tox:

tox -e py38

Combine the two modes to run specific tests with a single version of Python:

tox -e py38 tests/test_setproject.py

You can also filter them:

tox -e py38 -- -k workon

Add new tests by modifying an existing file or creating new script in the tests directory.

Display the environment name in the terminal prompt

bash/zsh

The first run setup should take care of this for you.

You can do it manually by appending to your .bashrc/.zshrc

source $(pew shell_config)

fish

Just like for bash/zsh, but since fish uses a fish_prompt function and not a PS1 environment variable, the setup will only make available to you a fish function pew_prompt. Just use its output in the fish_prompt function.

powershell prompt

Add this to a prompt function:

Write-Host -NoNewLine -f blue ([System.IO.Path]::GetFileName($env:VIRTUAL_ENV))

no hooks (for now)

(There's currently a Pull Request open for it)

Adding hooks for installing some packages on each new virtualenv creation is quite easy, but I couldn't find some comprehensive hook examples, and virtualenvwrapper's hook implementation lets the hook return a script to be sourced.

This could be handled by (instead of getting back a script to be sourced) getting back an environment/list of key-values to be applied when invoking inve.

But to handle just the simple case, using the existing virtualenvwrapper's infrastructure (which relied on stevedore) seemed like overkill, and given that the most interesting virtualenvwrapper's extensions have been merged to the trunk at the end, and that I never used virtualenvwrapper's hook first hand, I decided to skip them, at least for now.

Thanks

Everyone who submitted patches/PR, as of September 2015:

  • José Luis Lafuente
  • Arthur Vuillard
  • Jakub Stasiak
  • Ryan Hiebert
  • Michael Hofer
  • Daniel Harding
  • Timothy Corbett-Clark
  • Simon Junod
  • Robin
  • Matei Trușcă
  • Lucas Cimon
  • Alexandre Decan
  • Ashwin Vishnu Mohanan

Thanks also to Michael F. Lamb for his thought provoking gist and to Doug Hellman for virtualenvwrapper

Rationale

Pew is written in pure python and leverages inve: the idea for a better activate script.

Pew was originally a rewrite of virtualenvwrapper, the advantage is that pew doesn't hook into a shell, but is only a set of commands, thus completely shell-agnostic:

It works on bash, zsh, fish, powershell, etc.

Thanks to using Python libraries and setuptools for dependency management, to Python stricter error handling and the fact that "shelling out" let us avoid keeping track of the previous environment variable values, pew code is much shorter and easier to understand than virtualenvwrapper's. How many Python programmers know at a glance what does "${out_args[@]-}" do? Or eval "envname=\$$#"? Or all other bash quirks for that matter?

pew's People

Contributors

berdario avatar erinxocon avatar tjanez avatar kennethreitz avatar jlesquembre avatar arthru avatar jstasiak avatar pfmoore avatar ryanhiebert avatar uranusjr avatar mcyprian avatar michaelxor avatar yggi49 avatar ashwinvis avatar living180 avatar gnprice avatar lucas-c avatar timgates42 avatar jeremytrimble avatar aljohri avatar indigane avatar aranega avatar tcorbettclark avatar sobolevn avatar nyobe avatar peterdemin avatar infothrill avatar e4r7hbug avatar mlcdf avatar jayvdb avatar

Stargazers

 avatar Johnathan Schneider avatar Ji Ru avatar souvik dutta avatar Max avatar dong avatar Don Onwunumah avatar  avatar Jeff Regan avatar G Karthik Raja avatar Tanguy Launay avatar Kyle O'Brien avatar popo avatar Todd Sutton avatar Joel Van Eenwyk avatar Vera Rei avatar Janko Vidaković avatar ygXXII avatar Olivier Samyn avatar  avatar Andrew avatar Hyeonseo Yang avatar Alan Szmyt avatar Georgios Kafanas avatar Khoi Nguyen Tinh Song avatar Harry Chen avatar Aurelien Gateau avatar Tim Tate avatar Adnan Ahmed avatar msenturk avatar Mario avatar  avatar Harvey avatar Nate Rudnick-Aldridge avatar  avatar Marc Yefimchuk avatar Felix avatar Manuel Rivera avatar  avatar KamalkaNipun avatar Krystian Safjan avatar Nelson Guamán avatar Iwan Aucamp avatar  avatar Shonn avatar Ajeeb K P avatar Max avatar Sascha Ohms avatar  avatar Thorsten Fritze avatar Nikita avatar Marc Green avatar Aamaal Abdul-Malik Anderson avatar Florian Bütler avatar István Lantos avatar pedoc avatar Roman Hossain Shaon avatar  avatar Neoma Fong avatar  avatar  avatar wsadczh avatar  avatar  avatar Ariary avatar Aliaksei avatar Antropy avatar  avatar Ralph avatar Tobias avatar Daniel avatar Matt avatar  avatar Naeem N avatar Emanuele Sabetta avatar Blair Noctis avatar  avatar frankfanslc avatar Rick Price avatar Konstantin Kl. avatar Noorhteen Raja NJ avatar Bart avatar  avatar Maor Kadosh avatar  avatar Adrian Strzała avatar Hung Phan avatar  avatar danav avatar  avatar  avatar  avatar George Klinich avatar Aurélien Gâteau avatar Teddy Xinyuan Chen avatar Valentin Marlier avatar Iain Samuel McLean Elder avatar Felix Grzelka avatar Jamie Sparks avatar Jiansong Liu avatar

Watchers

Shiva avatar Onofre Souza avatar Noam  Vergain avatar xVoLAnD avatar  avatar Árni Már Jónsson avatar Pavel Marakhovsky avatar evandrix avatar Rakhmad Azhari avatar  avatar Bo CHEN avatar  avatar Gregory avatar Michael R. Bernstein avatar  avatar Mohamed Faramawi avatar  avatar Julien Vitard avatar Bruno Villasanti avatar  avatar  avatar  avatar  avatar Jeff Tratner avatar Andreas Ecker avatar Arvid avatar zhang jian avatar Belal avatar Yuetao avatar Max avatar  avatar Zhiyang Ong avatar Travis C. LaGrone avatar  avatar

pew's Issues

"pew wipenv" uninstalls packages from the main environment

``pew in MYENV pew wipeenv`' uninstalls all packages from MYENV which is good.

But when executed directly (pew wipenv), which is quite easy to do by someone learning how to use pew, packages from the system Python are uninstalled which should not happen that easily. A nicer solution would be to fail when we are outside virtual env or at least require a switch like --force in such cases.

Checked on Windows / cmd.exe and on Windows / Git Bash, Python 2.7.10 and:
pathlib==1.0.1
pew==0.1.14
virtualenv==13.0.1
virtualenv-clone==0.2.5

Cannot download non-wheel dependencies

Steps to reproduce:

  • Using pip 1.5.6 from /usr/lib/python2.7/dist-packages (python 2.7) on Ubuntu 14.10
  • pip install --download . pew (correctly downloads wheels into current folder)
  • pip install --download . pew --no-use-wheel

What should happen:
Correctly downloads tar.gz files into current folder

What happens instead:

Downloading/unpacking pew
  Using download cache from /home/username/.cache/pip/https%3A%2F%2Fpypi.python.org%2Fpackages%2Fsource%2Fp%2Fpew%2Fpew-0.1.14.tar.gz
  Saved ./pew-0.1.14.tar.gz
  Running setup.py (path:/tmp/pip_build_username/pew/setup.py) egg_info for package pew
    Traceback (most recent call last):
      File "<string>", line 17, in <module>
      File "/tmp/pip_build_username/pew/setup.py", line 5, in <module>
        import pew
      File "pew/__init__.py", line 11, in <module>
        from . import pew
      File "pew/pew.py", line 12, in <module>
        from pathlib import Path
    ImportError: No module named pathlib
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):

  File "<string>", line 17, in <module>

  File "/tmp/pip_build_username/pew/setup.py", line 5, in <module>

    import pew

  File "pew/__init__.py", line 11, in <module>

    from . import pew

  File "pew/pew.py", line 12, in <module>

    from pathlib import Path

ImportError: No module named pathlib

----------------------------------------
Cleaning up...
Command python setup.py egg_info failed with error code 1 in /tmp/pip_build_username/pew
Storing debug log for failure in /home/username/.pip/pip.log

Workaround:
Works with pip 6.0.6 from /home/username/.local/lib/python3.4/site-packages (python 3.4) (that is, a non-system (--user) installation of the very latest version of pip; I'm not sure if running under Python 3 has anything to do with the workaround working.

Exception when prompt contains Unicode symbol

My bash prompt contains a unicode symbol.

When I try to perform pew workon, it fails with a UnicodeEncodeError:

Traceback (most recent call last):
  File "/usr/local/bin/pew", line 11, in <module>
    sys.exit(pew())
  File "/usr/local/lib/python2.7/dist-packages/pew/pew.py", line 684, in pew
    return command(sys.argv[2:])
  File "/usr/local/lib/python2.7/dist-packages/pew/pew.py", line 322, in workon_cmd
    shell(env, cwd=project_dir)
  File "/usr/local/lib/python2.7/dist-packages/pew/pew.py", line 172, in shell
    fork_bash(env, cwd)
  File "/usr/local/lib/python2.7/dist-packages/pew/pew.py", line 150, in fork_bash
    rcfile.write(bashrc.read())
UnicodeEncodeError: 'ascii' codec can't encode character u'\u21af' in position 2223: ordinal not in range(128)

If I remove the offending symbol from my prompt, everything works as intended. (pew version 0.1.18)

pew new fails when installed using pip (due to older version of setuptools)

@berdario

Firstly, I apologize for communicating via a bug-report. I couldn't find your twitter handle, or another way to reach you.

I was setting up a new dev env, using #! and virtualbox. After installing pip using get-pip.py, I tried to install pew, but was unable to create new environments:

shiva@crunchbang-2:~$ sudo pip install pew
shiva@crunchbang-2:~$ pew ls
Traceback (most recent call last):
  File "/usr/local/bin/pew", line 5, in <module>
    from pkg_resources import load_entry_point
  File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 2707, in <module>
    working_set.require(__requires__)
  File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 686, in require
    needed = self.resolve(parse_requirements(requirements))
  File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 584, in resolve
    raise DistributionNotFound(req)
pkg_resources.DistributionNotFound: virtualenv

The fix is to upgrade the setuptools that come with python2.7 by default. Not sure, if this is specific to my env, or is a requirement for pew, that hasn't been documented.

Thoughts?

More details (if required) at http://blog.shiv.me/2014/02/obvious-but-not/

Add tab completion

I don't know if it's possible but it would be convenient to have the tab completion available with the pew workon command (and maybe with some others I don't use).

Release new version to PyPI

The latest version (0.1.9) doesn't include some useful fixes, like the #24 . Please make a new release with this changes.

Command "python setup.py egg_info" failed with error code 1

I just tried to install pew using pip 1.7.2 and got this error:

; python -V
Python 2.7.5
; pip --version
pip 7.1.2 from /usr/lib/python2.7/site-packages (python 2.7)
; pip install --user pew
Collecting pew
  Using cached pew-0.1.18-py2.py3-none-any.whl
Collecting pythonz-bd>=1.10.2 (from pew)
  Using cached pythonz-bd-1.10.2.tar.gz
  Complete output from command python setup.py egg_info:
  error in pythonz-bd setup command: Invalid environment marker: python_version>="3.5"
  ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-ngA0LP/pythonz-bd

Non-ASCII chars in .bashrc crash pew

My prompt (PS1) has fancy Unicode characters so pew crashes with UnicodeEncodeError when writing the temporary .bashrc.

On this line:

        with NamedTemporaryFile('w+') as rcfile:
            with bashrcpath.open() as bashrc:
                rcfile.write(bashrc.read())  # crashes here
            rcfile.write('\nexport PATH=' + compute_path(env))

rcfile has a default encoding of ascii which cannot encode said characters for writing. Using byte strings everywhere might be the only right solution to this issue.

can't install when both 3.5 and 2.7.10 on os x

I am not very good at debugging broken installs and dependencies.

Here is what happens:
sudo -H pip install pew
Collecting pew
Downloading pew-0.1.18-py2.py3-none-any.whl
Collecting pythonz-bd>=1.10.2 (from pew)
Downloading pythonz-bd-1.10.2.tar.gz (85kB)
100% |████████████████████████████████| 86kB 3.8MB/s
Complete output from command python setup.py egg_info:
error in pythonz-bd setup command: Invalid environment marker: python_version>="3.5"

----------------------------------------

Command "python setup.py egg_info" failed with error code 1 in /private/tmp/pip-build-VI9n4h/pythonz-bd

Some questions:

  1. haven't wheels pretty much supplanted eggs?--I see that it is a wheel, so I don't understand the message that refers to python setup.py egg_info.
  2. My system path points to Python 2.7.10 in /Library/Frameworks--NOT /System/Library/Frameworks.
  3. So, when I run pip I am installing against python 2.7.10 so why the error message about python_version="3.5". You shouldn't be able to even see that Python 3.5 is there unless there is some error in your script--or, unlike virtualenvwrapper, you try to support all python's in parallel.

"pew new" fails on raspberry pi

Hi, I tried to pip install pew on a rPi today, here is how it went. (raspbian, python3.2)

$ sudo pip install pew
Collecting pew
  Using cached pew-0.1.14-py2.py3-none-any.whl
Requirement already satisfied (use --upgrade to upgrade): virtualenv>=1.11 in /usr/local/lib/python3.2/dist-packages (from pew)
Requirement already satisfied (use --upgrade to upgrade): virtualenv-clone>=0.2.5 in /usr/local/lib/python3.2/dist-packages (from pew)
Requirement already satisfied (use --upgrade to upgrade): pathlib in /usr/local/lib/python3.2/dist-packages (from pew)
Requirement already satisfied (use --upgrade to upgrade): setuptools>=0.8 in /usr/local/lib/python3.2/dist-packages (from pew)
Installing collected packages: pew
Successfully installed pew-0.1.14

$ pew new testpew
Traceback (most recent call last):
  File "/usr/local/bin/pew", line 7, in <module>
    from pew.pew import pew
  File "/usr/local/lib/python3.2/dist-packages/pew/__init__.py", line 11, in <module>
    from . import pew
  File "/usr/local/lib/python3.2/dist-packages/pew/pew.py", line 283
    new_paths = [os.path.abspath(d) + u"\n" for d in args.dirs]
                                          ^
SyntaxError: invalid syntax

Pew 0.1.16 crash on Windows (related to pythonz?)

Windows 7, Python 2.7.8, Git Bash.

pew 0.1.16 installed by pip (pip install --upgrade pew), crashes:

$ pew ls
Traceback (most recent call last):
  File "c:\python27\lib\runpy.py", line 162, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "c:\python27\lib\runpy.py", line 72, in _run_code
    exec code in run_globals
  File "c:\Python27\Scripts\pew.exe\__main__.py", line 5, in <module>
  File "c:\python27\lib\site-packages\pew\__init__.py", line 11, in <module>
    from . import pew
  File "c:\python27\lib\site-packages\pew\pew.py", line 21, in <module>
    from pythonz.commands.install import InstallCommand
  File "c:\python27\lib\site-packages\pythonz\commands\install.py", line 5, in <module>
    from pythonz.installer.pythoninstaller import PythonInstaller
  File "c:\python27\lib\site-packages\pythonz\installer\pythoninstaller.py", line 19, in <module>
    from pythonz.downloader import Downloader, DownloadError, validate_sha256
  File "c:\python27\lib\site-packages\pythonz\downloader.py", line 2, in <module>
    from mmap import mmap, PROT_READ
ImportError: cannot import name PROT_READ

The same with other commands (version, new, ...).

It works when downgraded to pew 0.1.15 through pip install pew==0.1.15.

Support for hooks

Currently, pew lacks hooks like virtualenvwrapper's

http://virtualenvwrapper.readthedocs.org/en/latest/scripts.html

The problem is that some of those hooks/scripts aren't executed, but are instead sourced.

Clearly, pew cannot source arbitrary scripts.

I've never actively used the hooks, so I need suggestions from people who have to design the feature.

As I wrote in the readme:

This could be handled by (instead of getting back a script to be sourced) getting back an environment/list of key-values to be applied when invoking inve

The format of this file could be an ini-file, or it could be something fancier like valid python code.

In this case the hook could expose a dictionary (just like os.environ)

....and this would be actually closer to the idea of sourcing a script from a process written in the same language as the script, allowing it to produce side-effects.

If going this way, we should pick a way to load the code... import, eval (or something like the stevedore plugins?).

IMHO import is the cleaner and simpler (to debug) alternative, but I want to hear some opinions.

Finally: actual-scripts and to-be-sourced-scripts might need to be clearly differentiated.

Ideas?

iPython and symlink from .virtualenvs to .local/share/virtualenvs causes: WARNING: Attempting to work in a virtualenv. If you ...

I encountered an issue with iPython running inside a virtualenv freshly made by pew. Note that this might be an iPython problem...

The symptoms are the following warning when invoking iPython from within the virtualenv:

WARNING: Attempting to work in a virtualenv. If you encounter problems, please install IPython inside the virtualenv.

The following is my analysis of what may be wrong...

When pew creates the first virtualenv for a Linux user it creates a symlink from ~/.virtualenvs to ~/.local/share/virtualenvs: https://github.com/berdario/invewrapper/blob/master/invewrapper/invewrapper.py#L80

That means that pip installed packages will have entry scripts which use the .local/share version of python. See the first (#!) line below (which is being run from within the virtualenv):

tcorbettclark@cmed1:~$ cat $(which ipython)
#!/home/tcorbettclark/.local/share/virtualenvs/ice/bin/python
# EASY-INSTALL-ENTRY-SCRIPT: 'ipython==1.1.0','console_scripts','ipython'
__requires__ = 'ipython==1.1.0'
import sys
from pkg_resources import load_entry_point

if __name__ == '__main__':
    sys.exit(
        load_entry_point('ipython==1.1.0', 'console_scripts', 'ipython')()
    )

However the VIRTUAL_ENV environment variable will not use the followed symlink. See the last line of:

tcorbettclark@cmed1:~$ python
Python 2.7.3 (default, Sep 26 2013, 16:35:25) 
[GCC 4.7.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> os.environ['VIRTUAL_ENV']
'/home/tcorbettclark/.virtualenvs/ice'

The problem is that iPython uses string comparison to detect whether it is running inside a virtualenv or not: https://github.com/ipython/ipython/blob/5bf4949fbd30de6211226e4b27e8680c4b199fc9/IPython/core/interactiveshell.py#L719. These paths are not a prefix of one another because one has the expanded symlink and one does not.

My workaround was to stop pew from creating the symlink by manually creating the ~/.virtualenvs directory before creating the very first virtualenv i.e.: mkdir -p .virtualenvs.

Can't create virtualenv with Python 3.5.0

Currently, I'm using Ubuntu 15.10 with latest pew (0.1.18).
I'm install CPython 3.5.0 with pythonz and create virtualenv with Python 3.5.0 but it's raise this message

pew new --python=$(pythonz locate 3.5.0) mailman                                                                             
Running virtualenv with interpreter /home/mrtux/.pythonz/pythons/CPython-3.5.0/bin/python3
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/enum/__init__.py", line 371, in __getattr__
    return cls._member_map_[name]
KeyError: '_convert'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/virtualenv.py", line 23, in <module>
    import subprocess
  File "/home/mrtux/.pythonz/pythons/CPython-3.5.0/lib/python3.5/subprocess.py", line 364, in <module>
    import signal
  File "/home/mrtux/.pythonz/pythons/CPython-3.5.0/lib/python3.5/signal.py", line 8, in <module>
    _IntEnum._convert(
  File "/usr/local/lib/python2.7/dist-packages/enum/__init__.py", line 373, in __getattr__
    raise AttributeError(name)
AttributeError: _convert
Error while trying to remove the /home/mrtux/DevProjects/virtualenvs/mailman env: 
No such file or directory

Error with sitepackages_dir and toggleglobalsitepackages

I'm on OS X 10.9, with python installed via homebrew. Within a virtualenv, the toggleglobalsitepackages and sitepackages_dir commands give me this error:

isbadawi@astaire:~$ pew toggleglobalsitepackages
Traceback (most recent call last):
  File "<string>", line 1, in <module>
AttributeError: 'module' object has no attribute 'sysconfig'
Traceback (most recent call last):
  File "/usr/local/bin/pew", line 9, in <module>
    load_entry_point('pew==0.1.6', 'console_scripts', 'pew')()
  File "/usr/local/lib/python2.7/site-packages/invewrapper/invewrapper.py", line 438, in pew
    return command()
  File "/usr/local/lib/python2.7/site-packages/invewrapper/invewrapper.py", line 300, in toggleglobalsitepackages_cmd
    site = sitepackages_dir()
  File "/usr/local/lib/python2.7/site-packages/invewrapper/invewrapper.py", line 245, in sitepackages_dir
    print(distutils.sysconfig.get_python_lib())'])
  File "/usr/local/lib/python2.7/site-packages/invewrapper/invewrapper.py", line 57, in shell
    return check_output(*args).decode(locale.getlocale()[1]).strip()
  File "/usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 575, in check_output
    raise CalledProcessError(retcode, cmd, output=output)
subprocess.CalledProcessError: Command '['python', '-c', 'import distutils; print(distutils.sysconfig.get_python_lib())']' returned non-zero exit status 1

It doesn't copy pip to non-default python virtual environments, so ends up using wrong (global) pip for installs.

I'm using Ubuntu 12.04.3 server
I've installed pip (globally) via sudo apt-get install python-pip
I've installed pypy (via sudo apt-get install pypy)

I create a new environment:

grickert@ubuntu:~$ pew new --python=pypy test2
Running virtualenv with interpreter /usr/bin/pypy
New python executable in test2/bin/pypy
Installing setuptools, pip...done.
Launching subshell in virtual environment. Type 'exit' or 'Ctrl+D' to return.

I then try to install twisted python in the new environment (my prompt includes the virtual environment name)

test2 grickert@ubuntu:~$pip install twisted
Downloading/unpacking twisted
Running setup.py egg_info for package twisted
[snip]
error: could not create '/usr/local/lib/python2.7/dist-packages/twisted': Permission denied
[snip]

Here is my path (when I'm in the virutal env)
test2 grickert@ubuntu:~$ echo $PATH
/home/grickert/.local/share/virtualenvs/test2/bin:/usr/lobal/sbin:
[snip]

In my ~/.virtualenvs/test2/bin directory, there is no pip, so it's using the global one for the install.

I'm not sure if the issue is with invewrapper, twisted, pypy or me (most likely), but thought I'd start here.

If I just create a new environment with my default python interpreter, everything works.

Upgrade pip

[vincent@vincent crossbar]$ pew new test
New python executable in test/bin/python
Installing setuptools, pip...done.
Launching subshell in virtual environment. Type 'exit' or 'Ctrl+D' to return.
(test) [vincent@vincent crossbar]$ pip install pew
You are using pip version 6.0.3, however version 6.0.8 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.

I don't know how pip is installed during the creation of the env but maybe you could run pip install --upgrade pip automatically, couldn't you? And so could you with setuptools.

Cannot use without sudo

I am using Arch Linux x64, installing with sudo pip install pew. I cannot install without sudo.

But now I cannot use pew without sudo either. I get the following error:

Traceback (most recent call last):
  File "/usr/bin/pew", line 7, in <module>
    from pew.pew import pew
ImportError: No module named 'pew.pew'

Python 3.4.2 everywhere

I can't create an env with Python 2:

[vincent@vincent crossbarwww]$ python
Python 3.4.2 |Continuum Analytics, Inc.| (default, Oct 21 2014, 17:40:08) 
[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> 
[vincent@vincent crossbarwww]$ python2.7
Python 2.7.5 (default, Feb 19 2014, 13:47:40) 
[GCC 4.8.2 20131212 (Red Hat 4.8.2-7)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> 
[vincent@vincent crossbarwww]$ pew new -p python2.7 test
Running virtualenv with interpreter /usr/bin/python2.7
New python executable in test/bin/python2.7
Also creating executable in test/bin/python
Installing setuptools, pip...done.
Launching subshell in virtual environment. Type 'exit' or 'Ctrl+D' to return.
(test) [vincent@vincent crossbarwww]$ python -V
Python 3.4.2 :: Continuum Analytics, Inc.
(test) [vincent@vincent crossbarwww]$

Thanks.

Rename to pew

I really like pew as a command line interface but don't quite get why the package is named "invewrapper". Any chance to rename it to pew? Seems like "pew" is not registered on PyPI..

"invewrapper" could become a transitional package depending on pew.

Start supporting pyvenv

Supporting pyvenv (the stdlib venv module) might mean that in a remote future, where Python <3.4 will have disappeared, the virtualenv dependency will be redundant.

Due to this bug, to use venv on Ubuntu/Debian it'd require a preemptive check if ensurepip is available with python -c 'import ensurepip' (python -m ensurepip won't work due to a debian patch)

Still, before implementing it, it's better to wait until some bugs will have been ironed out

sitepackages_dir doesn't work on windows

> sitepackages_dir.exe
Traceback (most recent call last):
  File "<string>", line 1, in <module>
AttributeError: 'module' object has no attribute 'sysconfig'
Traceback (most recent call last):
  File "C:\Python27\Scripts\sitepackages_dir-script.py", line 9, in <module>
    load_entry_point('invewrapper==0.1.3', 'console_scripts', 'sitepackages_dir')()
  File "C:\Python27\lib\site-packages\invewrapper\invewrapper.py", line 242, in sitepackages_dir_cmd
    print(sitepackages_dir())
  File "C:\Python27\lib\site-packages\invewrapper\invewrapper.py", line 204, in sitepackages_dir
    print(distutils.sysconfig.get_python_lib())'])
  File "C:\Python27\lib\site-packages\invewrapper\invewrapper.py", line 21, in shell
    return check_output(*args).decode(locale.getlocale()[1]).strip()
  File "C:\Python27\lib\subprocess.py", line 544, in check_output
    raise CalledProcessError(retcode, cmd, output=output)
subprocess.CalledProcessError: Command '['python', '-c', 'import distutils; print(distutils.sysconfig.get_python_lib())']' returned non-zero exit status 1

I fear this might be a python bug

Tab-completion breaks in zsh with $(pew shell_config)

After running source $(pew shell_config) in either my .zshrc, .zprofile, or on the command-line, tab-completion goes a bit wonky.

Before and after running the shell_config (notice how ls gets duplicated after pressing tab):

shell_config_bug

I suspect that it might be a bad interaction with one of prezto's runtime modules.

Document How To Activate the Environmnet

How would I "set up your terminal emulator to launch your shell as a login shell"?

I use the fish shell, and I realize I need to do something like fish --login to start a login shell, but how would I make sure that pew use /usr/local/bin/fish --login instead of /usr/local/bin/fish?

Could pew add the env name in the $PS1?

One thing that I like with pew is to be able to exist the virtualenv using ctrl+D, one thing that bothers me is that I don't know in which venv I am.

Would it be possible to add a |venv_name| before the PS1 so that it is possible to know in which venv we currently are with pew?

pew new fails if non-PyPI downloads are required

Steps to reproduce:

  • pew new test_example -i pytidylib==0.2.1

What should happen:

  • Create new VE called "test_example"
  • Installing pytidylib version 0.2.1 (which happens to be hosted externally)

What happens instead:

  • New VE created
  • pytidylib install fails to install with the following error:
New python executable in test_example/bin/python
Installing setuptools, pip...done.
Downloading/unpacking pytidylib==0.2.1
  Could not find a version that satisfies the requirement pytidylib==0.2.1 (from versions: 0.1.2)
  Some externally hosted files were ignored (use --allow-external to allow).
Cleaning up...
No distributions matching the version for pytidylib==0.2.1
Storing debug log for failure in /home/username/.pip/pip.log

Notes:

  • pip install pytidylib==0.2.1 inside the new VE also fails, with the same error message
  • pew new -r requirements.txt also fails (if the file contains the failing requirement)
  • pip --version returns pip 1.5.4 from /home/username/.virtualenvs/test_example/local/lib/python2.7/site-packages (python 2.7)
  • pip install --help reveals the following:
  --allow-external <package>  Allow the installation of externally hosted files
  --allow-all-external        Allow the installation of all externally hosted files
  --allow-unverified <package>
                             Allow the installation of insecure and unverifiable files

There are of course a million other pip options. Perhaps we need a way to pass "generic" pip options?

Workaround:

Download the tar.gz yourself and pip install it directly. pip install of URLs also works (pip install http://cloud.github.com/downloads/countergram/pytidylib/pytidylib-0.2.1.tar.gz). This workaround is scriptable and the URL method can be used in a pip requirements file if you label the requirement (add http://cloud.github.com/downloads/countergram/pytidylib/pytidylib-0.2.1.tar.gz#egg=pytidylib to your requirements file). The #egg label is not strictly required but helps pip recognise the library.

Cannot uninstall pew from pip --user install

Steps to reproduce:

  • pip install --user setuptools [1]
  • pip install --user pew
  • pip uninstall pew

What should happen:

pew is installed then uninstalled.

What happens instead:

pew is installed. When attempting uninstallation:

Can't uninstall 'pew'. No files were found to uninstall.

Notes:

  • This also prevents upgrade attempts but I can't reproduce this at the moment.
  • This procedure works with other Python packages (e.g. youtube-dl)
  • This procedure works in a virtualenv.

Footnotes:

[1] This is required for the installation to work, otherwise pew complains that it requires setuptools and aborts the installation attempt, even if setuptools is already installed via apt. I don't think this is a bug (but I'm not sure), probably required so pew can detect setuptools in its "environment" or it requires a newer version of setuptools than what is currently in the Ubuntu repos.

Workaround:

Manually delete files listed in .local/lib/python2.7/site-packages/pew-0.1.12-py2.7.egg-info/installed-files.txt

Duplicated $PATH entries

$ echo $PATH
/home/hen/.local/bin:/home/hen/.opam/system/bin:/usr/lib/jvm/jdk1.7.0_21/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games

$ pew workon python33
Launching subshell in virtual environment. Type 'exit' or 'Ctrl+D' to return.

(python33) $ echo $PATH
/home/hen/.local/bin:/home/hen/.opam/system/bin:/usr/lib/jvm/jdk1.7.0_21/bin:/home/hen/miniconda3/envs/python33/bin:/home/hen/.local/bin:/home/hen/.opam/system/bin:/usr/lib/jvm/jdk1.7.0_21/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games

This is causing me problems, since ~/.local/bin comes before $WORKON_HOME (~/miniconda3/envs). This is unrelated to the fact that I'm trying to use pew with conda; the same thing happens on an entirely new virtualenv.

"sudo easy_install pew" triggers SandboxViolation (but "sudo pip install pew" works)

Steps to reproduce:

  • sudo easy_install pew

What should happen:

  • pew installs in appropriate locations for root user (so that I could run "sudo pew ..." thereafter)

What happens instead:

  • pew attempts to create /root/.local
  • Triggers SandboxViolation

Notes:

  • Not sure if this should be reported to setuptools team as well?
user@belisama:/opt/python2.7/bin$ sudo easy_install pew  
Searching for pew  
Reading https://pypi.python.org/simple/pew/  
Best match: pew 0.1.9  
Downloading https://pypi.python.org/packages/source/p/pew/pew-0.1.9.tar.gz#md5=90a82400074b50a9e73c3045ed9ac217  
Processing pew-0.1.9.tar.gz  
Writing /tmp/easy_install-D8noCj/pew-0.1.9/setup.cfg  
Running pew-0.1.9/setup.py -q bdist_egg --dist-dir /tmp/easy_install-D8noCj/pew-0.1.9/egg-dist-tmp-wGczyO  
error: SandboxViolation: mkdir('/root/.local', 511) {}  

The package setup script has attempted to modify files on your system  
that are not within the EasyInstall build area, and has been aborted.  

This package cannot be safely installed by EasyInstall, and may not  
support alternate installation locations even if you run its setup  
script by hand.  Please inform the package's author and the EasyInstall  

Streamline packaging (for deb and maybe rpm in the future?), find deb maintainer

See the original comment

Even if doing things "the hard way" is often instructive, I just stumbled upon (again!) this project to help create proper deb/rpm packages

Along with that, there's also dh-virtualenv, which might('ve helped)/help with avoiding to repackage the different dependencies (virtualenv-clone, pathlib)

This has really low priority, and I don't plan to spend any effort on it anytime soon, but I just want to note this down, so when the time is due me (or someone else) might have a cue about where to start

Display the env name in the terminal

Hi!

Currently, the env name is not displayed in the terminal as virtualenv does. It's hard to know if an env is activated, on which we are working... This script seems to do the job:

function venv_ps1(){
    test -n "$VIRTUAL_ENV" && echo "($(basename "$VIRTUAL_ENV")) "
}
PS1="$(venv_ps1)$PS1"

From here.

pythonz-bd==1.10.2 install problem

Hi @berdario! No issues on your pythonz, so posting here:

$ pip install pythonz-bd==1.10.2
Collecting pythonz-bd==1.10.2
  Using cached pythonz-bd-1.10.2.tar.gz
    Complete output from command python setup.py egg_info:
    error in pythonz-bd setup command: Invalid environment marker: python_version>="3.5"
$ pip install pythonz-bd==1.10.1
# success

This is on Python 2.7.6. Is that version too old to handle this 3.5 version spec thing maybe? I'm not sure what the problem is.

The 1.10.1 workaround seems like it will work for me, but wanted to let you know in case others encounter this.

Cannot activate environment with pew on MacOs Yosemite

Hi there,
I installed pew on Yosemite using "pip install pew".
I cannot activate environments (wether they ware created with pew or with virtualenvwrapper) and have the "The environment doesn't seem to be activated" message.

I looked at the instructions given here, but, to be honest, I didn't really understand it.

I tried to put my "export PATH= ...." in a .zsh_proflie, but it didn't change anything.

Can anybody help?

Thanks in advance!

Display ($VIRTUALENV) in PS1

This may be a silly request, but I was blocked from moving from virtualenvwrapper by the absence of the brackets around the active venv on the commandline in pew :)

Is there a way to drop in our own environment variable somehow.

AttributeError: 'NoneType' object has no attribute 'rfind'

Bug reproduction:

$ pew new -i python-heatclient heat-test
New python executable in heat-test/bin/python2.7
Not overwriting existing python script heat-test/bin/python (you must use heat-test/bin/python2.7)
Installing setuptools, pip, wheel...done.
Collecting python-heatclient
  Using cached python_heatclient-0.6.0-py2.py3-none-any.whl
Collecting oslo.serialization>=1.4.0 (from python-heatclient)
  Using cached oslo.serialization-1.8.0-py2.py3-none-any.whl
Collecting python-swiftclient>=2.2.0 (from python-heatclient)
  Using cached python_swiftclient-2.5.0-py2.py3-none-any.whl
Collecting oslo.i18n>=1.5.0 (from python-heatclient)
  Using cached oslo.i18n-2.3.0-py2.py3-none-any.whl
Collecting pbr<2.0,>=0.11 (from python-heatclient)
  Using cached pbr-1.4.0-py2.py3-none-any.whl
Collecting argparse (from python-heatclient)
  Using cached argparse-1.3.0-py2.py3-none-any.whl
Collecting requests>=2.5.2 (from python-heatclient)
  Using cached requests-2.7.0-py2.py3-none-any.whl
Collecting oslo.utils>=1.4.0 (from python-heatclient)
  Using cached oslo.utils-2.2.0-py2.py3-none-any.whl
Collecting iso8601>=0.1.9 (from python-heatclient)
  Using cached iso8601-0.1.10.tar.gz
Collecting six>=1.9.0 (from python-heatclient)
  Using cached six-1.9.0-py2.py3-none-any.whl
Collecting PyYAML>=3.1.0 (from python-heatclient)
Collecting Babel>=1.3 (from python-heatclient)
  Using cached Babel-2.0.tar.gz
Collecting PrettyTable<0.8,>=0.7 (from python-heatclient)
  Using cached prettytable-0.7.2.tar.bz2
Collecting python-keystoneclient>=1.3.0 (from python-heatclient)
  Using cached python_keystoneclient-1.6.0-py2.py3-none-any.whl
Collecting msgpack-python>=0.4.0 (from oslo.serialization>=1.4.0->python-heatclient)
  Using cached msgpack-python-0.4.6.tar.gz
Collecting pytz>=2013.6 (from oslo.serialization>=1.4.0->python-heatclient)
  Using cached pytz-2015.4-py2.py3-none-any.whl
Collecting futures>=2.1.3 (from python-swiftclient>=2.2.0->python-heatclient)
  Using cached futures-3.0.3-py2-none-any.whl
Collecting monotonic>=0.1 (from oslo.utils>=1.4.0->python-heatclient)
  Using cached monotonic-0.3.tar.gz
Collecting netifaces>=0.10.4 (from oslo.utils>=1.4.0->python-heatclient)
  Using cached netifaces-0.10.4.tar.gz
Collecting netaddr>=0.7.12 (from oslo.utils>=1.4.0->python-heatclient)
  Using cached netaddr-0.7.15-py2.py3-none-any.whl
Collecting debtcollector>=0.3.0 (from oslo.utils>=1.4.0->python-heatclient)
  Using cached debtcollector-0.7.0-py2.py3-none-any.whl
Collecting stevedore>=1.3.0 (from python-keystoneclient>=1.3.0->python-heatclient)
  Using cached stevedore-1.7.0-py2.py3-none-any.whl
Collecting oslo.config>=1.11.0 (from python-keystoneclient>=1.3.0->python-heatclient)
  Using cached oslo.config-2.2.0-py2.py3-none-any.whl
Collecting wrapt>=1.7.0 (from debtcollector>=0.3.0->oslo.utils>=1.4.0->python-heatclient)
  Using cached wrapt-1.10.5.tar.gz
Building wheels for collected packages: iso8601, Babel, PrettyTable, msgpack-python, monotonic, netifaces, wrapt
  Running setup.py bdist_wheel for iso8601
  Stored in directory: /home/lucas_cimon/.cache/pip/wheels/3f/7c/d1/fddaaceaa3ebe55637ccc89faff444d8a6c43011fd593715a5
  Running setup.py bdist_wheel for Babel
  Stored in directory: /home/lucas_cimon/.cache/pip/wheels/15/b9/ae/1b8f9a7c0e6e06a27d0bd8e6de2f3d82292c9b00e5d0a6dd45
  Running setup.py bdist_wheel for PrettyTable
  Stored in directory: /home/lucas_cimon/.cache/pip/wheels/41/46/ec/ec86e65e50e9f4be52547a3bedd46077e7414c53d2ed0418fd
  Running setup.py bdist_wheel for msgpack-python
  Stored in directory: /home/lucas_cimon/.cache/pip/wheels/f3/97/a5/dd6e3b680de10b689464c44bc211239d1fe54bd296ff860897
  Running setup.py bdist_wheel for monotonic
  Stored in directory: /home/lucas_cimon/.cache/pip/wheels/0f/cf/72/297c6d473b3f94a80084ed52548c13bea1acf37ca543961393
  Running setup.py bdist_wheel for netifaces
  Stored in directory: /home/lucas_cimon/.cache/pip/wheels/32/42/e1/c70ed63c260bddfedf2472663153d03a17ee650b512273991d
  Running setup.py bdist_wheel for wrapt
  Stored in directory: /home/lucas_cimon/.cache/pip/wheels/1d/bd/59/f8ec76ecb9134b951bbe216327920b891acc35847024a06b50
Successfully built iso8601 Babel PrettyTable msgpack-python monotonic netifaces wrapt
Installing collected packages: pbr, msgpack-python, monotonic, pytz, Babel, six, oslo.i18n, netifaces, netaddr, wrapt, debtcollector, iso8601, oslo.utils, oslo.serialization, futures, requests, python-swiftclient, argparse, PyYAML, PrettyTable, stevedore, oslo.config, python-keystoneclient, python-heatclient
Successfully installed Babel-2.0 PrettyTable-0.7.2 PyYAML-3.11 argparse-1.3.0 debtcollector-0.7.0 futures-3.0.3 iso8601-0.1.10 monotonic-0.3 msgpack-python-0.4.6 netaddr-0.7.15 netifaces-0.10.4 oslo.config-2.2.0 oslo.i18n-2.3.0 oslo.serialization-1.8.0 oslo.utils-2.2.0 pbr-1.4.0 python-heatclient-0.6.0 python-keystoneclient-1.6.0 python-swiftclient-2.5.0 pytz-2015.4 requests-2.7.0 six-1.9.0 stevedore-1.7.0 wrapt-1.10.5
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/home/lucas_cimon/.local/lib/python2.7/site-packages/pew/pew.py", line 490, in prevent_path_errors
    if 'VIRTUAL_ENV' in os.environ and not check_path():
  File "/home/lucas_cimon/.local/lib/python2.7/site-packages/pew/_utils.py", line 39, in check_path
    return parent(parent(which('python'))) == os.environ['VIRTUAL_ENV']
  File "/usr/lib/python2.7/posixpath.py", line 129, in dirname
    i = p.rfind('/') + 1
AttributeError: 'NoneType' object has no attribute 'rfind'

$ pew workon heat-test
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/home/lucas_cimon/.local/lib/python2.7/site-packages/pew/pew.py", line 490, in prevent_path_errors
    if 'VIRTUAL_ENV' in os.environ and not check_path():
  File "/home/lucas_cimon/.local/lib/python2.7/site-packages/pew/_utils.py", line 39, in check_path
    return parent(parent(which('python'))) == os.environ['VIRTUAL_ENV']
  File "/usr/lib/python2.7/posixpath.py", line 129, in dirname
    i = p.rfind('/') + 1
AttributeError: 'NoneType' object has no attribute 'rfind'

I already tried to pip2.7 install --user --upgrade pew.

Some more info (I'm using Cygwin):

$ python --version
Python 2.7.9
$ pew version
0.1.14
$ uname -a
CYGWIN_NT-6.3 XXXXXXX 1.7.35(0.287/5/3) 2015-03-04 12:09 x86_64 Cygwin

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.