Completed
Push — pyup-initial-update ( 5e7443 )
by Michael
17:36 queued 17:30
created

create_venv()   A

Complexity

Conditions 2

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
c 0
b 0
f 0
dl 0
loc 5
ccs 5
cts 5
cp 1
crap 2
rs 9.4285
1 3
import os
2 3
import tempfile
3
4 3
from plumbum import local
0 ignored issues
show
Configuration introduced by
The import plumbum could not be resolved.

This can be caused by one of the following:

1. Missing Dependencies

This error could indicate a configuration issue of Pylint. Make sure that your libraries are available by adding the necessary commands.

# .scrutinizer.yml
before_commands:
    - sudo pip install abc # Python2
    - sudo pip3 install abc # Python3
Tip: We are currently not using virtualenv to run pylint, when installing your modules make sure to use the command for the correct version.

2. Missing __init__.py files

This error could also result from missing __init__.py files in your module folders. Make sure that you place one file in each sub-folder.

Loading history...
5 3
from plumbum.cmd import virtualenv
0 ignored issues
show
Configuration introduced by
The import plumbum.cmd could not be resolved.

This can be caused by one of the following:

1. Missing Dependencies

This error could indicate a configuration issue of Pylint. Make sure that your libraries are available by adding the necessary commands.

# .scrutinizer.yml
before_commands:
    - sudo pip install abc # Python2
    - sudo pip3 install abc # Python3
Tip: We are currently not using virtualenv to run pylint, when installing your modules make sure to use the command for the correct version.

2. Missing __init__.py files

This error could also result from missing __init__.py files in your module folders. Make sure that you place one file in each sub-folder.

Loading history...
6
7
8 3
def create_venv(tmp_dir=None):
9 3
    if not tmp_dir:
10 3
        tmp_dir = tempfile.mkdtemp()
11 3
    virtualenv('--no-site-packages', tmp_dir)
12 3
    return tmp_dir
13
14
15 3
def install(package_name, venv_dir):
16
    if not os.path.exists(venv_dir):
17
        venv_dir = create_venv()
18
    pip = '%s/bin/pip' % venv_dir
19
    local[pip]('install', package_name)
20