From fec639553a1bd4aae6eced35deb7ed4b7895d3d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Filipe=20Brand=C3=A3o?= Date: Mon, 26 Feb 2024 18:20:52 +0000 Subject: [PATCH] nlwpy: Include nlwpy.test as submodule --- nl-writer2/.gitignore | 2 ++ nl-writer2/LICENSE | 29 +++++++++++++++ nl-writer2/MANIFEST.in | 1 + nl-writer2/nlwpy/conda.recipe/meta.yaml | 35 ------------------- nl-writer2/nlwpy/test/__init__.py | 2 ++ nl-writer2/nlwpy/test/__main__.py | 3 ++ .../nlwpy/{tests => test}/test_solve.py | 0 nl-writer2/nlwpy/tests/__init__.py | 0 nl-writer2/setup.py | 33 ++++++++++------- 9 files changed, 57 insertions(+), 48 deletions(-) create mode 100644 nl-writer2/LICENSE delete mode 100644 nl-writer2/nlwpy/conda.recipe/meta.yaml create mode 100644 nl-writer2/nlwpy/test/__init__.py create mode 100644 nl-writer2/nlwpy/test/__main__.py rename nl-writer2/nlwpy/{tests => test}/test_solve.py (100%) delete mode 100644 nl-writer2/nlwpy/tests/__init__.py diff --git a/nl-writer2/.gitignore b/nl-writer2/.gitignore index ec4d995da..8469ea0dc 100644 --- a/nl-writer2/.gitignore +++ b/nl-writer2/.gitignore @@ -5,3 +5,5 @@ *.so dist/ build/ +__pycache__ + diff --git a/nl-writer2/LICENSE b/nl-writer2/LICENSE new file mode 100644 index 000000000..4f7e92262 --- /dev/null +++ b/nl-writer2/LICENSE @@ -0,0 +1,29 @@ +BSD 3-Clause License + +Copyright (c) 2024, AMPL Optimization inc. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +* Neither the name of the copyright holder nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. \ No newline at end of file diff --git a/nl-writer2/MANIFEST.in b/nl-writer2/MANIFEST.in index 00e8c5bef..793c0c468 100644 --- a/nl-writer2/MANIFEST.in +++ b/nl-writer2/MANIFEST.in @@ -1,2 +1,3 @@ recursive-include include *.h *.hpp recursive-include nlwpy *.py +include LICENSE diff --git a/nl-writer2/nlwpy/conda.recipe/meta.yaml b/nl-writer2/nlwpy/conda.recipe/meta.yaml deleted file mode 100644 index ce9119a6e..000000000 --- a/nl-writer2/nlwpy/conda.recipe/meta.yaml +++ /dev/null @@ -1,35 +0,0 @@ -package: - name: python_example - version: 0.0.1 - -source: - path: .. - -build: - number: 0 - script: {{ PYTHON }} -m pip install . -vvv - -requirements: - build: - - {{ compiler('cxx') }} - - host: - - python - - pip - - pybind11 >=2.10.0 - - run: - - python - - -test: - imports: - - python_example - source_files: - - tests - commands: - - python tests/test.py - -about: - summary: An example project built with pybind11. - license_file: LICENSE diff --git a/nl-writer2/nlwpy/test/__init__.py b/nl-writer2/nlwpy/test/__init__.py new file mode 100644 index 000000000..9e3798031 --- /dev/null +++ b/nl-writer2/nlwpy/test/__init__.py @@ -0,0 +1,2 @@ +# nlwpy tests +# $ pytest --pyargs nlwpy diff --git a/nl-writer2/nlwpy/test/__main__.py b/nl-writer2/nlwpy/test/__main__.py new file mode 100644 index 000000000..cffb5ca4b --- /dev/null +++ b/nl-writer2/nlwpy/test/__main__.py @@ -0,0 +1,3 @@ +import pytest + +pytest.main(["--pyargs", "nlwpy.test"]) diff --git a/nl-writer2/nlwpy/tests/test_solve.py b/nl-writer2/nlwpy/test/test_solve.py similarity index 100% rename from nl-writer2/nlwpy/tests/test_solve.py rename to nl-writer2/nlwpy/test/test_solve.py diff --git a/nl-writer2/nlwpy/tests/__init__.py b/nl-writer2/nlwpy/tests/__init__.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/nl-writer2/setup.py b/nl-writer2/setup.py index 6a3dafe4e..59350dd0f 100644 --- a/nl-writer2/setup.py +++ b/nl-writer2/setup.py @@ -1,20 +1,11 @@ # Available at setup time due to pyproject.toml -from pybind11.setup_helpers import build_ext from setuptools import setup, Extension import pybind11 import glob +import os __version__ = "0.0.1b0" -# The main interface is through Pybind11Extension. -# * You can add cxx_std=11/14/17, and then build_ext can be removed. -# * You can set include_pybind11=false to add the include directory yourself, -# say from a submodule. -# -# Note: -# Sort input source files if you glob sources to ensure bit-for-bit -# reproducible builds (https://github.com/pybind/python_example/pull/53) - def compile_args(): from platform import system @@ -40,8 +31,26 @@ def compile_args(): return [] +def ls_dir(base_dir): + return [ + os.path.join(dirpath, fname) + for (dirpath, dirnames, files) in os.walk(base_dir) + for fname in files + ] + + +def package_content(): + files = ls_dir("nlwpy/") + return [ + fpath.replace("nlwpy/", "", 1) + for fpath in files + if "__pycache__" not in fpath and fpath.endswith(".py") + ] + + setup( name="nlwpy", + license="BSD-3", version=__version__, author="Gleb Belov", author_email="gleb@ampl.com", @@ -58,10 +67,8 @@ def compile_args(): define_macros=[("VERSION_INFO", __version__)], ), ], + package_data={"": package_content()}, extras_require={"test": "pytest"}, - # Currently, build_ext only provides an optional "highest supported C++ - # level" feature, but in the future it may provide more features. - cmdclass={"build_ext": build_ext}, zip_safe=False, python_requires=">=3.7", )