forked from aboutcode-org/scancode-toolkit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfigure.bat
125 lines (99 loc) · 3.72 KB
/
configure.bat
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
@echo OFF
@setlocal
@rem Copyright (c) nexB Inc. and others. All rights reserved.
@rem SPDX-License-Identifier: Apache-2.0
@rem See http://www.apache.org/licenses/LICENSE-2.0 for the license text.
@rem ScanCode is a trademark of nexB Inc.
@rem See https://github.com/nexB/scancode-toolkit for support or download.
@rem See https://aboutcode.org for more information about nexB OSS projects.
@rem ################################
@rem # A configuration script to set things up: create a virtualenv and install
@rem # update thirdparty packages
goto config
:cli_help
echo An initial configuration script
echo " usage: configure [options]"
echo.
echo The default is to configure for regular use.
echo The script will attempt to find a suitable Python executable.
echo Set the PYTHON_EXECUTABLE environment variable to provide your own
echo Python executable path.
echo.
echo The options are:
echo "--clean: clean built and installed files and exit."
echo "--dev: configure the environment for development."
echo "--help: display these help messages and exit."
echo.
endlocal
exit /b 0
:config
@rem ################################
@rem # Defaults. Change these variables to customize this script locally
@rem ################################
@rem # thirdparty package locations
set "THIRDPARTY_DIR=thirdparty"
set "THIRDPARTY_LINKS=https://thirdparty.aboutcode.org/pypi"
@rem # requirements used by defaults and with --dev
set "REQUIREMENTS=--editable . --constraint requirements.txt"
set "DEV_REQUIREMENTS=--editable .[dev] --constraint requirements.txt --constraint requirements-dev.txt"
@rem # default supported Python version
if not defined CONFIGURE_SUPPORTED_PYTHON (
set CONFIGURE_SUPPORTED_PYTHON=3.6
)
@rem #################################
@rem Current directory where this script lives
set PROJECT_ROOT_DIR=%~dp0
@rem parse command line options
set CLI_ARGS="%REQUIREMENTS%"
set CONFIGURE_DEV_MODE=0
if "%1" EQU "--help" (goto cli_help)
if "%1" EQU "--clean" (set CLI_ARGS=--clean)
if "%1" EQU "--dev" (
set CLI_ARGS=%DEV_REQUIREMENTS%
set CONFIGURE_DEV_MODE=1
)
@rem find a proper Python to run
if defined CONFIGURE_PYTHON_EXECUTABLE (
if exist "%CONFIGURE_PYTHON_EXECUTABLE%" (
goto run
)
)
:find_python
@rem Check the existence of the "py" launcher available in Python 3
@rem If we have it, check if we have a py -3 installed with the required version
@rem Try to use a Python in the path if all else fail
where py >nul 2>nul
if %ERRORLEVEL% == 0 (
@rem we have a py launcher, check for the availability of our Python 3 version
set CONFIGURE_PYTHON_EXECUTABLE=py -%CONFIGURE_SUPPORTED_PYTHON%%
%CONFIGURE_PYTHON_EXECUTABLE% --version >nul 2>nul
if %ERRORLEVEL% neq 0 (
echo "* Unable to find a suitable installation of Python %CONFIGURE_SUPPORTED_PYTHON%."
exit /b 1
)
) else (
echo "* Unable to find a suitable installation of Python %CONFIGURE_SUPPORTED_PYTHON%."
exit /b 1
)
:run
@rem ################################
@rem # Setup development mode
if "%CONFIGURE_DEV_MODE%" == 1 (
@rem # Add development tag file to auto-regen license index on file changes
echo. 2>%%PROJECT_ROOT_DIR%\SCANCODE_DEV_MODE"
)
@rem # Run configure scripts proper and activate
@rem without this there are some heisenbugs on Windows 10
@rem but this make scancode run slower
set PYTHONDONTWRITEBYTECODE=1
call %CONFIGURE_PYTHON_EXECUTABLE% "%PROJECT_ROOT_DIR%etc\configure.py" %CLI_ARGS%
@rem Return a proper return code on failure
if %ERRORLEVEL% neq 0 (
exit /b %ERRORLEVEL%
)
endlocal
@rem # Activate the virtualenv if it exists
if exist "%PROJECT_ROOT_DIR%Scripts\activate" (
"%PROJECT_ROOT_DIR%Scripts\activate"
)
exit /b 0