forked from canonical/landscape-client
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup_common.py
More file actions
71 lines (57 loc) · 1.57 KB
/
Copy pathsetup_common.py
File metadata and controls
71 lines (57 loc) · 1.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import shutil
from pathlib import Path
from setuptools import Command, setup
from landscape import PYTHON_VERSION
class CleanCommand(Command):
"""
Custom clean command to replace the one from DistUtilsExtra
"""
user_options = []
def run(self):
for pattern in ["build", "dist", ".eggs", "*.egg-info"]:
for path in Path(".").glob(pattern):
if path.is_dir():
shutil.rmtree(path)
# Recursively remove __pycache__ and compiled files
for pycache in Path(".").rglob("__pycache__"):
if pycache.is_dir():
shutil.rmtree(pycache)
for compiled in Path(".").rglob("*.py[co]"):
if compiled.is_file():
compiled.unlink()
def initialize_options(self):
self.all = True
def finalize_options(self):
pass
SETUP = dict(
name=None,
description=None,
packages=None,
py_modules=None,
scripts=None,
version=PYTHON_VERSION,
author="Landscape Team",
author_email="landscape-team@canonical.com",
url="http://landscape.canonical.com",
cmdclass={"clean": CleanCommand},
)
def setup_landscape(
name,
description,
packages,
modules=None,
scripts=None,
**kwargs,
):
assert name and description and packages
kwargs = dict(
SETUP,
name=name,
description=description,
packages=packages,
py_modules=modules,
scripts=scripts,
**kwargs,
)
kwargs = {k: v for k, v in kwargs.items() if k is not None}
setup(**kwargs)