Skip to content

Commit

Permalink
Add setup.py clean
Browse files Browse the repository at this point in the history
  • Loading branch information
Florents-Tselai committed Aug 15, 2024
1 parent 5ea0319 commit ed5dd55
Showing 1 changed file with 40 additions and 2 deletions.
42 changes: 40 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
from setuptools import setup
import os
from tsellm import __version__
from setuptools import setup, Command
import os
import shutil
import glob


def get_long_description():
Expand All @@ -11,6 +13,39 @@ def get_long_description():
return fp.read()


class CleanCommand(Command):
"""Custom clean command to tidy up the project root."""

user_options = []

def initialize_options(self):
pass

def finalize_options(self):
pass

def run(self):
# Paths to clean
files_to_remove = ["*.jpg", "*.sqlite3", "*.duckdb"]
dirs_to_clean = ["build", "dist", "*.egg-info"]

for pattern in files_to_remove:
for file in glob.glob(pattern):
try:
os.remove(file)
print(f"Removed file: {file}")
except Exception as e:
print(f"Could not remove {file}: {e}")

for pattern in dirs_to_clean:
for dir in glob.glob(pattern):
try:
shutil.rmtree(dir)
print(f"Removed directory: {dir}")
except Exception as e:
print(f"Could not remove {dir}: {e}")


setup(
name="tsellm",
description=__version__.__description__,
Expand All @@ -22,6 +57,9 @@ def get_long_description():
[console_scripts]
tsellm=tsellm.cli:cli
""",
cmdclass={
"clean": CleanCommand,
},
project_urls={
"Issues": "https://github.com/Florents-Tselai/tsellm/issues",
"CI": "https://github.com/Florents-Tselai/tsellm/actions",
Expand Down

0 comments on commit ed5dd55

Please sign in to comment.