-
Notifications
You must be signed in to change notification settings - Fork 0
/
manage_package.bat
98 lines (88 loc) · 2.17 KB
/
manage_package.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
@echo off
REM Windows BAT script to manage the publishing of the arduino-hid-emulator package
REM Define variables
set PACKAGE_NAME=arduino-hid-emulator
set PYPI_REPO=pypi
set TEST_PYPI_REPO=testpypi
set DIST_DIR=dist
REM Parse argument and jump to the appropriate section
if "%1"=="" goto menu
if "%1"=="clean" goto clean
if "%1"=="build" goto build
if "%1"=="test-publish" goto test-publish
if "%1"=="publish" goto publish
if "%1"=="test-install" goto test-install
if "%1"=="test" goto test
REM Invalid argument handling
echo Invalid command: %1
goto menu
:clean
echo Cleaning up old builds...
if exist %DIST_DIR% (
rmdir /s /q %DIST_DIR%
echo %DIST_DIR% folder removed.
) else (
echo %DIST_DIR% folder already clean.
)
if exist build (
rmdir /s /q build
echo build folder removed.
) else (
echo build folder already clean.
)
for /d %%D in (*.egg-info) do (
rmdir /s /q "%%D"
echo Removed %%D
) || echo No .egg-info folders found.
exit /b
:build
call :clean
echo Building the package...
python setup.py sdist bdist_wheel
if %ERRORLEVEL% neq 0 (
echo Error: Package build failed.
exit /b 1
)
exit /b
:test-publish
call :build
echo Publishing to TestPyPI...
twine upload --repository %TEST_PYPI_REPO% %DIST_DIR%\*
if %ERRORLEVEL% neq 0 (
echo Error: Publishing to TestPyPI failed.
exit /b 1
)
exit /b
:publish
call :build
echo Publishing to PyPI...
twine upload --repository %PYPI_REPO% %DIST_DIR%\*
if %ERRORLEVEL% neq 0 (
echo Error: Publishing to PyPI failed.
exit /b 1
)
exit /b
:test-install
echo Installing from TestPyPI...
pip install --index-url https://test.pypi.org/simple/ --no-deps %PACKAGE_NAME%
if %ERRORLEVEL% neq 0 (
echo Error: Test installation failed.
exit /b 1
)
exit /b
:test
call :clean
call :build
call :test-publish
call :test-install
exit /b
:menu
echo Usage: manage_package.bat [command]
echo Available commands:
echo clean - Remove old builds
echo build - Build the package
echo test-publish - Publish to TestPyPI
echo publish - Publish to PyPI
echo test-install - Install from TestPyPI
echo test - Full test (clean, build, publish to TestPyPI, and install)
exit /b