-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathsetup.py
More file actions
114 lines (86 loc) · 3.63 KB
/
setup.py
File metadata and controls
114 lines (86 loc) · 3.63 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
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
# microbetag : a python library for metabolic networks sampling and analysis
# microbetag is developed and maintained by the Lab of microbial systems biology
# Copyright (c) 2024 Haris Zafeiropoulos
# Licensed under GNU LGPL.3, see LICENCE file
# This is the setup Python script for building the microbetag library
"""
Script to install the microbetag library locally.
To do so, you may run:
python setup.py sdist bdist_wheel
pip install .
In case you get the strip_trailing_zero error
pip install --upgrade setuptools packaging
Attention!
For the seed complementarity module to work fine, you need to make sure
you have downloaded the MetaNetX reference file for chemical compounds chem_xref.tar.gz
and place it in `microbetag/mtg_maps_models/MetaNetX`
This should be already done when running `setup_environment.sh`.
"""
import os
import re
import sys
import ast
import subprocess
from setuptools import setup, find_packages
from setuptools.command.install import install
# Read the requirements.txt file
with open("requirements/requirements.txt") as f:
requirements = f.read().splitlines()
def get_records():
init_path = os.path.join("microbetag", "__init__.py")
with open(init_path) as f:
content = f.read()
version_match = re.search(r'__version__\s*=\s*"([^"]+)"', content)
version = version_match.group(1) if version_match else None
authors_match = re.search(r'__authors__\s*=\s*(\[.*?\])', content, re.DOTALL)
authors = ast.literal_eval(authors_match.group(1)) if authors_match else []
license_match = re.search(r'__license__\s*=\s*"([^"]+)"', content)
license = license_match.group(1) if license_match else None
cite_match = re.search(r'__cite__\s*=\s*"([^"]+)"', content)
cite = cite_match.group(1) if cite_match else None
return {
"version": version,
"authors": authors,
"license": license,
"cite": cite
}
records = get_records()
class CustomInstallCommand(install):
def run(self):
install.run(self)
# NOTE (Haris Zafeiropoulos, 2025-05-22):
# The package pyshorteners==1.0.1 does not support modern PEP 517/518 builds and
# tries to use a deprecated setup.py egg_info process,
# which fails in current Python environments
# (especially in isolated or conda environments with modern setuptools and pip).
subprocess.check_call([sys.executable, "-m", "pip", "install", "pyshorteners==1.0.1"])
setup(
name = "microbetag",
description = "A library for microbial co-occurrencce network annotation.",
documentation = "https://microbetag.readthedocs.io/",
version = records["version"],
authors = records["authors"],
license = records["license"],
cite = records["cite"],
packages = find_packages(include=["microbetag", "microbetag.*"]),
include_package_data = True,
entry_points = {
"console_scripts": [
"microbetag = microbetag.microbetag:main",
],
},
package_data = {
"microbetag": ["mtg_maps_models/*", "PhyloMint/*", "PhyloMint/lib/*"]
},
install_requires = requirements,
dependency_links = [
"git+https://github.com/hariszaf/manta.git@scipy-version#egg=manta"
],
cmdclass={
'install': CustomInstallCommand,
},
)
# NOTE (Haris Zafeiropoulos, 2025-06-01):
# Python 3.9.19 does support dict[str, str] and other generic built-ins, yet it does not support the | (union) operator for types — that was only introduced in Python 3.10.
# phenotrex runs in Python 3.8
# Consider Python 3.8 as basis