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:
14
setup.py
14
setup.py
@@ -1,18 +1,18 @@
|
|||||||
from setuptools import setup, find_packages
|
from setuptools import setup, find_packages
|
||||||
import os
|
import os
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
import subprocess
|
import shutil
|
||||||
from setuptools.command.install import install
|
|
||||||
|
|
||||||
# Create the .crawl4ai folder in the user's home directory if it doesn't exist
|
# Create the .crawl4ai folder in the user's home directory if it doesn't exist
|
||||||
# If the folder already exists, remove the cache folder
|
# If the folder already exists, remove the cache folder
|
||||||
crawl4ai_folder = os.path.join(Path.home(), ".crawl4ai")
|
crawl4ai_folder = Path.home() / ".crawl4ai"
|
||||||
if os.path.exists(f"{crawl4ai_folder}/cache"):
|
cache_folder = 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)
|
|
||||||
|
|
||||||
|
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
|
# Read the requirements from requirements.txt
|
||||||
with open("requirements.txt") as f:
|
with open("requirements.txt") as f:
|
||||||
|
|||||||
Reference in New Issue
Block a user