Skip to content

Commit bfbf6ec

Browse files
committed
clean up setup.py + edit docs
1 parent e33e423 commit bfbf6ec

File tree

2 files changed

+50
-46
lines changed

2 files changed

+50
-46
lines changed

docs/install.md

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@
22

33
### Installation methods
44

5-
Partis can be installed via:
6-
- [pip and pipx](#installation-with-pip): recommended
5+
Partis can be installed via:
6+
- [pip and pipx](#installation-with-pip-or-pipx): recommended
77
- [additional steps for simulation installation](#simulation)
88
- [with Docker](#installation-with-docker)
9+
- [plotting dependencies](#plotting)
910

1011
#### Installation with pip or pipx
1112

@@ -51,6 +52,7 @@ partis-test.py --quick
5152
partis-test.py --no-simu
5253
partis-test.py --paired --no-simu
5354
```
55+
5456
#### Simulation
5557

5658
A variety of partis simulation options will work using the base install described above; however for full functionality you'll need to install R and some R packages, as well as potentially compile bio++.
@@ -108,11 +110,35 @@ Alternatively, you can detach from the container with `ctrl-q q` (or whatever yo
108110
To then reattach to this running container, run `docker attach container-1`.
109111
If you don't plan on reattaching to a container, you should run with `--rm` so it is removed when you exit; otherwise you'll use up a lot of disk space with accumulated old containers (view with `sudo docker ps -a`).
110112

111-
#### MDS Plotting
113+
#### Plotting
112114

113-
In order to make the [MDS plots](plotting.md#partition-plots), you need R and the bios2mds package installed:
115+
##### Optional Python Dependencies
116+
117+
The base installation includes all required dependencies for core partis functionality.
118+
However, some advanced plotting and analysis features require additional Python packages that can be installed as optional extras:
119+
120+
**Plotting extras** (for advanced visualization):
121+
```bash
122+
pip install partis-bcr[plotting]
123+
```
124+
Includes: `circlify`, `ete3`, `joypy`
114125

126+
**Full extras** (all optional features):
127+
```bash
128+
pip install partis-bcr[full]
115129
```
130+
Includes: `circlify`, `ete3`, `joypy`, `levenshtein`
131+
132+
If installing from source, use:
133+
```bash
134+
pip install -e .[plotting] # or .[full]
135+
```
136+
137+
##### MDS Plotting with R
138+
139+
In order to make the [MDS plots](plotting.md#partition-plots), you need R and the bios2mds package installed:
140+
141+
```bash
116142
apt-get install xorg libx11-dev libglu1-mesa-dev r-cran-rgl # may not be necessary, depending on existing R install, but is at least necessary in docker
117143
conda install -y -cr r-rgl r-essentials
118144
unset R_LIBS_SITE

setup.py

Lines changed: 20 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import os
44
import sys
55
import subprocess
6-
import shutil
76
from pathlib import Path
87
from setuptools import setup, find_packages
98
from setuptools.command.build_py import build_py
@@ -36,61 +35,40 @@ def check_system_dependencies():
3635

3736
def build_compiled_components():
3837
"""Build the required C++ components using the build script."""
39-
38+
4039
print("Building partis compiled components (ig-sw and ham)...")
41-
40+
4241
# Check system dependencies first
4342
check_system_dependencies()
44-
43+
4544
base_dir = Path(__file__).parent.absolute()
4645
build_script = base_dir / "bin" / "build.sh"
47-
46+
4847
if not build_script.exists():
4948
raise Exception(f"Build script not found at {build_script}")
50-
49+
5150
print("Compiling C++ components...")
5251
result = subprocess.run([str(build_script)], cwd=str(base_dir))
53-
52+
5453
if result.returncode != 0:
5554
raise Exception(f"Build script failed with exit code {result.returncode}")
56-
57-
print("✓ Successfully built ig-sw and ham binaries")
5855

59-
60-
class CustomBuildPy(build_py):
61-
"""Custom build command that compiles C++ components."""
62-
def run(self):
63-
# First run the standard build
64-
build_py.run(self)
65-
# Then build our C++ components
66-
build_compiled_components()
67-
68-
69-
class CustomDevelop(develop):
70-
"""Custom develop command that compiles C++ components."""
71-
def run(self):
72-
# Build C++ components first
73-
build_compiled_components()
74-
# Then run the standard develop
75-
develop.run(self)
56+
print("✓ Successfully built ig-sw and ham binaries")
7657

7758

78-
class CustomInstall(install):
79-
"""Custom install command that ensures C++ components are built."""
80-
def run(self):
81-
# Build C++ components first
82-
build_compiled_components()
83-
# Then run the standard install
84-
install.run(self)
59+
def make_custom_command(base_class):
60+
"""Factory function to create custom command classes that build C++ components."""
61+
class CustomCommand(base_class):
62+
def run(self):
63+
build_compiled_components()
64+
base_class.run(self)
65+
return CustomCommand
8566

8667

87-
class CustomEggInfo(egg_info):
88-
"""Custom egg_info command that builds C++ components early."""
89-
def run(self):
90-
# Build C++ components before creating egg info
91-
build_compiled_components()
92-
# Then run the standard egg_info
93-
egg_info.run(self)
68+
CustomBuildPy = make_custom_command(build_py)
69+
CustomDevelop = make_custom_command(develop)
70+
CustomInstall = make_custom_command(install)
71+
CustomEggInfo = make_custom_command(egg_info)
9472

9573

9674
class BinaryDistribution(Distribution):
@@ -162,14 +140,12 @@ def has_ext_modules(self):
162140
'circlify',
163141
'ete3',
164142
'joypy',
165-
'matplotlib',
166143
],
167144
'full': [
168145
'circlify',
169146
'ete3',
170147
'joypy',
171148
'levenshtein',
172-
'matplotlib',
173149
],
174150
},
175151

@@ -197,6 +173,8 @@ def has_ext_modules(self):
197173
include_package_data=True,
198174
package_data={
199175
'partis': [
176+
# Note: Using ../ to include files from outside the package directory
177+
# These are runtime dependencies that need to be bundled with the package
200178
'../bin/*',
201179
'../data/**/*',
202180
'../test/**/*',

0 commit comments

Comments
 (0)