Completed
Push — init-test ( 3e12e7 )
by Michael
07:46 queued 07:14
created

create_venv()   A

Complexity

Conditions 2

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 1
CRAP Score 4.048

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
c 1
b 0
f 0
dl 0
loc 5
ccs 1
cts 5
cp 0.2
crap 4.048
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
    if not tmp_dir:
10
        tmp_dir = tempfile.mkdtemp()
11
    virtualenv('--no-site-packages', tmp_dir)
12
    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