Skip to content
This repository has been archived by the owner on Feb 12, 2021. It is now read-only.

Add installation script #107

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
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
29 changes: 29 additions & 0 deletions configure.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/bin/bash
#
# Copyright (c) 2015 nexB Inc. http://www.nexb.com/ - All rights reserved.
#
################################
# change these variables to customize this script locally
################################
# you can define one or more thirdparty dirs, each prefixed with TPP_DIR
export TPP_DIR_BASE="thirdparty/base"
export TPP_DIR_PROD="thirdparty/prod"
export TPP_DIR_DEV="thirdparty/dev"

# default configurations for dev
CONF_DEFAULT="etc/conf/dev"
#################################

CFG_CMD_LINE_ARGS="$@"

if [ "$1" == "" ]; then
# default for dev conf if not argument is provided
CFG_CMD_LINE_ARGS=$CONF_DEFAULT
fi

CONFIGURE_ROOT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

python2.7 "$CONFIGURE_ROOT_DIR/etc/configure.py" $CFG_CMD_LINE_ARGS
if [ -f "$CONFIGURE_ROOT_DIR/bin/activate" ]; then
source $CONFIGURE_ROOT_DIR/bin/activate
fi
59 changes: 59 additions & 0 deletions etc/conf/base.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
"""
This base config script gets automatically executed for all platforms via
configure.
"""

import sys


"""
Check that we run a supported OS and architecture.
"""

def unsupported(platform):
print('Unsupported OS/platform %r.' % platform)
print('See https://github.com/nexB/scancode-toolkit/ for supported OS/platforms.')
print('Enter a ticket https://github.com/nexB/scancode-toolkit/issues asking for support of your OS/platform combo.')
sys.exit(1)

if sys.maxsize > 2 ** 32:
arch = '64'
else:
arch = '32'

sys_platform = str(sys.platform).lower()
if 'linux' in sys_platform:
os = 'linux'
elif'win32' in sys_platform:
os = 'win'
elif 'darwin' in sys_platform:
os = 'mac'
else:
unsupported(sys_platform)


supported_combos = {
'linux': ['32', '64'],
'win': ['32',],
'mac': ['64',],
}

arches = supported_combos[os]
if arch not in arches:
unsupported(os + arch)


"""
Re/build the license cache on every configure run.
"""

def build_license_cache():
"""
Force a rebuild of the license cache on configure.
"""
from licensedcode import cache
print('* Building license index...')
cache.reindex()


build_license_cache()
10 changes: 10 additions & 0 deletions etc/conf/base.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Base configuration tools
certifi
setuptools
wheel
pip
wincertstore
six

# Self
-e .
37 changes: 37 additions & 0 deletions etc/conf/dev/base.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
"""
This base config script gets automatically executed for all platforms via
configure if the "dev" sub-configuration is specified (which is the default).
"""

import os


def setup_dev_mode():
"""
Create the development mode tag file. In development mode, ScanCode does
not rely on license data to remain untouched and will always check the
license index cache for consistency, rebuilding it if necessary.
"""
from scancode import root_dir
with open(os.path.join(root_dir, 'SCANCODE_DEV_MODE'), 'wb') as sdm:
sdm.write('This is a tag file to notify that ScanCode is used in development mode.')


def setup_vscode():
"""
Add base settings for .vscode
"""
from scancode import root_dir
from commoncode.fileutils import create_dir
from commoncode.fileutils import copyfile

settings = os.path.join(root_dir, 'etc', 'vscode', 'settings.json')

if os.path.exists(settings):
vscode = os.path.join(root_dir, '.vscode')
create_dir(vscode)
copyfile(settings, vscode)


setup_dev_mode()
setup_vscode()
12 changes: 12 additions & 0 deletions etc/conf/dev/base.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Testing
apipkg
py
pytest
colorama
execnet
pytest-xdist
bumpversion
coverage
pytest-cov
codecov
xmltodict
Loading