chore: Refactor setup.py to use pathlib and shutil for folder creation and removal, to remove cache folder in cross platform manner.
This commit is contained in:
parent
ca0336af9e
commit
fa5516aad6
14
setup.py
14
setup.py
@ -1,18 +1,18 @@
|
||||
from setuptools import setup, find_packages
|
||||
import os
|
||||
from pathlib import Path
|
||||
import subprocess
|
||||
from setuptools.command.install import install
|
||||
import shutil
|
||||
|
||||
# Create the .crawl4ai folder in the user's home directory if it doesn't exist
|
||||
# If the folder already exists, remove the cache folder
|
||||
crawl4ai_folder = os.path.join(Path.home(), ".crawl4ai")
|
||||
if os.path.exists(f"{crawl4ai_folder}/cache"):
|
||||
subprocess.run(["rm", "-rf", f"{crawl4ai_folder}/cache"])
|
||||
os.makedirs(crawl4ai_folder, exist_ok=True)
|
||||
os.makedirs(f"{crawl4ai_folder}/cache", exist_ok=True)
|
||||
crawl4ai_folder = Path.home() / ".crawl4ai"
|
||||
cache_folder = crawl4ai_folder / "cache"
|
||||
|
||||
if cache_folder.exists():
|
||||
shutil.rmtree(cache_folder)
|
||||
|
||||
crawl4ai_folder.mkdir(exist_ok=True)
|
||||
cache_folder.mkdir(exist_ok=True)
|
||||
|
||||
# Read the requirements from requirements.txt
|
||||
with open("requirements.txt") as f:
|
||||
|
Loading…
x
Reference in New Issue
Block a user