Skip to content

Commit

Permalink
Switch to Travis CI
Browse files Browse the repository at this point in the history
  • Loading branch information
Julian Blank committed Aug 14, 2019
1 parent fcca7f4 commit 55324fe
Show file tree
Hide file tree
Showing 11 changed files with 185 additions and 179 deletions.
12 changes: 0 additions & 12 deletions .gitlab-ci.yml

This file was deleted.

11 changes: 11 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
language: python
python:
- "3.7"

install:
- pip install numpy
- python setup.py sdist
- pip install dist/*

script:
- python tests/test_suite.py
2 changes: 1 addition & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
recursive-include pymoo *.py *.cpp
recursive-exclude pymoo *.so *.pyx *.pxd

include LICENSE Makefile
include setup.py setup_ext.py LICENSE Makefile
6 changes: 4 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
clean:
rm -rf build dist pymoo.egg-info
rm -rf build builds dist pymoo.egg-info

clean-ext:
rm -f pymoo/cython/*.c
Expand All @@ -18,4 +18,6 @@ dist:

install:
python setup.py install


test:
gitlab-runner exec shell default
14 changes: 1 addition & 13 deletions pymoo/__init__.py
Original file line number Diff line number Diff line change
@@ -1,13 +1 @@
__version__ = "0.3.1"

__all__ = ["algorithms",
"cython",
"decision_making",
"model",
"operators",
"performance_indicator",
"problems",
"util",
"vendor",
"visualization",
]
from pymoo.version import __version__
4 changes: 2 additions & 2 deletions pymoo/usage/misc/usage_decompose.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from pymoo.operators.repair.out_of_bounds_repair import repair_out_of_bounds
from pymoo.optimize import minimize
from pymoo.problems.util import decompose
from pymoo.visualization.scatter import scatter
from pymoo.visualization.scatter import Scatter


class ModifiedZDT1(ZDT):
Expand Down Expand Up @@ -67,7 +67,7 @@ def _evaluate(self, x, out, *args, **kwargs):
print(pf[opt])
print(decomp.do(pf, weights).min())

plot = scatter()
plot = Scatter()
plot.add(pf)
plot.add(F)
plot.add(np.row_stack([np.zeros(2), weights]), plot_type="line")
Expand Down
4 changes: 2 additions & 2 deletions pymoo/usage/usage_problem.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,11 +128,11 @@

# START truss2d
from pymoo.factory import get_problem
from pymoo.visualization.scatter import scatter
from pymoo.visualization.scatter import Scatter

pf = get_problem("truss2d").pareto_front()

plot = scatter(title="Pareto-front")
plot = Scatter(title="Pareto-front")
plot.add(pf, s=80, facecolors='none', edgecolors='r')
plot.add(pf, plot_type="line", color="black", linewidth=2)
plot.show()
Expand Down
1 change: 1 addition & 0 deletions pymoo/version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__version__ = "0.3.1"
165 changes: 159 additions & 6 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,36 @@
from setup_ext import readme, run_setup
import distutils
import os
import sys
import traceback
from distutils.errors import CCompilerError, DistutilsExecError, DistutilsPlatformError

import setuptools
from setuptools import setup, Extension
from setuptools.command.build_ext import build_ext

from pymoo.version import __version__

# ---------------------------------------------------------------------------------------------------------
# SETUP
# ---------------------------------------------------------------------------------------------------------


__name__ = "pymoo"
__author__ = "Julian Blank"
__version__ = '0.3.1.dev'
__url__ = "https://pymoo.org"

kwargs = dict(
name=__name__,
version=__version__,
author=__author__,
url=__url__,
python_requires='>3.5',
python_requires='>=3.6',
author_email="[email protected]",
description="Multi-Objective Optimization in Python",
long_description=readme(),
license='Apache License 2.0',
keywords="optimization",
install_requires=['numpy>=1.15', 'scipy>=1.1', 'matplotlib>=3', 'autograd>=1.3'],
include_package_data=True,
packages=["pymoo"] + ["pymoo." + e for e in setuptools.find_packages(where='pymoo')],
platforms='any',
classifiers=[
'Intended Audience :: Developers',
Expand All @@ -27,7 +39,6 @@
'License :: OSI Approved :: Apache Software License',
'Programming Language :: Python',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Topic :: Scientific/Engineering',
Expand All @@ -36,4 +47,146 @@
]
)


# update the readme.rst to be part of setup
def readme():
with open('README.rst') as f:
return f.read()

kwargs['long_description'] = readme()


# ---------------------------------------------------------------------------------------------------------
# Extensions
# ---------------------------------------------------------------------------------------------------------



ext_errors = (CCompilerError, DistutilsExecError, DistutilsPlatformError, IOError)


def is_new_osx():
name = distutils.util.get_platform()
if sys.platform != "darwin":
return False
elif name.startswith("macosx-10"):
minor_version = int(name.split("-")[1].split(".")[1])
if minor_version >= 7:
return True
else:
return False
else:
return False


# fix compiling for new macosx!
if is_new_osx():
os.environ['CFLAGS'] = '-stdlib=libc++'


class BuildFailed(Exception):
pass


# try to compile, if not possible throw exception
def construct_build_ext(build_ext):
class WrappedBuildExt(build_ext):
def run(self):
try:
build_ext.run(self)
except DistutilsPlatformError as x:
raise BuildFailed(x)

def build_extension(self, ext):
try:
build_ext.build_extension(self, ext)
except ext_errors as x:
raise BuildFailed(x)

return WrappedBuildExt


def run_setup(setup_args):
# try to add compilation to the setup - if fails just do default
try:

do_cythonize = False
if "--cythonize" in sys.argv:
do_cythonize = True
sys.argv.remove("--cythonize")

# copy the kwargs
kwargs = dict(setup_args)
kwargs['cmdclass'] = {}

try:
import numpy as np
kwargs['include_dirs'] = [np.get_include()]
except:
raise BuildFailed("NumPy libraries must be installed for compiled extensions! Speedups are not enabled.")

# return the object for building which allows installation with no compilation
kwargs['cmdclass']['build_ext'] = construct_build_ext(build_ext)

# all the modules must be finally added here
kwargs['ext_modules'] = []
cython_folder = os.path.join(os.path.dirname(os.path.abspath(__file__)), "pymoo", "cython")
files = os.listdir(cython_folder)

if do_cythonize:
from Cython.Build import cythonize
kwargs['ext_modules'] = cythonize("pymoo/cython/*.pyx")
else:
cpp_files = [f for f in files if f.endswith(".cpp")]

if len(cpp_files) == 0:
print('*' * 75)
print("WARNING: No modules for compilation available. To compile pyx files, execute:")
print("make compile-with-cython")
print('*' * 75)
return

else:

for source in cpp_files:
kwargs['ext_modules'].append(
Extension("pymoo.cython.%s" % source[:-4], [os.path.join(cython_folder, source)]))

print("==========================")

if len(kwargs['ext_modules']) == 0:
print('*' * 75)
print("WARNING: No modules for compilation available. To compile pyx files, add --cythonize.")
print('*' * 75)

else:
# print(kwargs['ext_modules'])
setup(**kwargs)
print('*' * 75)
print("Compilation Successful.")
print("Installation with Compilation succeeded.")
print('*' * 75)

except BaseException as e:

setup(**setup_args)
ex_type, ex_value, ex_traceback = sys.exc_info()

print('*' * 75)
print("WARNING: Compilation Failed.")
print("WARNING:", ex_type)
print("WARNING:", ex_value)
print()
print("=" * 75)
traceback.print_exc()
print("=" * 75)
print()
print("WARNING: For the compiled libraries numpy is required. Please make sure they are installed")
print("WARNING: pip install numpy")
print("WARNING: Also, make sure you have a compiler for C++!")
print('*' * 75)
print("Plain Python installation succeeded.")
print('*' * 75)


run_setup(kwargs)
Loading

0 comments on commit 55324fe

Please sign in to comment.