Skip to content

Commit fb939fd

Browse files
ianhellepetebryan
andauthored
Setup.cfg and Pyproject.toml (microsoft#287)
* Moving most setup config to setup.cfg Extras couldn't be moved there since we have multiple overlapping extra groups. Updated import_analyzer.py to avoid creating copy of setup.py * Add Pipfile creation to create_reqs_all.py * Trying to get the version in setup.cfg causes a failure with pip install -e . This is because setuptools tries to import the msticpy package before dependencies are fully installed. See pypa/setuptools#1724 Co-authored-by: Pete Bryan <peter.bryan@microsoft.com>
1 parent a7d996a commit fb939fd

9 files changed

+213
-222
lines changed

MANIFEST.in

+1
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,6 @@ include msticpy/msticpyconfig.yaml
33
include msticpy/resources/*
44
include requirements.txt
55
include requirements-dev.txt
6+
include requirements-all.txt
67
include README.md
78
recursive-exclude tests *

pyproject.toml

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[build-system]
2+
requires = [
3+
"setuptools>=42",
4+
"wheel"
5+
]
6+
build-backend = "setuptools.build_meta"

requirements-all.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ azure-storage-blob>=12.5.0
1515
bokeh>=1.4.0
1616
cryptography>=3.1
1717
deprecated>=1.2.4
18-
dnspython<=2.0.0 # <=2.0 required by ipwhois
18+
dnspython<=2.0.0
1919
folium>=0.9.0
2020
geoip2>=2.9.0
21-
html5lib # req by pandas for scraping
21+
html5lib
2222
idna<3 # req < 3 from requests
2323
ipwhois>=1.1.0
2424
ipython>=7.23.1

requirements.txt

+2-13
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,15 @@
1-
# adal>=1.2.2 # Kql
21
attrs>=18.2.0
32
azure-common>=1.1.18
43
azure-core>=1.2.2
54
azure-identity>=1.5.0
6-
# azure-keyvault-secrets>=4.0.0 # azure
7-
# azure-mgmt-compute>=4.6.2 # azure
8-
# azure-mgmt-core>=1.2.1 # installed by others
9-
# azure-mgmt-keyvault>=2.0.0 # azure
10-
# azure-mgmt-monitor>=1.0.1 # azure
11-
# azure-mgmt-network>=2.7.0 # azure
12-
# azure-mgmt-resource>=16.1.0 # azure
13-
# azure-mgmt-resourcegraph>=8.0.0 # azure
145
azure-mgmt-subscription>=1.0.0
15-
# azure-storage-blob>=12.5.0 #
16-
# beautifulsoup4>=4.6.3 # move to dev
176
bokeh>=1.4.0
187
cryptography>=3.1
198
deprecated>=1.2.4
20-
dnspython<=2.0.0 # <=2.0 required by ipwhois
9+
dnspython<=2.0.0
2110
folium>=0.9.0
2211
geoip2>=2.9.0
23-
html5lib # req by pandas for scraping
12+
html5lib
2413
idna<3 # req < 3 from requests
2514
ipwhois>=1.1.0
2615
ipython>=7.23.1

setup.cfg

+59
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
[metadata]
2+
name = msticpy
3+
description = MSTIC Security Tools
4+
long_description = file: README.md
5+
long_description_content_type = text/markdown
6+
author = Ian Hellen
7+
author_email = ianhelle@microsoft.com
8+
maintainer = Pete Bryan
9+
maintainer_email = peter.bryan@microsoft.com
10+
keywords =
11+
security
12+
azure
13+
sentinel
14+
mstic
15+
cybersec
16+
infosec
17+
cyber
18+
cybersecurity
19+
jupyter
20+
notebooks
21+
SOC
22+
hunting
23+
license = MIT License
24+
classifiers =
25+
Programming Language :: Python
26+
Programming Language :: Python :: 3
27+
Programming Language :: Python :: 3 :: Only
28+
Programming Language :: Python :: 3.6
29+
Programming Language :: Python :: 3.7
30+
Programming Language :: Python :: 3.8
31+
Programming Language :: Python :: 3.9
32+
Programming Language :: Python :: 3.10
33+
License :: OSI Approved :: MIT License
34+
Operating System :: OS Independent
35+
Development Status :: 5 - Production/Stable
36+
Framework :: IPython
37+
Framework :: Jupyter
38+
Intended Audience :: Developers
39+
Intended Audience :: Information Technology
40+
Topic :: Security
41+
Topic :: Software Development :: Libraries :: Python Modules
42+
43+
url = https://github.com/microsoft/msticpy
44+
project_urls =
45+
Documentation = https://msticpy.readthedocs.io
46+
Code = https://github.com/microsoft/msticpy
47+
Issue tracker = https://github.com/microsoft/msticpy/issues
48+
49+
[options]
50+
zip_safe = False
51+
include_package_data = True
52+
package_dir =
53+
msticpy = msticpy
54+
packages = find:
55+
python_requires = >=3.6
56+
57+
[options.packages.find]
58+
include = msticpy*
59+
exclude = tests. tests*. *.tests.*

setup.py

+5-84
Original file line numberDiff line numberDiff line change
@@ -4,37 +4,12 @@
44
# license information.
55
# --------------------------------------------------------------------------
66
"""Setup script for msticpy."""
7-
import os
87
import re
98
import setuptools
109

11-
12-
def install_requires_rtd(install_list: list) -> list:
13-
"""Return modified install list if installing for ReadtheDocs."""
14-
rtd_exceptions = [
15-
"Kqlmagic",
16-
"azure-cli-core",
17-
"matplotlib",
18-
"statsmodels",
19-
"scipy",
20-
"splunk-sdk",
21-
"seaborn",
22-
]
23-
return [
24-
pkg
25-
for pkg in install_list
26-
if not any(excl_pkg for excl_pkg in rtd_exceptions if excl_pkg in pkg)
27-
]
28-
29-
30-
with open("README.md", "r", encoding="utf-8") as fh:
31-
LONG_DESC = fh.read()
32-
33-
# pylint: disable=locally-disabled, invalid-name
3410
with open("msticpy/_version.py", "r", encoding="utf-8") as fd:
3511
v_match = re.search(r'^VERSION\s*=\s*[\'"]([^\'"]*)[\'"]', fd.read(), re.MULTILINE)
3612
__version__ = v_match.group(1) if v_match else "no version"
37-
# pylint: enable=locally-disabled, invalid-name
3813

3914
with open("requirements.txt", "r", encoding="utf-8") as fh:
4015
INSTALL_REQUIRES = fh.readlines()
@@ -88,64 +63,10 @@ def _combine_extras(extras: list) -> list:
8863
EXTRAS["test"] = sorted(_combine_extras(["all", "dev"]))
8964
EXTRAS["azsentinel"] = sorted(_combine_extras(["azure", "kql", "keyvault"]))
9065
EXTRAS["azuresentinel"] = sorted(_combine_extras(["azure", "kql", "keyvault"]))
66+
EXTRAS["sentinel"] = sorted(_combine_extras(["azure", "kql", "keyvault"]))
9167

92-
# If ReadTheDocs build, remove a couple of problematic packages
93-
# (we ask Sphinx to mock these in the import)
94-
if os.environ.get("MP_RTD_BUILD"):
95-
INSTALL_REQUIRES = install_requires_rtd(INSTALL_REQUIRES)
9668

97-
setuptools.setup(
98-
name="msticpy",
99-
version=__version__,
100-
author="Ian Hellen",
101-
author_email="ianhelle@microsoft.com",
102-
description="MSTIC Security Tools",
103-
license="MIT License",
104-
long_description=LONG_DESC,
105-
long_description_content_type="text/markdown",
106-
url="https://github.com/microsoft/msticpy",
107-
project_urls={
108-
"Documentation": "https://msticpy.readthedocs.io",
109-
"Code": "https://github.com/microsoft/msticpy",
110-
"Issue tracker": "https://github.com/microsoft/msticpy/issues",
111-
},
112-
python_requires=">=3.6",
113-
packages=setuptools.find_packages(exclude=["tests", "tests.*", "*.tests.*"]),
114-
classifiers=[
115-
"Programming Language :: Python",
116-
"Programming Language :: Python :: 3",
117-
"Programming Language :: Python :: 3 :: Only",
118-
"Programming Language :: Python :: 3.6",
119-
"Programming Language :: Python :: 3.7",
120-
"Programming Language :: Python :: 3.8",
121-
"Programming Language :: Python :: 3.9",
122-
"Programming Language :: Python :: 3.10",
123-
"License :: OSI Approved :: MIT License",
124-
"Operating System :: OS Independent",
125-
"Development Status :: 5 - Production/Stable",
126-
"Framework :: IPython",
127-
"Framework :: Jupyter",
128-
"Intended Audience :: Developers",
129-
"Intended Audience :: Information Technology",
130-
"Topic :: Security",
131-
"Topic :: Software Development :: Libraries :: Python Modules",
132-
],
133-
install_requires=INSTALL_REQUIRES,
134-
extras_require=EXTRAS,
135-
keywords=[
136-
"security",
137-
"azure",
138-
"sentinel",
139-
"mstic",
140-
"cybersec",
141-
"infosec",
142-
"cyber",
143-
"cybersecurity",
144-
"jupyter",
145-
"notebooks",
146-
"SOC",
147-
"hunting",
148-
],
149-
zip_safe=False,
150-
include_package_data=True,
151-
)
69+
if __name__ == "__main__":
70+
setuptools.setup(
71+
install_requires=INSTALL_REQUIRES, extras_require=EXTRAS, version=__version__
72+
)

tests/test_pkg_imports.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
@pytest.fixture(scope="module")
4242
def extras_from_setup():
4343
"""Read extras packages from setup.py."""
44-
return get_extras_from_setup(PKG_ROOT, extra="all")
44+
return get_extras_from_setup(extra="all")
4545

4646

4747
def test_missing_pkgs_req():

0 commit comments

Comments
 (0)