-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathsetup.py
84 lines (69 loc) · 2.77 KB
/
setup.py
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
72
73
74
75
76
77
78
79
80
81
82
83
84
# This file is part of the Network Dismantling review,
# proposed in the paper "Robustness and resilience of complex networks"
# by Oriol Artime, Marco Grassia, Manlio De Domenico, James P. Gleeson,
# Hernán A. Makse, Giuseppe Mangioni, Matjaž Perc and Filippo Radicchi.
#
# This is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# The project is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with the code. If not, see <http://www.gnu.org/licenses/>.
import importlib
import logging
from pathlib import Path
from network_dismantling._setup_hook import registry
from setuptools import setup, find_packages
from setuptools.command.develop import develop
from setuptools.command.egg_info import egg_info
from setuptools.command.install import install
logger = logging.getLogger(__name__)
package_folder = Path(__file__).parent / "network_dismantling"
for folder in package_folder.iterdir():
if folder.is_dir() and (folder / "setup_hook.py").exists():
# logger.info(f"Loading {folder.name}")
module = importlib.import_module(f"network_dismantling.{folder.name}.setup_hook")
class CustomInstallCommand(install):
def run(self):
install.run(self)
for hook in registry:
try:
hook(
package_folder=package_folder,
logger=logger,
)
except Exception as e:
logger.exception(f"Error during setup: {e}",
exc_info=e,
)
class CustomDevelopCommand(develop):
def run(self):
develop.run(self)
for hook in registry:
hook()
class CustomEggInfoCommand(egg_info):
def run(self):
egg_info.run(self)
for hook in registry:
hook()
setup(
name="NetworkDismantling",
version="0.1",
packages=find_packages(),
url="https://github.com/NetworkDismantling/review/",
license="",
author="Marco Grassia",
author_email="",
description="Network dismantling library. Cite: Artime, O., Grassia, M., De Domenico, M. et al. Robustness and resilience of complex networks. Nat Rev Phys (2024). https://doi.org/10.1038/s42254-023-00676-y",
cmdclass={
"install": CustomInstallCommand,
"develop": CustomDevelopCommand,
"egg_info": CustomEggInfoCommand,
}
)