forked from SMTG-Bham/doped
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.py
124 lines (105 loc) · 4.04 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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
"""This is a setup.py script to install doped"""
import os
import glob
import subprocess
import sys
import warnings
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
SETUP_PTH = os.path.dirname(os.path.abspath(__file__))
def readme():
"""
Set GitHub repo README as package README.
"""
with open("README.md") as readme_file:
return readme_file.read()
def pmg_analysis_defects_warning():
"""
Print warning message if pymatgen-analysis-defects is installed.
"""
installed_packages = str(subprocess.check_output([sys.executable, "-m", "pip", "list"]))
if "pymatgen-analysis-defects" in installed_packages:
print("Test!!")
warnings.warn("pymatgen-analysis-defects is installed, which will cause incompatibility issues with doped. "
"Please uninstall pymatgen-analysis-defects with 'pip uninstall pymatgen-analysis-defects'.")
class PostInstallCommand(install):
"""Post-installation for installation mode.
Subclass of the setup tools install class in order to run custom commands
after installation. Note that this only works when using 'python setup.py install'
but not 'pip install .' or 'pip install -e .'.
"""
def run(self):
"""
Performs the usual install process and then checks if pymatgen-analysis-defects
is installed. If so, prints a warning message that this needs to be
uninstalled for doped to work (at present).
"""
# Perform the usual install process
install.run(self)
pmg_analysis_defects_warning()
class PostDevelopCommand(develop):
"""Post-installation for development mode."""
def run(self):
"""
Performs the usual install process and then checks if pymatgen-analysis-defects
is installed. If so, prints a warning message that this needs to be
uninstalled for doped to work (at present).
"""
develop.run(self)
pmg_analysis_defects_warning()
class CustomEggInfoCommand(egg_info):
"""Post-installation"""
def run(self):
"""
Performs the usual install process and then checks if pymatgen-analysis-defects
is installed. If so, prints a warning message that this needs to be
uninstalled for doped to work (at present).
"""
egg_info.run(self)
pmg_analysis_defects_warning()
setup(
name="doped",
packages=find_packages(),
version="0.2.1",
install_requires=[
"numpy>=1.21.0",
"pymatgen<2022.8.23",
"matplotlib",
"monty>=3.0.2",
"tabulate",
"ase",
"shakenbreak==22.11.1", # pymatgen<2022.8.23
],
package_data={"doped.pycdt.utils": ["*.yaml"], "doped": ["default_POTCARs.yaml"]},
author="Seán Kavanagh",
author_email="[email protected]",
maintainer="Seán Kavanagh",
maintainer_email="[email protected]",
url="https://github.com/SMTG-UCL/doped",
description="Collection of Python modules & functions to perform "
"and process solid-state defect calculations",
long_description=readme(),
long_description_content_type="text/markdown",
classifiers=[
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.8",
"Intended Audience :: Science/Research",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
"Topic :: Scientific/Engineering :: Information Analysis",
"Topic :: Scientific/Engineering :: Physics",
"Topic :: Scientific/Engineering :: Chemistry",
"Topic :: Software Development :: Libraries :: Python Modules",
],
license="MIT",
scripts=glob.glob(os.path.join(SETUP_PTH, "scripts", "*")),
test_suite="nose.collector",
tests_require=["nose", "pytest"],
cmdclass={
"install": PostInstallCommand,
"develop": PostDevelopCommand,
"egg_info": CustomEggInfoCommand,
},
)