mirror of
https://github.com/DragonMinded/bemaniutils.git
synced 2026-08-22 02:14:26 -05:00
Add a setup.py command for cleaning built code.
This commit is contained in:
28
setup.py
28
setup.py
@@ -1,5 +1,6 @@
|
||||
import os
|
||||
from setuptools import setup
|
||||
import shutil
|
||||
from setuptools import Command, setup
|
||||
|
||||
|
||||
def extensions():
|
||||
@@ -92,6 +93,28 @@ def extensions():
|
||||
]
|
||||
|
||||
|
||||
class CleanExtCommand(Command):
|
||||
description = 'Clean all compiled python extensions from the current directory.'
|
||||
|
||||
user_options = []
|
||||
|
||||
def initialize_options(self) -> None:
|
||||
pass
|
||||
|
||||
def finalize_options(self) -> None:
|
||||
pass
|
||||
|
||||
def run(self) -> None:
|
||||
print("Removing build directory...")
|
||||
shutil.rmtree(os.path.abspath("build/"), ignore_errors=True)
|
||||
for dirname, subdirList, fileList in os.walk(os.path.abspath("bemani/")):
|
||||
for filename in fileList:
|
||||
if filename[-3:] == ".so":
|
||||
fullname = os.path.join(dirname, filename)
|
||||
print(f"Removing {fullname}")
|
||||
os.remove(fullname)
|
||||
|
||||
|
||||
setup(
|
||||
name='bemani',
|
||||
version='1.0',
|
||||
@@ -170,6 +193,9 @@ setup(
|
||||
# remove the ext_modules line and run setuptools again. Everything should work, but
|
||||
# it will run slower.
|
||||
ext_modules=extensions(),
|
||||
cmdclass={
|
||||
'clean_ext': CleanExtCommand,
|
||||
},
|
||||
include_package_data=True,
|
||||
zip_safe=False,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user