|
11 | 11 | import sys |
12 | 12 | from pathlib import Path |
13 | 13 |
|
14 | | -assert len(sys.argv) == 2, 'Argument is required, usage: build.py pip/twine' |
| 14 | +assert len(sys.argv) == 2, "Argument is required, usage: build.py pip/twine" |
15 | 15 | mode: str = sys.argv[1].strip() |
16 | 16 |
|
17 | 17 | root = Path(__file__).resolve().parent |
18 | | -dist = root / 'dist' |
19 | | -build = root / 'build' |
| 18 | +dist = root / "dist" |
| 19 | +build = root / "build" |
20 | 20 |
|
21 | | -if mode == 'pip': |
| 21 | +if mode == "pip": |
22 | 22 | if dist.is_dir(): |
23 | 23 | for k in dist.iterdir(): |
24 | | - if 'pygame_menu-' in k.name or 'pygame-menu-' in k.name: |
| 24 | + if "pygame_menu-" in k.name or "pygame-menu-" in k.name: |
25 | 25 | k.unlink() |
26 | 26 |
|
27 | 27 | if build.is_dir(): |
28 | 28 | for k in build.iterdir(): |
29 | | - if 'bdist.' in k.name or k.name == 'lib': |
| 29 | + if "bdist." in k.name or k.name == "lib": |
30 | 30 | shutil.rmtree(k) |
31 | 31 |
|
32 | | - subprocess.run( |
33 | | - ["python", "setup.py", "sdist", "bdist_wheel"], |
34 | | - check=True |
35 | | - ) |
| 32 | + subprocess.run(["python", "setup.py", "sdist", "bdist_wheel"], check=True) |
36 | 33 |
|
37 | | -elif mode == 'twine': |
| 34 | +elif mode == "twine": |
38 | 35 | if dist.is_dir(): |
39 | 36 | subprocess.run( |
40 | 37 | ["python", "-m", "twine", "upload", "dist/*"], |
41 | | - shell=True, # required because of wildcard |
42 | | - check=True |
| 38 | + shell=True, # required because of wildcard |
| 39 | + check=True, |
43 | 40 | ) |
44 | 41 | else: |
45 | | - raise FileNotFoundError('No distribution found, execute build.py pip first') |
| 42 | + raise FileNotFoundError("No distribution found, execute build.py pip first") |
46 | 43 |
|
47 | 44 | else: |
48 | | - raise ValueError(f'Unknown mode {mode}') |
| 45 | + raise ValueError(f"Unknown mode {mode}") |
0 commit comments