summaryrefslogtreecommitdiff
path: root/make.bat
blob: 9944cf0b278f18f986bcfa0474fca8b9ad9bf9d4 (plain)
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
@ECHO OFF

REM ==========================================================================
REM Shortcuts for various tasks, emulating UNIX "make" on Windows.
REM Use this script for various tasks such as installing psutil or
REM running tests ("make.bat test").
REM This script is modeled after my Windows installation so it might
REM need some adjustements in order to work on your system.
REM By default C:\Python27\python.exe is used.
REM To run another Python version run:
REM set PYTHON=C:\Python33\python.exe & make test
REM In case of Python 2.4 and 2.5 mingw32 compiler is used.
REM ==========================================================================


if "%PYTHON%" == "" (
    SET PYTHON=C:\Python27\python.exe
)
if "%TSCRIPT%" == "" (
    SET TSCRIPT=test\test_psutil.py
)
SET PATH=%PYTHON%;%PATH%
SET PATH=C:\MinGW\bin;%PATH%


if "%1" == "help" (
    :help
    echo Run `make ^<target^>` where ^<target^> is one of:
    echo   clean         clean build files
    echo   build         compile without installing
    echo   install       compile and install
    echo   uninstall     uninstall
    echo   test          run tests
    echo   memtest       run memory leak tests
    echo   build-exes    create exe installers in dist directory
    echo   upload-exes   upload exe installers on pypi
    goto :eof
)

if "%1" == "clean" (
    :clean
    for /r %%R in (__pycache__) do if exist %%R (rmdir /S /Q %%R)
    for /r %%R in (*.pyc) do if exist %%R (del /s %%R)
    for /r %%R in (*.orig) do if exist %%R (del /s %%R)
    for /r %%R in (*.bak) do if exist %%R (del /s %%R))
    for /r %%R in (*.rej) do if exist %%R (del /s %%R)
    if exist psutil.egg-info (rmdir /S /Q psutil.egg-info)
    if exist build (rmdir /S /Q build)
    if exist dist (rmdir /S /Q dist)
    goto :eof
)

if "%1" == "build" (
    :build
    if %PYTHON%==C:\Python24\python.exe (
        %PYTHON% setup.py build -c mingw32
    ) else if %PYTHON%==C:\Python25\python.exe (
        %PYTHON% setup.py build -c mingw32
    ) else (
        %PYTHON% setup.py build
    )
    if %errorlevel% neq 0 goto :error
    goto :eof
)

if "%1" == "install" (
    :install
    call :build
    %PYTHON% setup.py install
    goto :eof
)

if "%1" == "uninstall" (
    :uninstall
    rmdir /S /Q %PYTHON%\Lib\site-packages\psutil
    del /F /S /Q %PYTHON%\Lib\site-packages\psutil*
    del /F /S /Q %PYTHON%\Lib\site-packages\_psutil*
    goto :eof
)

if "%1" == "test" (
    :test
    call :install
    %PYTHON% %TSCRIPT%
    goto :eof
)

if "%1" == "memtest" (
    :memtest
    call :install
    %PYTHON% test\test_memory_leaks.py
    goto :eof
)

if "%1" == "build-exes" (
    :build-exes
    call :clean
    C:\Python26\python.exe setup.py build bdist_wininst & if %errorlevel% neq 0 goto :error
    C:\Python27\python.exe setup.py build bdist_wininst & if %errorlevel% neq 0 goto :error
    C:\Python33\python.exe setup.py build bdist_wininst & if %errorlevel% neq 0 goto :error
    goto :eof
)

if "%1" == "upload-exes" (
    :upload-exes
    C:\Python26\python.exe setup.py bdist_wininst upload  & if %errorlevel% neq 0 goto :error
    C:\Python27\python.exe setup.py bdist_wininst upload  & if %errorlevel% neq 0 goto :error
    C:\Python33\python.exe setup.py bdist_wininst upload  & if %errorlevel% neq 0 goto :error
    goto :eof
)

goto :help

:error
    echo last command returned an error; exiting
    exit /b %errorlevel%