From a48f2e965b855fa08cb50e5fb51f64d909b2968c Mon Sep 17 00:00:00 2001 From: Dan <14043624+delivrance@users.noreply.github.com> Date: Sat, 25 Aug 2018 13:53:48 +0200 Subject: [PATCH] Add clean command to setup.py --- setup.py | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index 00f9be63..a5ad052d 100644 --- a/setup.py +++ b/setup.py @@ -17,9 +17,10 @@ # along with Pyrogram. If not, see . import re +import shutil from sys import argv -from setuptools import setup, find_packages +from setuptools import setup, find_packages, Command from compiler.api import compiler as api_compiler from compiler.docs import compiler as docs_compiler @@ -44,6 +45,24 @@ with open("README.rst", encoding="utf-8") as f: readme = re.sub(r"\.\. \|.+\| raw:: html(?:\s{4}.+)+\n\n", "", f.read()) readme = re.sub(r"\|header\|", "|logo|\n\n|description|\n\n|scheme| |tgcrypto|", readme) + +class Clean(Command): + PATHS = "./build ./dist ./Pyrogram.egg-info".split() + + user_options = [] + + def initialize_options(self): + pass + + def finalize_options(self): + pass + + def run(self): + for path in self.PATHS: + print("removing {}".format(path)) + shutil.rmtree(path, ignore_errors=True) + + setup( name="Pyrogram", version=version, @@ -85,5 +104,8 @@ setup( packages=find_packages(exclude=["compiler*"]), zip_safe=False, install_requires=read("requirements.txt"), - extras_require={"tgcrypto": ["tgcrypto>=1.0.4"]} + extras_require={"tgcrypto": ["tgcrypto>=1.0.4"]}, + cmdclass={ + "clean": Clean + } )