From 3dd2f4c879c3289e03df21ee00bba8df818e620c Mon Sep 17 00:00:00 2001 From: Ralf Gabriels Date: Sun, 14 Nov 2021 15:06:01 +0100 Subject: [PATCH] Add support for Windows (#151) 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 --- .github/workflows/build_and_publish.yml | 17 ++++++++------ .github/workflows/test.yml | 8 +++++-- README.md | 7 ++++++ ms2pip/ms2pipC.py | 1 + setup.py | 30 +++++++++++++++++++------ 5 files changed, 47 insertions(+), 16 deletions(-) diff --git a/.github/workflows/build_and_publish.yml b/.github/workflows/build_and_publish.yml index b990606b..76d75883 100644 --- a/.github/workflows/build_and_publish.yml +++ b/.github/workflows/build_and_publish.yml @@ -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 @@ -35,7 +35,7 @@ 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: @@ -43,17 +43,20 @@ jobs: - 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" diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index de0fa787..3859b12f 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,6 +1,10 @@ name: Tests -on: [push, pull_request] +on: + push: + branches: + - releases + pull_request: jobs: build: @@ -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 diff --git a/README.md b/README.md index 1e233528..b9a2456f 100644 --- a/README.md +++ b/README.md @@ -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. @@ -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 ``` diff --git a/ms2pip/ms2pipC.py b/ms2pip/ms2pipC.py index aa8b0a8e..fc3a58ec 100644 --- a/ms2pip/ms2pipC.py +++ b/ms2pip/ms2pipC.py @@ -120,6 +120,7 @@ } }, } +MODELS["HCD"] = MODELS["HCD2021"] def process_peptides(worker_num, data, afile, modfile, modfile2, PTMmap, model): diff --git a/setup.py b/setup.py index 2a52f70d..092fa340 100644 --- a/setup.py +++ b/setup.py @@ -1,4 +1,5 @@ import os +import platform from glob import glob from setuptools import setup @@ -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()], ) ]