-
Notifications
You must be signed in to change notification settings - Fork 33
Expand file tree
/
Copy pathsetup.py
More file actions
205 lines (172 loc) · 6.21 KB
/
setup.py
File metadata and controls
205 lines (172 loc) · 6.21 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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
#!/usr/bin/env python3
import os
import sys
import subprocess
from pathlib import Path
from setuptools import setup, find_packages
from setuptools.command.build_py import build_py
from setuptools.command.develop import develop
from setuptools.command.install import install
from setuptools.command.egg_info import egg_info
from setuptools.dist import Distribution
def check_system_dependencies():
"""Check that required system dependencies are available."""
required_commands = ['scons', 'gcc', 'g++', 'python3', 'mafft']
missing = []
for cmd in required_commands:
try:
subprocess.run([cmd, '--version'], capture_output=True, check=True)
except (subprocess.CalledProcessError, FileNotFoundError):
missing.append(cmd)
# Check python3-venv separately since it's a module, not a command
try:
subprocess.run([sys.executable, '-m', 'venv', '--help'], capture_output=True, check=True)
except (subprocess.CalledProcessError, FileNotFoundError):
missing.append('python3-venv')
if missing:
raise RuntimeError('Missing required system dependencies: %s. Please install all packages listed in the manual (docs/install.md#installation-with-pip), then try the installation again.' % ', '.join(missing))
def build_compiled_components():
"""Build the required C++ components using the build script."""
print("Building partis compiled components (ig-sw and ham)...")
# Check system dependencies first
check_system_dependencies()
base_dir = Path(__file__).parent.absolute()
build_script = base_dir / "bin" / "build.sh"
if not build_script.exists():
raise Exception(f"Build script not found at {build_script}")
print("Compiling C++ components...")
result = subprocess.run([str(build_script)], cwd=str(base_dir))
if result.returncode != 0:
raise Exception(f"Build script failed with exit code {result.returncode}")
print("✓ Successfully built ig-sw and ham binaries")
def make_custom_command(base_class):
"""Factory function to create custom command classes that build C++ components."""
class CustomCommand(base_class):
def run(self):
build_compiled_components()
base_class.run(self)
return CustomCommand
CustomBuildPy = make_custom_command(build_py)
CustomDevelop = make_custom_command(develop)
CustomInstall = make_custom_command(install)
CustomEggInfo = make_custom_command(egg_info)
class BinaryDistribution(Distribution):
"""Distribution which always forces a binary package with platform name"""
def has_ext_modules(self):
return True
# Read the README file
here = os.path.abspath(os.path.dirname(__file__))
with open(os.path.join(here, 'README.md'), encoding='utf-8') as f:
long_description = f.read()
setup(
name='partis-bcr',
use_scm_version=True,
description='B- and T-cell receptor sequence annotation, simulation, clonal family and germline inference',
long_description=long_description,
long_description_content_type='text/markdown',
url='https://github.com/psathyrella/partis',
author='Duncan Ralph',
author_email='dkralph@gmail.com',
license='GPL-3.0-or-later',
classifiers=[
'Development Status :: 4 - Beta',
'Intended Audience :: Science/Research',
'Topic :: Scientific/Engineering :: Bio-Informatics',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: 3.11',
'Programming Language :: Python :: 3.12',
],
keywords='immunology bioinformatics bcr tcr antibody sequence-analysis',
# Packages and package data
packages=['partis', 'partis.cache'],
package_dir={'partis': 'partis'},
python_requires='>=3.7',
# Dependencies
install_requires=[
'biopython',
'colored-traceback',
'dendropy',
'fire',
'matplotlib',
'numpy',
'pandas',
'psutil',
'pysam',
'PyYAML',
'scikit-learn',
'scipy',
'seaborn',
'six',
],
# Optional dependencies
extras_require={
'plotting': [
'circlify',
'ete3',
'PyQt5',
'joypy',
'levenshtein',
],
},
# Entry points
entry_points={
'console_scripts': [
'partis=partis.main:main',
],
},
# Install Python scripts to PATH
scripts=[
'bin/cf-germlines.py',
'bin/cf-alleles.py',
'bin/extract-pairing-info.py',
'bin/split-loci.py',
'bin/get-naive-probabilities.py',
'bin/compare-plotdirs.py',
'bin/gctree-run.py',
'bin/make-html',
'bin/parse-output.py',
'bin/partis-test.py',
],
# Include data files
include_package_data=True,
package_data={
'partis': [
# Note: Using ../ to include files from outside the package directory
# These are runtime dependencies that need to be bundled with the package
'../bin/*',
'../data/**/*',
'../test/*.py',
'../test/*.fa',
'../test/*.yaml',
'../test/*.yml',
'../test/*.sh',
'../test/*.nwk',
'../test/paired-data/**/*',
'../test/ref-results/**/*',
'../test/paired/ref-results/**/*',
'../packages/ham/bcrham',
'../packages/ig-sw/src/ig_align/ig-sw',
'../packages/bpp/bin/bppseqgen',
'../packages/bpp/lib/*',
],
},
# Custom build commands
cmdclass={
'build_py': CustomBuildPy,
'develop': CustomDevelop,
'install': CustomInstall,
'egg_info': CustomEggInfo,
},
# Force binary distribution
distclass=BinaryDistribution,
# URLs
project_urls={
'Bug Reports': 'https://github.com/psathyrella/partis/issues',
'Source': 'https://github.com/psathyrella/partis',
'Documentation': 'https://github.com/psathyrella/partis/tree/main/docs',
},
)