Skip to content

Commit

Permalink
Add support for Windows (#151)
Browse files Browse the repository at this point in the history
Add support for Windows:

- [x] Make extra compile arguments compatible
- [x] Add Windows to build platforms in cibuildwheel action
- [x] Update readme

Extra:
- [x] Made `HCD` model name synonymous to `HCD2021` for backwards compatibility
- [x] Fixed build for macOS: Missing XGBoost dependency in build environment: `libomp`
- [x] Avoid extra test runs due to `on: [push, pull_request]` by specifying push branch

Caveats for compiled wheels: 
- 32bit platforms not built, as XGBoost wheels are missing
- Python 3.9 and 3.10 not built, as pyTables wheels are missing: PyTables/PyTables#823
  • Loading branch information
RalfG authored Nov 14, 2021
1 parent ea18527 commit 3dd2f4c
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 16 deletions.
17 changes: 10 additions & 7 deletions .github/workflows/build_and_publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.9'
python-version: '3.10'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools numpy cython flake8
pip install setuptools oldest-supported-numpy cython flake8
- name: Check for syntax errors
run: |
flake8 ./ms2pip ./fasta2speclib --count --select=E9,F63,F7,F82 --show-source --statistics
Expand All @@ -35,25 +35,28 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-18.04, macos-latest]
os: [ubuntu-18.04, windows-latest, macos-latest]
steps:
- uses: actions/checkout@v2
with:
lfs: 'true'
- uses: actions/setup-python@v2
name: Install Python
with:
python-version: '3.7'
python-version: '3.10'
- name: Check for syntax errors
run: |
pip install flake8
flake8 ./ms2pip ./fasta2speclib --count --select=E9,F63,F7,F82 --show-source --statistics
- uses: joerick/cibuildwheel@v1.7.4
- uses: joerick/cibuildwheel@v2.2.2
with:
output-dir: dist
env:
CIBW_BUILD: "cp3*-macosx_x86_64 cp3*-manylinux_x86_64"
CIBW_SKIP: "cp35-* cp39-macosx_x86_64" # see compomics/ms2pip_c#126
# No XGBoost wheels for 32bit Windows
# No PyTables wheels for Python 3.9 and 3.10 yet; see compomics/ms2pip_c#126
CIBW_BUILD: "cp3*-manylinux_x86_64 cp3*-win_amd64 cp3*-macosx_x86_64"
CIBW_SKIP: "cp39-* cp310-*"
CIBW_BEFORE_ALL_MACOS: "brew install libomp"
CIBW_MANYLINUX_X86_64_IMAGE: "manylinux2014"
CIBW_TEST_REQUIRES: "pytest"
CIBW_TEST_COMMAND: "pytest {project}/tests"
Expand Down
8 changes: 6 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
name: Tests

on: [push, pull_request]
on:
push:
branches:
- releases
pull_request:

jobs:
build:
Expand All @@ -9,7 +13,7 @@ jobs:
strategy:
max-parallel: 4
matrix:
python-version: [3.6, 3.7, 3.8, 3.9]
python-version: [3.6, 3.7, 3.8]

steps:
- uses: actions/checkout@v2
Expand Down
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,11 @@ With Python 3.6 or higher, run:
pip install ms2pip
```

Compiled wheels are available for Python 3.6, 3.7, and 3.8, on 64bit Linux,
Windows, and macOS. This should install MS²PIP in a few seconds. For other
platforms, MS²PIP can be built from source, although it can take up to one hour
to compile the large prediction models.

We recommend using a [venv](https://docs.python.org/3/library/venv.html) or
[conda](https://docs.conda.io/en/latest/) virtual environment.

Expand All @@ -86,6 +91,8 @@ Install with activated bioconda and conda-forge channels:
conda install -c defaults -c bioconda -c conda-forge ms2pip
```

Bioconda packages are only available for Linux and macOS.

#### Docker container
First check the latest version tag on [biocontainers/ms2pip/tags](https://quay.io/repository/biocontainers/ms2pip?tab=tags). Then pull and run the container with
```
Expand Down
1 change: 1 addition & 0 deletions ms2pip/ms2pipC.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@
}
},
}
MODELS["HCD"] = MODELS["HCD2021"]


def process_peptides(worker_num, data, afile, modfile, modfile2, PTMmap, model):
Expand Down
30 changes: 23 additions & 7 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
import platform
from glob import glob

from setuptools import setup
Expand Down Expand Up @@ -67,17 +68,32 @@
]
#_ = [[os.remove(f) for f in glob(pat)] for pat in to_remove]

# Large machine-written C model files require optimization to be disabled
compile_args = {
"Linux": [
"-O0",
"-fno-var-tracking",
"-Wno-unused-result",
"-Wno-cpp",
"-Wno-unused-function",
],
"Darwin": [
"-O0",
],
"Windows": [
"/Od",
"/DEBUG",
"/GL-",
"/bigobj",
"/wd4244",
]
}

extensions = [
Extension(
"ms2pip.cython_modules.ms2pip_pyx",
sources=["ms2pip/cython_modules/ms2pip_pyx.pyx"] + glob("ms2pip/models/*/*.c"),
extra_compile_args=[
"-fno-var-tracking",
"-Og",
"-Wno-unused-result",
"-Wno-cpp",
"-Wno-unused-function",
],
extra_compile_args=compile_args[platform.system()],
)
]

Expand Down

0 comments on commit 3dd2f4c

Please sign in to comment.