Skip to content

Commit

Permalink
Windows support
Browse files Browse the repository at this point in the history
Signed-off-by: Conor MacBride <conor@macbride.me>
  • Loading branch information
ConorMacBride committed Nov 7, 2020
1 parent c2b2f0e commit 44a28c6
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 4 deletions.
9 changes: 8 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,21 @@ jobs:
os: osx
osx_image: xcode11.2
language: shell
- name: "Python 3.8.0 on Windows"
os: windows
language: shell
before_install:
- choco install python --version 3.8.0
- python -m pip install --upgrade pip
env: PATH=/c/Python38:/c/Python38/Scripts:$PATH
install:
- pip3 install --upgrade pip
- pip3 install -e .
script: python3 -m pytest --cov=mcalf || python -m pytest --cov=mcalf
after_script: cd ~
deploy:
provider: pypi
user: "__token__"
username: "__token__"
password:
secure: "uxdVaVDzDGLC2GzxI1xz4iFqNF1aSM39r1fP3Y5bRx7TTArZka96hoaUD38jNJndebUW/caVv9gkqrEUMdL6YKE6/1orpNNcqBug+mUsglwI8fR7pDaZGqubdf583qNbpWfvzaNR8FX1IQCHc1PQNhp1dPFHGUYkQY6ILX3bltcX1998/4xkkH6SOVuLNn63itW5i5L6sd2kRu4ooBWgQBIKEHQ31RsawkVeZtMcnsh7vi2iJW53sGj5D6PaBjxZ8kphe8bA4On7bIGe44i5JgPAu9ksuH9GbV6xks/0d4l2OrVFa2IrGKs35S8idwFpipXiPmti2u5sDhIhMxHTO2l3/jPYpbgXO/id5lTbUV3xvqaeugoFqiqiB5WkwN+6KHv0gSox3UPoPpkdoWltWBNHTjoxHnt7IKtmawD23Mu9SR4k5QfSET9a3awyzvrFRoFk6S5payBVNlvEdM/2V3c/YTBNDTrWbllXtBRbs2/Ej86GqR+JF3IFPaHi495Yegvdc9cT570m7IHvY/AUxrbm8aBGIsMIOwPXPmdC3+Y1RDDfTTmh+HxJmkHGonox6MoKMwB5YF6CuPHyI9PeKqi7yzK6dZ1bFFi6/GItUAklecHyfDB+cP60HPOhyj18LwkzdYtUPOLc8pYf4jtsjXQfp6INl7IIrLZ9mI0IHV8="
skip_existing: true
Expand Down
2 changes: 1 addition & 1 deletion cextern/voigt.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include <math.h>

double func(int n, double args[n]) {
double func(int n, double args[]) {
return exp( - pow(args[0], 2.0) / (2.0 * pow(args[2], 2.0))) / (pow(args[3], 2.0) + pow(args[1] - args[0], 2.0));
}
35 changes: 33 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,36 @@

import os.path
from setuptools import setup, find_packages, Extension
from distutils.command.build_ext import build_ext


class build_ext(build_ext):

def build_extension(self, ext):
self._ctypes = isinstance(ext, CTypes)
return super().build_extension(ext)

def get_export_symbols(self, ext):
if self._ctypes:
return ext.export_symbols
return super().get_export_symbols(ext)

def get_ext_filename(self, ext_name):
if self._ctypes:
# Ensure that the extension ends in ".so"
# Modified version of parent method
from distutils.sysconfig import get_config_var
ext_suffix = get_config_var('EXT_SUFFIX')
expanded_suffix = ext_suffix.split('.')
expanded_suffix[-1] = "so"
ext_suffix = ".".join(expanded_suffix)
ext_path = ext_name.split('.')
return os.path.join(*ext_path) + ext_suffix
return super().get_ext_filename(ext_name)


class CTypes(Extension):
pass


def read(file_name):
Expand All @@ -19,11 +49,12 @@ def read(file_name):
"pyyaml>=5.1", "pathos>=0.2.5", "scikit-learn>=0.21",
"matplotlib>=3.1", "astropy>=3.2", "pytest", "pytest-cov"],

ext_modules=[Extension("mcalf.profiles.ext_voigtlib", ["cextern/voigt.c"])],
ext_modules=[CTypes("mcalf.profiles.ext_voigtlib", ["cextern/voigt.c"])],
cmdclass={'build_ext': build_ext},

author="Conor MacBride",
author_email="cmacbride01@qub.ac.uk",
licence="BSD 2-Clause",
license="BSD 2-Clause",
description="MCALF: Multi-Component Atmospheric Line Fitting",
keywords="spectrum spectra fitting absorption emission voigt",
url="https://github.com/ConorMacBride/mcalf/",
Expand Down

0 comments on commit 44a28c6

Please sign in to comment.