Skip to content
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
23 changes: 16 additions & 7 deletions .appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,23 @@
image: Visual Studio 2017
build: off
test: off
cache:
- '%LOCALAPPDATA%\pip\Cache'

skip_branch_with_pr: true
branches:
only:
- master

environment:
matrix:
- PYTHON: "C:\\Python27-x64"
- PYTHON: "C:\\Python35-x64"
- PYTHON: "C:\\Python36-x64"
- PYTHON: "C:\\Python37-x64"

install:
- "%PYTHON%\\python.exe -m pip install pytest"
- "%PYTHON%\\python.exe setup.py --quiet clean develop"

build: off
- "%PYTHON%\\python.exe -m pip install -U pip"
- "%PYTHON%\\python.exe -m pip install tox codecov"

test_script:
- "%PYTHON%\\python.exe -m pytest"
- "%PYTHON%\\python.exe -m tox"
- "%PYTHON%\\python.exe -m tox -e codecov"
14 changes: 7 additions & 7 deletions .codecov.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
comment: false
coverage:
status:
patch:
default:
target: '100'
project:
default:
target: '100'
status:
patch:
default:
target: '80'
project:
default:
target: '80'
15 changes: 14 additions & 1 deletion .coveragerc
Original file line number Diff line number Diff line change
@@ -1,10 +1,23 @@
[run]
data_file = tests/coverage/.coverage
branch = True
parallel = True
source =
userpath
tests
branch = True
omit =
userpath/__main__.py
userpath/cli.py

[paths]
userpath =
userpath
/home/userpath/userpath
c:\*\userpath\userpath
tests =
tests
/home/userpath/tests
c:\*\userpath\tests

[report]
exclude_lines =
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
.cache/
.coverage
.idea/
.tox/
.vscode/
userpath.egg-info/
build/
Expand Down
33 changes: 16 additions & 17 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,22 @@
dist: xenial
language: python

services:
- docker

branches:
only:
- master

matrix:
include:
- python: 2.7
env: TOXENV=py27
- python: 3.5
env: TOXENV=py35
- python: 3.6
env: TOXENV=py36
- python: 3.7
dist: xenial
sudo: true
env: TOXENV=py37
- python: pypy2.7-5.8.0
env: TOXENV=pypy
- python: pypy3.5-5.8.0
env: TOXENV=pypy3
include:
- python: 2.7
env: TOXENV=py27
- python: 3.7
env: TOXENV=py37

install:
- pip install tox
- pip install tox codecov

script: tox
script:
- tox -e $TOXENV,coverage,codecov
44 changes: 27 additions & 17 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,25 +1,37 @@
userpath
========

.. image:: https://img.shields.io/pypi/v/userpath.svg?style=flat-square
:target: https://pypi.org/project/userpath
:alt: Latest PyPI version

.. image:: https://img.shields.io/travis/ofek/userpath/master.svg?style=flat-square
.. image:: https://img.shields.io/travis/ofek/userpath/master.svg?logo=travis&label=Travis%20CI
:target: https://travis-ci.org/ofek/userpath
:alt: Travis CI
:alt: CI - Travis

.. image:: https://img.shields.io/appveyor/ci/ofek/userpath/master.svg?style=flat-square
.. image:: https://img.shields.io/appveyor/ci/ofek/userpath/master.svg?logo=appveyor&label=AppVeyor
:target: https://ci.appveyor.com/project/ofek/userpath
:alt: AppVeyor CI
:alt: CI - AppVeyor

.. image:: https://img.shields.io/codecov/c/github/ofek/userpath/master.svg?logo=data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTAiIGhlaWdodD0iNDgiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+CgogPGc+CiAgPHRpdGxlPmJhY2tncm91bmQ8L3RpdGxlPgogIDxyZWN0IGZpbGw9Im5vbmUiIGlkPSJjYW52YXNfYmFja2dyb3VuZCIgaGVpZ2h0PSI0MDIiIHdpZHRoPSI1ODIiIHk9Ii0xIiB4PSItMSIvPgogPC9nPgogPGc+CiAgPHRpdGxlPkxheWVyIDE8L3RpdGxlPgogIDxwYXRoIGlkPSJzdmdfMSIgZmlsbC1ydWxlPSJldmVub2Rk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jUgLTcuMzE0LC0xNy41NTFjLTQuNzE2LC00LjY3OSAtMTAuOTkxLC03LjI1NSAtMTcuNjcyLC03LjI1NSIvPgogPC9nPgo8L3N2Zz4=&label=Codecov
:target: https://codecov.io/github/ofek/userpath?branch=master
:alt: Codecov
|
.. image:: https://img.shields.io/pypi/pyversions/userpath.svg?logo=python&label=Python&logoColor=gold
:target: https://pypi.org/project/userpath
:alt: PyPI - Supported Python versions

.. image:: https://img.shields.io/pypi/pyversions/userpath.svg?style=flat-square
.. image:: https://img.shields.io/pypi/v/userpath.svg?logo=python&label=PyPI&logoColor=gold
:target: https://pypi.org/project/userpath
:alt: Supported Python versions
:alt: PyPI - Version

.. image:: https://img.shields.io/pypi/l/userpath.svg?style=flat-square
.. image:: https://img.shields.io/pypi/dm/userpath.svg?color=blue&label=Downloads&logo=python&logoColor=gold
:target: https://pypi.org/project/userpath
:alt: PyPI - Downloads
|
.. image:: https://img.shields.io/badge/License-MIT%2FApache--2.0-9400d3.svg
:target: https://choosealicense.com/licenses
:alt: License
:alt: License: MIT/Apache-2.0

.. image:: https://img.shields.io/badge/say-thanks-ff69b4.svg
:target: https://saythanks.io/to/ofek
:alt: Say Thanks

-----

Expand All @@ -38,18 +50,16 @@ Installation

userpath is distributed on `PyPI <https://pypi.org>`_ as a universal
wheel and is available on Linux/macOS and Windows and supports
Python 2.6-2.7/3.3+ and PyPy.

.. code-block:: bash
Python 2.7/3.6+ and PyPy.
::

$ pip install userpath

Commands
--------

Only 3!

.. code-block:: bash
::

$ userpath -h
Usage: userpath [OPTIONS] COMMAND [ARGS]...
Expand Down
2 changes: 2 additions & 0 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
coverage
pytest
1 change: 0 additions & 1 deletion requirements.txt

This file was deleted.

15 changes: 5 additions & 10 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@
with open('README.rst', 'r', encoding='utf-8') as f:
readme = f.read()

REQUIRES = ['click']
REQUIRES = ['click', 'distro']

setup(
name='userpath',
version=version,
description='Cross-platform tool for adding locations to the user PATH, no sudo/runas required!',
description='Cross-platform tool for adding locations to the user PATH, no elevated privileges required!',
long_description=readme,
author='Ofek Lev',
author_email='ofekmeister@gmail.com',
Expand All @@ -41,20 +41,15 @@
'License :: OSI Approved :: Apache Software License',
'Natural Language :: English',
'Operating System :: OS Independent',
'Programming Language :: Python :: 2.6',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3.3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: Implementation :: CPython',
'Programming Language :: Python :: Implementation :: PyPy'
'Programming Language :: Python :: Implementation :: PyPy',
],

install_requires=REQUIRES,
tests_require=['coverage', 'pytest'],

packages=find_packages(),
packages=['userpath'],
entry_points={
'console_scripts': [
'userpath = userpath.cli:userpath',
Expand Down
81 changes: 81 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
import os
import subprocess
from itertools import chain

import pytest

from userpath.shells import SHELLS

HERE = os.path.dirname(os.path.abspath(__file__))
ROOT = os.path.dirname(HERE)


def pytest_configure(config):
# pytest will emit warnings if these aren't registered ahead of time
for shell in sorted(SHELLS):
config.addinivalue_line('markers', '{shell}: marker to only run tests for {shell}'.format(shell=shell))


@pytest.fixture(scope='class')
def shell_test(request):
if 'SHELL' in os.environ:
yield
else:
compose_file = os.path.join(HERE, 'docker', 'docker-compose.yaml')
shell_name = request.module.SHELL_NAME
dockerfile = getattr(request.cls, 'DOCKERFILE', 'debian')
container = '{}-{}'.format(shell_name, dockerfile)

tox_env = os.environ['TOX_ENV_NAME']
python_version = '.'.join(tox_env.replace('py', ''))

try:
os.environ['SHELL'] = shell_name
os.environ['DOCKERFILE'] = dockerfile
os.environ['PYTHON_VERSION'] = python_version
subprocess.check_call(['docker-compose', '-f', compose_file, 'up', '-d', '--build'])

# Python gets really upset when compiled files from different paths and/or platforms are encountered
clean_package()

yield lambda test_name: subprocess.Popen(
[
'docker',
'exec',
'-w',
'/home/userpath',
container,
'coverage',
'run',
'-m',
'pytest',
'tests/{}::{}::{}'.format(os.path.basename(request.module.__file__), request.node.name, test_name),
],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
)
finally:
# Clean up for the next tox invocation
clean_package()

# Tear down without checking for errors
subprocess.call(['docker-compose', '-f', compose_file, 'down'])
del os.environ['SHELL']
del os.environ['DOCKERFILE']
del os.environ['PYTHON_VERSION']


def clean_package():
to_delete = []
walker = os.walk(ROOT)

top = next(walker)
top[1].remove('.tox')

for root, dirs, files in chain((top,), walker):
for f in files:
if f.endswith('.pyc'):
to_delete.append(os.path.join(root, f))

for f in to_delete:
os.remove(f)
3 changes: 3 additions & 0 deletions tests/coverage/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Ignore this directory used for coverage aggregation
*
!.gitignore
10 changes: 10 additions & 0 deletions tests/docker/debian
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
ARG PYTHON_VERSION
FROM python:${PYTHON_VERSION}-stretch

RUN apt-get update \
&& apt-get --no-install-recommends -y install fish zsh

COPY requirements.txt /
RUN pip install -r requirements.txt

CMD ["tail", "-f", "/dev/null"]
15 changes: 15 additions & 0 deletions tests/docker/docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
version: '3'

services:

userpath:
container_name: ${SHELL}-${DOCKERFILE}
build:
context: .
dockerfile: ./${DOCKERFILE}
args:
PYTHON_VERSION: ${PYTHON_VERSION}
environment:
- SHELL=${SHELL}
volumes:
- ./../../:/home/userpath
10 changes: 10 additions & 0 deletions tests/docker/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Deps
click
distro

# Test deps
coverage
pytest

# xonsh shell, if we can
xonsh; python_version > '3.0'
Loading