Skip to content

Commit

Permalink
Merge 456fccb into df793a2
Browse files Browse the repository at this point in the history
  • Loading branch information
fgregg committed Apr 17, 2018
2 parents df793a2 + 456fccb commit 37fbea8
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 41 deletions.
2 changes: 1 addition & 1 deletion .manylinux-install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ set -e -x
# Compile wheels
for PYBIN in /opt/python/*/bin; do
if [[ "${PYBIN}" == *"cp27"* ]] || [[ "${PYBIN}" == *"cp34"* ]] || [[ "${PYBIN}" == *"cp35"* ]] || [[ "${PYBIN}" == *"cp36"* ]]; then
"${PYBIN}/pip" install --upgrade pip
"${PYBIN}/pip" install -r /io/requirements.txt
"${PYBIN}/cython" /io/lbfgs/_lowlevel.pyx
"${PYBIN}/pip" install -e /io/
"${PYBIN}/pip" wheel /io/ -w wheelhouse/
rm -rf /io/build /io/*.egg-info
Expand Down
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ matrix:
install:
- pip install --upgrade pip
- pip install -r requirements.txt
- cython lbfgs/_lowlevel.pyx
- pip install -e .
script:
- pytest tests --cov lbfgs
Expand Down
4 changes: 1 addition & 3 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,9 @@ environment:
install:
- "SET PATH=C:\\Python%PYTHON%;c:\\Python%PYTHON%\\scripts;%PATH%"
- python -m pip install --upgrade pip
- pip install numpy
- echo "C:\Program Files\Microsoft SDKs\Windows\v7.1\Bin\SetEnv.cmd" /x64 > "C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\amd64/vcvars64.bat"
- pip install -r requirements.txt
- cython lbfgs/_lowlevel.pyx
- pip install -e .
- pip install -e .

build: false

Expand Down
2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[build-system]
requires = ["setuptools", "wheel", "cython", "numpy==1.13.1"]
2 changes: 0 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
numpy
cython
pytest
pytest-cov
53 changes: 19 additions & 34 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
#!/usr/bin/env python
import sys
from setuptools import setup, Extension
from setuptools.command.build_ext import build_ext
from distutils.ccompiler import get_default_compiler
import numpy

try:
from Cython.Build import cythonize
use_cython = True
except ImportError:
use_cython = False

class custom_build_ext(build_ext):
def finalize_options(self):
Expand All @@ -15,35 +21,17 @@ def finalize_options(self):
if compiler == 'msvc':
include_dirs.append('compat/win32')

include_dirs = ['liblbfgs', numpy.get_include()]


# from Michael Hoffman's http://www.ebi.ac.uk/~hoffman/software/sunflower/
class NumpyExtension(Extension):

def __init__(self, *args, **kwargs):
Extension.__init__(self, *args, **kwargs)

self._include_dirs = self.include_dirs
del self.include_dirs # restore overwritten property

# warning: Extension is a classic class so it's not really read-only

def get_include_dirs(self):
from numpy import get_include

return self._include_dirs + [get_include()]

def set_include_dirs(self, value):
self._include_dirs = value

def del_include_dirs(self):
pass

include_dirs = property(get_include_dirs,
set_include_dirs,
del_include_dirs)

include_dirs = ['liblbfgs']
if use_cython:
ext_modules = cythonize(
[Extension('lbfgs._lowlevel',
['lbfgs/_lowlevel.pyx', 'liblbfgs/lbfgs.c'],
include_dirs=include_dirs)])
else:
ext_modules = [Extension('lbfgs._lowlevel',
['lbfgs/_lowlevel.c', 'liblbfgs/lbfgs.c'],
include_dirs=include_dirs)]

setup(
name="PyLBFGS",
Expand All @@ -52,10 +40,8 @@ def del_include_dirs(self):
author="Lars Buitinck, Forest Gregg",
author_email="fgregg@gmail.com",
packages=['lbfgs'],
install_requires=['numpy>=1.12.1'],
ext_modules=[NumpyExtension('lbfgs._lowlevel',
['lbfgs/_lowlevel.c', 'liblbfgs/lbfgs.c'],
include_dirs=include_dirs)],
install_requires=['numpy>=1.13.1'],
ext_modules=ext_modules,
classifiers=[
"Intended Audience :: Developers",
"Intended Audience :: Science/Research",
Expand All @@ -68,4 +54,3 @@ def del_include_dirs(self):
],
cmdclass={'build_ext': custom_build_ext},
)

0 comments on commit 37fbea8

Please sign in to comment.