From nobody Sun Jun 19 21:38:14 2022 X-Original-To: dev-commits-ports-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 68386866C41; Sun, 19 Jun 2022 21:38:14 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4LR5jy2RZXz4jlm; Sun, 19 Jun 2022 21:38:14 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1655674694; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=D/hrKTzay5u1F00IZOCpK15N+AQN48pDJjG4S/sUxEw=; b=htD2UgtN/bfaalYlZxGe9qoR/7PvFVSccWHFhGWZTVFlLSOSr9p/955FXtFtfvhTWF1eWY ew7iGtCUfsV6nK4B4Pyb1ye/lK/36Zudp2783TYe7FHHGBncmA0yTtxsjlVvd4jQwjTStA CsGPBvx/Vx72phcf+y4nHMGfrtHbNNJhNe4OExK4Gpli7PoivO+84RMe5tIB4H/f1rbFEe sW6v41ymnMR1xafHg23MgzXqCBRn9lkYJl9Gf0gDLqmeYFjc0VxyaczaGDqUmkaFsp+SkU JRK35SNiyK2bPn5A9QZBLc5MkwbdUq9GyBcQFV2cCHvFv7K9azSwNger8UPffw== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 3080F10D93; Sun, 19 Jun 2022 21:38:14 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 25JLcErj072341; Sun, 19 Jun 2022 21:38:14 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 25JLcESY072340; Sun, 19 Jun 2022 21:38:14 GMT (envelope-from git) Date: Sun, 19 Jun 2022 21:38:14 GMT Message-Id: <202206192138.25JLcESY072340@gitrepo.freebsd.org> To: ports-committers@FreeBSD.org, dev-commits-ports-all@FreeBSD.org, dev-commits-ports-main@FreeBSD.org From: Yuri Victorovich Subject: git: 1b6bef5d436a - main - math/py-nlopt: New port: Nonlinear optimization library List-Id: Commits to the main branch of the FreeBSD ports repository List-Archive: https://lists.freebsd.org/archives/dev-commits-ports-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-ports-main@freebsd.org X-BeenThere: dev-commits-ports-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: yuri X-Git-Repository: ports X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 1b6bef5d436ab3213b9996a06880e155ffaadd06 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1655674694; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=D/hrKTzay5u1F00IZOCpK15N+AQN48pDJjG4S/sUxEw=; b=IT4e+8CKAQ4NnEO6q34BdgcgOb09TGOstAAGrlZ6Ln7ZtFwr08BexC2oT8Uh5WUGS0jAUw 3Uz/ujZXw8N11IMzYjrmsa/Cf/5AjRcKXs6CDwOp1buQWmtf701Y33u+wUImpAPAMKqzOs etTP9z+ZMgMSXtj1bvlbhW0Mzkq7YE0K9c1s6D5+KnxxapiWZEijXcnfWbOTMylsmVCMQ5 S6KK13j7LErIrekpNzlSPX2dRwZgblyV4Lq5kAe40hq1/snfbUQU1KUz9AH8NMTD46Ijuc uP7FQdzNLHjL9GuLbCgmIo7uU2KOuWa6ELplLM7NUrhty/ZbS8HAlHCNv47YsQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1655674694; a=rsa-sha256; cv=none; b=c1yH1y4EUZqvUGxK5Ee5o2Jfvs4FzEDNRc5mS+HE8B2Wp4u7RjJUXu7bRArzkQaCGHGnu+ CsQvGxeYMGy1alsc9LJD/TKD4mOgbWgpwRnKF0K18ssgVqY3XZwgPnvEDuf4+JO0lP0En6 +aNcC9vR6MaUXDqCGROvKjDlqpj7HTNrwKIC71xpV+vQw5HE6ITVbRwwK9Fm1r5D1RtAhi kYUyicEMJ9qOk0+BAH4XSfSNYtUdeimFNxqZwLiuYZxpC4qF+BdYUsBd9EejaDvvsp2IVZ nP/VDPXHtXQpaaXH6SgFyjuVpVUPB2F4M4x7xSkQVVI9vMCPnmQ+16sB/vmaig== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by yuri: URL: https://cgit.FreeBSD.org/ports/commit/?id=1b6bef5d436ab3213b9996a06880e155ffaadd06 commit 1b6bef5d436ab3213b9996a06880e155ffaadd06 Author: Yuri Victorovich AuthorDate: 2022-06-19 21:37:32 +0000 Commit: Yuri Victorovich CommitDate: 2022-06-19 21:38:11 +0000 math/py-nlopt: New port: Nonlinear optimization library --- math/Makefile | 1 + math/py-nlopt/Makefile | 33 +++++++++++++++++++++++++++++++++ math/py-nlopt/distinfo | 5 +++++ math/py-nlopt/files/example.py | 24 ++++++++++++++++++++++++ math/py-nlopt/files/patch-extensions.py | 11 +++++++++++ math/py-nlopt/pkg-descr | 4 ++++ math/py-nlopt/pkg-plist | 7 +++++++ 7 files changed, 85 insertions(+) diff --git a/math/Makefile b/math/Makefile index 10558e48f46b..ba5ac17f60e8 100644 --- a/math/Makefile +++ b/math/Makefile @@ -897,6 +897,7 @@ SUBDIR += py-ndindex SUBDIR += py-networkx SUBDIR += py-nevergrad + SUBDIR += py-nlopt SUBDIR += py-numexpr SUBDIR += py-numpoly SUBDIR += py-numpy diff --git a/math/py-nlopt/Makefile b/math/py-nlopt/Makefile new file mode 100644 index 000000000000..b47a8898a4ee --- /dev/null +++ b/math/py-nlopt/Makefile @@ -0,0 +1,33 @@ +PORTNAME= nlopt +DISTVERSION= 2.7.1 +CATEGORIES= math +#MASTER_SITES= CHEESESHOP # https://github.com/DanielBok/nlopt-python/issues/15 +PKGNAMEPREFIX= ${PYTHON_PKGNAMEPREFIX} + +MAINTAINER= yuri@FreeBSD.org +COMMENT= Nonlinear optimization library + +LICENSE= LGPL21 MIT +LICENSE_COMB= multi +LICENSE_FILE= ${WRKSRC}/LICENSE + +BUILD_DEPENDS= cmake:devel/cmake \ + swig:devel/swig \ + ${PYNUMPY} +RUN_DEPENDS= ${PYNUMPY} + +USES= python +USE_PYTHON= distutils # autoplist is broken, see https://github.com/DanielBok/nlopt-python/issues/17 + +USE_GITHUB= yes +GH_ACCOUNT= DanielBok +GH_PROJECT= nlopt-python +GH_TUPLE= stevengj:nlopt:4a0e93c:nlopt/extern/nlopt + +post-install: + @${STRIP_CMD} ${STAGEDIR}${PYTHON_SITELIBDIR}/nlopt/_nlopt.so + +do-test: + @${SETENV} ${TEST_ENV} PYTHONPATH=${STAGEDIR}${PYTHONPREFIX_SITELIBDIR} ${PYTHON_CMD} ${FILESDIR}/example.py + +.include diff --git a/math/py-nlopt/distinfo b/math/py-nlopt/distinfo new file mode 100644 index 000000000000..d896243b4cf7 --- /dev/null +++ b/math/py-nlopt/distinfo @@ -0,0 +1,5 @@ +TIMESTAMP = 1655669851 +SHA256 (DanielBok-nlopt-python-2.7.1_GH0.tar.gz) = 838a46f67309b1e1f63227a27726e8a7be19f9b05f0972d40b98a52ccfb799fb +SIZE (DanielBok-nlopt-python-2.7.1_GH0.tar.gz) = 6749 +SHA256 (stevengj-nlopt-4a0e93c_GH0.tar.gz) = 3d8036633821df60f387431fde51cd11c125743a24ccbda40221518ad21663a4 +SIZE (stevengj-nlopt-4a0e93c_GH0.tar.gz) = 2044242 diff --git a/math/py-nlopt/files/example.py b/math/py-nlopt/files/example.py new file mode 100644 index 000000000000..bcde61ba78f8 --- /dev/null +++ b/math/py-nlopt/files/example.py @@ -0,0 +1,24 @@ +import nlopt +from numpy import * +def myfunc(x, grad): + if grad.size > 0: + grad[0] = 0.0 + grad[1] = 0.5 / sqrt(x[1]) + return sqrt(x[1]) +def myconstraint(x, grad, a, b): + if grad.size > 0: + grad[0] = 3 * a * (a*x[0] + b)**2 + grad[1] = -1.0 + return (a*x[0] + b)**3 - x[1] +opt = nlopt.opt(nlopt.LD_MMA, 2) +opt.set_lower_bounds([-float('inf'), 0]) +opt.set_min_objective(myfunc) +opt.add_inequality_constraint(lambda x,grad: myconstraint(x,grad,2,0), 1e-8) +opt.add_inequality_constraint(lambda x,grad: myconstraint(x,grad,-1,1), 1e-8) +opt.set_xtol_rel(1e-4) +x = opt.optimize([1.234, 5.678]) +minf = opt.last_optimum_value() +print("optimum at ", x[0], x[1]) +print("minimum value = ", minf) +print("result code = ", opt.last_optimize_result()) + diff --git a/math/py-nlopt/files/patch-extensions.py b/math/py-nlopt/files/patch-extensions.py new file mode 100644 index 000000000000..1c8cfb1104cd --- /dev/null +++ b/math/py-nlopt/files/patch-extensions.py @@ -0,0 +1,11 @@ +--- extensions.py.orig 2022-06-19 20:42:31 UTC ++++ extensions.py +@@ -25,7 +25,7 @@ class NLOptBuild(build_ext): + except OSError: + raise RuntimeError("CMake must be installed") + +- if platform.system() not in ("Windows", "Linux", "Darwin"): ++ if platform.system() not in ("Windows", "Linux", "Darwin", "FreeBSD"): + raise RuntimeError(f"Unsupported os: {platform.system()}") + + for ext in self.extensions: diff --git a/math/py-nlopt/pkg-descr b/math/py-nlopt/pkg-descr new file mode 100644 index 000000000000..9d5064c5cdc6 --- /dev/null +++ b/math/py-nlopt/pkg-descr @@ -0,0 +1,4 @@ +Python bindings for NLOpt that contains various routines for +non-linear optimization. + +WWW: https://github.com/DanielBok/nlopt-python diff --git a/math/py-nlopt/pkg-plist b/math/py-nlopt/pkg-plist new file mode 100644 index 000000000000..325f0732f7c5 --- /dev/null +++ b/math/py-nlopt/pkg-plist @@ -0,0 +1,7 @@ +%%PYTHON_SITELIBDIR%%/nlopt/__init__.py +%%PYTHON_SITELIBDIR%%/nlopt/__pycache__/__init__%%PYTHON_EXT_SUFFIX%%.opt-1.pyc +%%PYTHON_SITELIBDIR%%/nlopt/__pycache__/__init__%%PYTHON_EXT_SUFFIX%%.pyc +%%PYTHON_SITELIBDIR%%/nlopt/__pycache__/nlopt%%PYTHON_EXT_SUFFIX%%.opt-1.pyc +%%PYTHON_SITELIBDIR%%/nlopt/__pycache__/nlopt%%PYTHON_EXT_SUFFIX%%.pyc +%%PYTHON_SITELIBDIR%%/nlopt/_nlopt.so +%%PYTHON_SITELIBDIR%%/nlopt/nlopt.py