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

Support Python 3.8, 3.9 and 3.10, drop EOL Python versions (2.7, 3.4, 3.5), use GitHub Actions for CI #214

Merged
merged 15 commits into from
Feb 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions .github/workflows/ci-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# NOTE: This name appears in GitHub's Checks API and in workflow's status badge.
name: ci-tests

# Trigger the workflow when:
on:
# A push occurs to one of the matched branches.
push:
branches:
- master
# Or when a pull request event occurs for a pull request against one of the
# matched branches.
pull_request:
branches:
- master

jobs:
tests:
# NOTE: This name appears in GitHub's Checks API.
name: tests
runs-on: ${{ matrix.platform }}
strategy:
matrix:
platform: [ubuntu-latest, windows-latest]
python-version: [3.6, 3.7, 3.8, 3.9, 3.10]
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install tox tox-gh-actions
- name: Test with Tox
run: tox
env:
PLATFORM: ${{ matrix.platform }}
54 changes: 0 additions & 54 deletions .travis.yml

This file was deleted.

8 changes: 4 additions & 4 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ name = "pypi"

[packages]

virtualenv = "==1.11.6"
"virtualenv-clone" = "==0.2.5"
"pythonz-bd" = {"version" = "*", "sys_platform" = "!='win32'" }
virtualenv = ">=1.11"
"virtualenv-clone" = ">=0.2.5"
"pythonz-bd" = {"version" = ">1.10.2", "sys_platform" = "!='win32'" }
"shellingham" = {"version" = "*", "sys_platform" = "=='win32'" }

[dev-packages]

pytest = "==2.6.2"
pytest = "*"
171 changes: 128 additions & 43 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@ Pew - Python Env Wrapper
========================

[![PyPi version](http://img.shields.io/pypi/v/pew.svg)](https://pypi.python.org/pypi/pew)
[![Build Status](https://travis-ci.org/berdario/pew.svg)](https://travis-ci.org/berdario/pew)
[![Build status](https://ci.appveyor.com/api/projects/status/xxe096txh1fuqfag/branch/master?svg=true)](https://ci.appveyor.com/project/berdario/pew/branch/master)
[![CI test status][github-ci-tests-badge]][github-ci-tests-link]
[![PyPi](https://img.shields.io/pypi/format/pew.svg)](https://pypi.python.org/pypi/pew/)

[github-ci-tests-badge]: https://github.com/berdario/pew/workflows/ci-tests/badge.svg
[github-ci-tests-link]: https://github.com/berdario/pew/actions?query=workflow:ci-tests+branch:master

[Releases & changelog](https://github.com/berdario/pew/releases)

Python Env Wrapper is a set of commands to manage multiple [virtual environments](http://pypi.python.org/pypi/virtualenv). 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.
Expand Down Expand Up @@ -67,48 +69,131 @@ 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=pypy -i django myproject
Running virtualenv with interpreter /home/dario/Applications/bin/pypy
New pypy executable in myproject/bin/pypy
Installing distribute..................................................................
.......................................................................................
..................................................................done.
Installing pip................done.
Downloading/unpacking django
Downloading Django-1.5.1.tar.gz (8.0MB):
8.0MB downloaded
Running setup.py egg_info for package django

warning: no previously-included files matching '__pycache__' found under directory '*'
warning: no previously-included files matching '*.py[co]' found under directory '*'
Installing collected packages: django
[SNIP]
Successfully installed django Cleaning up...
~> 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:
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 2.7.3 (b9c3566aa017, May 09 2013, 09:09:14)
[PyPy 2.0.0 with GCC 4.6.3]
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
distribute-0.6.34-py2.7.egg Django-1.5.1-py2.7.egg-info setuptools.pth pip-1.3.1-py2.7.egg
easy-install.pth django
/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
Downloading/unpacking pdbpp
[SNIP]
Successfully installed pdbpp fancycompleter wmctrl pygments pyrepl
Cleaning up...
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
Django==1.5.1
Pygments==1.6
cffi==0.6
distribute==0.6.34
fancycompleter==0.4
pdbpp==0.7.2
pyrepl==0.8.4
wmctrl==0.1
wsgiref==0.1.2
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:
Expand Down Expand Up @@ -216,9 +301,9 @@ Use Pythonz to download and build a Python vm

`usage: pew install [options] version`

To install Python3.5.0
To install Python3.8.0

`pew install 3.5.0`
`pew install 3.8.0`

To install Pypy:

Expand Down Expand Up @@ -372,23 +457,23 @@ Running Tests

The test suite for `pew` uses [tox](http://codespeak.net/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 travis-ci (for unix-like) and appveyor (for windows).
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 py27`
`tox -e py38`

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

`tox -e py27 tests/test_setproject.py`
`tox -e py38 tests/test_setproject.py`

You can also filter them:

`tox -e py34 -- -k workon`
`tox -e py38 -- -k workon`

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

Expand Down
7 changes: 0 additions & 7 deletions appveyor.yml

This file was deleted.

2 changes: 0 additions & 2 deletions pew/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
from __future__ import absolute_import

from . import pew
__all__ = ['pew']
12 changes: 2 additions & 10 deletions pew/_print_utils.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,8 @@
from __future__ import division, print_function

import os
from functools import partial
from math import ceil
try:
from itertools import zip_longest
except ImportError:
from itertools import izip_longest as zip_longest
try:
from shutil import get_terminal_size
except ImportError:
from backports.shutil_get_terminal_size import get_terminal_size
from itertools import zip_longest
from shutil import get_terminal_size

SEP = ' '
L = len(SEP)
Expand Down
21 changes: 3 additions & 18 deletions pew/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,31 +7,16 @@
from collections import namedtuple
from functools import partial, wraps
from pathlib import Path
from tempfile import NamedTemporaryFile as _ntf
try:
from shutil import which
except ImportError:
from shutilwhich import which
from tempfile import NamedTemporaryFile
from shutil import which

py2 = sys.version_info[0] == 2
windows = sys.platform == 'win32'

if py2 or windows:
if windows:
locale.setlocale(locale.LC_CTYPE, '')

encoding = locale.getlocale()[1] or 'ascii'

if py2:
@wraps(_ntf)
def NamedTemporaryFile(mode):
return getwriter(encoding)(_ntf(mode))

def to_unicode(x):
return x.decode(encoding)
else:
NamedTemporaryFile = _ntf
to_unicode = str

def check_path():
parent = os.path.dirname
return parent(parent(which('python'))) == os.environ['VIRTUAL_ENV']
Expand Down
Loading