From d18cb974cd3ecf555303c96740a26d8991acc5da Mon Sep 17 00:00:00 2001 From: vsoch Date: Wed, 21 Feb 2024 01:48:06 -0700 Subject: [PATCH] init: skeleton of project with basic plugin setup Problem: we need an easy interface for developers to write plugins! A plugin can be an extractor or (TBA) other. Generally speaking, it will run a tool of interest and map the output (e.g., application performance or similar) into a namespace defined for a compatibility specification. The calling library (compspec) discovers the plugin and knows how to handle validation and execution of these steps along with packaging of the metadata. It is going to be neat! Signed-off-by: vsoch --- .github/CODE_OF_CONDUCT.md | 73 +++++++ .github/dev-requirements.txt | 4 + .gitignore | 7 + .pre-commit-config.yaml | 31 +++ CHANGELOG.md | 17 ++ COPYRIGHT | 15 ++ LICENSE | 21 ++ MANIFEST.in | 8 + NOTICE | 21 ++ README.md | 53 +++++ compspec_ior/__init__.py | 2 + compspec_ior/plugin.py | 37 ++++ compspec_ior/schema.json | 366 +++++++++++++++++++++++++++++++++++ compspec_ior/version.py | 20 ++ pyproject.toml | 7 + pytest.ini | 7 + setup.cfg | 6 + setup.py | 101 ++++++++++ 18 files changed, 796 insertions(+) create mode 100644 .github/CODE_OF_CONDUCT.md create mode 100644 .github/dev-requirements.txt create mode 100644 .gitignore create mode 100644 .pre-commit-config.yaml create mode 100644 CHANGELOG.md create mode 100644 COPYRIGHT create mode 100644 LICENSE create mode 100644 MANIFEST.in create mode 100644 NOTICE create mode 100644 README.md create mode 100644 compspec_ior/__init__.py create mode 100644 compspec_ior/plugin.py create mode 100644 compspec_ior/schema.json create mode 100644 compspec_ior/version.py create mode 100644 pyproject.toml create mode 100644 pytest.ini create mode 100644 setup.cfg create mode 100644 setup.py diff --git a/.github/CODE_OF_CONDUCT.md b/.github/CODE_OF_CONDUCT.md new file mode 100644 index 0000000..daf4a29 --- /dev/null +++ b/.github/CODE_OF_CONDUCT.md @@ -0,0 +1,73 @@ +# Contributor Covenant Code of Conduct + +## Our Pledge + +In the interest of fostering an open and welcoming environment, we as +contributors and maintainers pledge to making participation in our project and +our community a harassment-free experience for everyone, regardless of age, body +size, disability, ethnicity, sex characteristics, gender identity and expression, +level of experience, education, socio-economic status, nationality, personal +appearance, race, religion, or sexual identity and orientation. + +## Our Standards + +Examples of behavior that contributes to creating a positive environment +include: + +* Using welcoming and inclusive language +* Being respectful of differing viewpoints and experiences +* Gracefully accepting constructive criticism +* Focusing on what is best for the community +* Showing empathy towards other community members + +Examples of unacceptable behavior by participants include: + +* The use of sexualized language or imagery and unwelcome sexual attention or + advances +* Trolling, insulting/derogatory comments, and personal or political attacks +* Public or private harassment +* Publishing others' private information, such as a physical or electronic + address, without explicit permission +* Other conduct which could reasonably be considered inappropriate in a + professional setting + +## Our Responsibilities + +Project maintainers are responsible for clarifying the standards of acceptable +behavior and are expected to take appropriate and fair corrective action in +response to any instances of unacceptable behavior. + +Project maintainers have the right and responsibility to remove, edit, or +reject comments, commits, code, wiki edits, issues, and other contributions +that are not aligned to this Code of Conduct, or to ban temporarily or +permanently any contributor for other behaviors that they deem inappropriate, +threatening, offensive, or harmful. + +## Scope + +This Code of Conduct applies both within project spaces and in public spaces +when an individual is representing the project or its community. Examples of +representing a project or community include using an official project e-mail +address, posting via an official social media account, or acting as an appointed +representative at an online or offline event. Representation of a project may be +further defined and clarified by project maintainers. + +## Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behavior may be +reported by contacting the project team leader @vsoch. All +complaints will be reviewed and investigated and will result in a response that +is deemed necessary and appropriate to the circumstances. The project team is +obligated to maintain confidentiality with regard to the reporter of an incident. +Further details of specific enforcement policies may be posted separately. + +Project maintainers who do not follow or enforce the Code of Conduct in good +faith may face temporary or permanent repercussions as determined by other +members of the project's leadership. + +## Attribution + +This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, +available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html + +[homepage]: https://www.contributor-covenant.org diff --git a/.github/dev-requirements.txt b/.github/dev-requirements.txt new file mode 100644 index 0000000..6116de3 --- /dev/null +++ b/.github/dev-requirements.txt @@ -0,0 +1,4 @@ +pre-commit +black==23.3.0 +isort +flake8 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4217d33 --- /dev/null +++ b/.gitignore @@ -0,0 +1,7 @@ +.eggs +compspec_ior.egg-info +*.so +build +__pycache__ +env +dist diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..3f140ca --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,31 @@ +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.3.0 + hooks: + - id: check-added-large-files + - id: check-case-conflict + - id: check-docstring-first + - id: end-of-file-fixer + - id: trailing-whitespace + - id: mixed-line-ending + + - repo: local + hooks: + - id: black + name: black + language: python + types: [python] + entry: black + + - id: isort + name: isort + args: [--filter-files] + language: python + types: [python] + entry: isort + + - id: flake8 + name: flake8 + language: python + types: [python] + entry: flake8 diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..570ac0a --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,17 @@ +# CHANGELOG + +This is a manually generated log to track changes to the repository for each release. +Each section should include general headers such as **Implemented enhancements** +and **Merged pull requests**. Critical items to know are: + + - renamed commands + - deprecated / removed commands + - changed defaults + - backward incompatible changes (recipe file format? image file format?) + - migration guidance (how to convert images?) + - changed behaviour (recipe sections work differently) + +The versions coincide with releases on pip. Only major versions will be released as tags on Github. + +## [0.0.x](https://github.com/compspec/compspec-ior/tree/main) (0.0.x) + - Initial creation of project skeleton (0.0.0) diff --git a/COPYRIGHT b/COPYRIGHT new file mode 100644 index 0000000..d7b7eb5 --- /dev/null +++ b/COPYRIGHT @@ -0,0 +1,15 @@ +Intellectual Property Notice +---------------------------- + +HPCIC DevTools is licensed under the MIT license (LICENSE). + +Copyrights and patents in this project are retained by +contributors. No copyright assignment is required to contribute to +HPCIC DevTools. + +SPDX usage +------------ + +Individual files contain SPDX tags instead of the full license text. +This enables machine processing of license information based on the SPDX +License Identifiers that are available here: https://spdx.org/licenses/ diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..410569d --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2024 LLNS, LLC and other HPCIC DevTools Developers. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 0000000..fc1fc95 --- /dev/null +++ b/MANIFEST.in @@ -0,0 +1,8 @@ +include README.md LICENSE +recursive-include compspec_ior * +prune OLD* +prune env* +global-exclude .env +global-exclude *.py[co] +recursive-exclude .git * +global-exclude __pycache__ diff --git a/NOTICE b/NOTICE new file mode 100644 index 0000000..3737d5a --- /dev/null +++ b/NOTICE @@ -0,0 +1,21 @@ +This work was produced under the auspices of the U.S. Department of +Energy by Lawrence Livermore National Laboratory under Contract +DE-AC52-07NA27344. + +This work was prepared as an account of work sponsored by an agency of +the United States Government. Neither the United States Government nor +Lawrence Livermore National Security, LLC, nor any of their employees +makes any warranty, expressed or implied, or assumes any legal liability +or responsibility for the accuracy, completeness, or usefulness of any +information, apparatus, product, or process disclosed, or represents that +its use would not infringe privately owned rights. + +Reference herein to any specific commercial product, process, or service +by trade name, trademark, manufacturer, or otherwise does not necessarily +constitute or imply its endorsement, recommendation, or favoring by the +United States Government or Lawrence Livermore National Security, LLC. + +The views and opinions of authors expressed herein do not necessarily +state or reflect those of the United States Government or Lawrence +Livermore National Security, LLC, and shall not be used for advertising +or product endorsement purposes. diff --git a/README.md b/README.md new file mode 100644 index 0000000..bcaa156 --- /dev/null +++ b/README.md @@ -0,0 +1,53 @@ +# Compspec IOR + +

+ +

+ +A compspec (Composition spec) is a specification and model for comparing things. Compspec IOR is +a plugin for extraction of [IOR](https://github.com/hpc/ior) metadata from applications, and packaging in compatibility specification +artifacts. This means that we also maintain the compatibility schema here. To learn more: + + - [Compspec](https://github.com/compspec/compspec): the Python library that discovers and loads this plugin. + - [Compatibility](https://github.com/compspec/spec/tree/main/compatibility): of container images and applications to a host environment. + - [Compspec Go](https://github.com/compspec/compspec-go): the Go library that retrieves artifacts and makes graphs for image selection and scheduling. + + +## Usage + +Install compspec and the plugin here: + +```bash +pip install compspec +pip install compspec-ior +``` + +Then run an extraction with IOR. You can use defaults, or add any parameters to IOR after the plugin name "ior" + +```bash +compspec extract ior ... +``` + +More coming soon! + +## TODO + +- Developer environment with IOR installed (for others and me too) +- testing, etc with pre-commit and spell checking +- implement run functionality + - use reasonable defaults for when nothing provided + - outputs should map to new schema.json attributes + - main library compspec should have support for oras push, etc. + +## License + +HPCIC DevTools is distributed under the terms of the MIT license. +All new contributions must be made under this license. + +See [LICENSE](https://github.com/converged-computing/cloud-select/blob/main/LICENSE), +[COPYRIGHT](https://github.com/converged-computing/cloud-select/blob/main/COPYRIGHT), and +[NOTICE](https://github.com/converged-computing/cloud-select/blob/main/NOTICE) for details. + +SPDX-License-Identifier: (MIT) + +LLNL-CODE- 842614 diff --git a/compspec_ior/__init__.py b/compspec_ior/__init__.py new file mode 100644 index 0000000..6a49c28 --- /dev/null +++ b/compspec_ior/__init__.py @@ -0,0 +1,2 @@ +from .plugin import ExtractorPlugin +from .version import __version__ diff --git a/compspec_ior/plugin.py b/compspec_ior/plugin.py new file mode 100644 index 0000000..d938094 --- /dev/null +++ b/compspec_ior/plugin.py @@ -0,0 +1,37 @@ +import argparse + +from compspec.plugin import Plugin + + +class ExtractorPlugin(Plugin): + """ + The IOR extractor plugin + """ + + description = "IOR parallel I/O benchmarks" + + def add_arguments(self, subparser): + """ + Add arguments for the plugin to show up in argparse + """ + ior = subparser.add_parser( + self.name, + formatter_class=argparse.RawTextHelpFormatter, + description=self.description, + ) + ior.add_argument( + "args", + help="Arguments for IOR (defaults to reasonable set if not defined)", + nargs="?", + ) + + def run(self, args): + """ + Run IOR and map metadata into compspec schema. + """ + # TODO + print(args) + print("RUN IOR HERE - choose defaults if") + import IPython + + IPython.embed() diff --git a/compspec_ior/schema.json b/compspec_ior/schema.json new file mode 100644 index 0000000..60642e6 --- /dev/null +++ b/compspec_ior/schema.json @@ -0,0 +1,366 @@ +{ + "graph": { + "id": "hpc.ior", + "type": "compspec", + "label": "compatibilities", + "nodes": { + "modules": { + "label": "IOR modules" + }, + "module.cephfs": { + "label": "cephfs module" + }, + "module.cephfs.olazy": { + "label": "enable Lazy I/O" + }, + "module.mmap": { + "label": "MMAP module" + }, + "module.mmap.madv_dont_need": { + "label": "Use advise don't need" + }, + "module.mmap.madv_pattern": { + "label": "Use advise to indicate the pattern random/sequential" + }, + "module.ncmpi": { + "label": "NCMPI module" + }, + "module.ncmpi.preallocate": { + "label": "Preallocate file size" + }, + "module.ncmpi.use_strided_datatype": { + "label": "put strided access into datatype" + }, + "module.ncmpi.use_file_view": { + "label": "Use MPI_File_set_view" + }, + "module.mpiio": { + "label": "Module MPIIO" + }, + "module.mpiio.preallocate": { + "label": "Preallocate file size" + }, + "module.mpiio.use_strided_datatype": { + "label": "put strided access into datatype" + }, + "module.mpiio.use_file_view": { + "label": "Use MPI_File_set_view" + }, + "module.dummy": { + "label": "Module DUMMY" + }, + "module.dummy.delay_only_rank0": { + "label": "Delay only Rank0" + }, + "module.dummy.delay_create_rank0": { + "label": "Delay per create in usec" + }, + "module.dummy.delay_close0": { + "label": "Delay per close in usec" + }, + "module.dummy.delay_sync0": { + "label": "Delay for sync in usec" + }, + "module.dummy.delay_xfer0": { + "label": "Delay per xfer in usec" + }, + "module.posix": { + "label": "POSIX module" + }, + "module.posix.odirect": { + "label": "Direct I/O Mode" + }, + "module.posix.rangelocks": { + "label": "Use range locks (read locks for read ops)" + }, + "options": { + "label": "Options for running IOR" + }, + "options.api": { + "label": "API for I/O [POSIX|PMDK|DUMMY|MPIIO|NCMPI|MMAP|CEPHFS|Gfarm]" + }, + "options.blocksize": { + "label": "contiguous bytes to write per task (e.g.: 8, 4k, 2m, 1g)" + }, + "options.inter_test_delay": { + "label": "delay between reps in seconds" + }, + "options.deadline_for_stonewalling": { + "label": "seconds before stopping write or read phase" + }, + "options.stonewalling_wear_out": { + "label": "once the stonewalling timeout is over, all process finish to access the amount of data" + }, + "options.stonewalling_wear_out_iterations": { + "label": "stop after processing this number of iterations, needed for reading data back written with" + }, + "options.min_time_duration": { + "label": "minimum Runtime for the run (will repeat from beginning of the file if time is not yet over)" + }, + "options.script_file": { + "label": "test script name" + }, + "options.set_timestamp_signature": { + "label": "set value for time stamp signature/random seed" + }, + "options.repetitions": { + "label": "number of repetitions of test" + }, + "options.outlier_threshold": { + "label": "warn on outlier N seconds from mean" + }, + "options.datapacket_type": { + "label": "type of packet that will be created [offset|incompressible|timestamp|random|o|i|t|r]" + }, + "options.num_tasks": { + "label": "number of tasks that are participating in the test (overrides MPI)" + }, + "options.test_file": { + "label": "full name for test" + }, + "options.task_per_node_offset": { + "label": "for read tests use with -C & -Z options (-C constant N, -Z at least N)" + }, + "options.segment_count": { + "label": "number of segments" + }, + "options.transfer_size": { + "label": "size of transfer in bytes (e.g.: 8, 4k, 2m, 1g)" + }, + "options.max_time_duration": { + "label": "max time in minutes executing repeated test; it aborts only between iterations and not within a test!" + }, + "options.reorder_task_random_seed": { + "label": "random seed for -Z option" + }, + "options.random_prefill": { + "label": "For random -z access only: Prefill the file with this blocksize, e.g., 2m" + }, + "options.random_offset_seed": { + "label": "The seed for -z" + } + }, + + "edges": [ + { + "source": "modules", + "target": "modules.cephfs", + "relation": "has-module" + }, + { + "source": "modules.cephfs", + "target": "modules.cephfs.olazy", + "relation": "has-property" + }, + { + "source": "modules", + "target": "modules.mmap", + "relation": "has-module" + }, + { + "source": "modules.mmap", + "target": "modules.mmap.madv_dont_need", + "relation": "has-property" + }, + { + "source": "modules.mmap", + "target": "modules.mmap.madv_pattern", + "relation": "has-property" + }, + { + "source": "modules", + "target": "modules.ncmpi", + "relation": "has-module" + }, + { + "source": "modules.ncmpi", + "target": "modules.ncmpi.preallocate", + "relation": "has-property" + }, + { + "source": "modules.ncmpi", + "target": "modules.ncmpi.use_strided_datatype", + "relation": "has-property" + }, + { + "source": "modules.ncmpi", + "target": "modules.ncmpi.use_file_view", + "relation": "has-property" + }, + { + "source": "modules", + "target": "modules.mpiio", + "relation": "has-module" + }, + { + "source": "modules.mpiio", + "target": "modules.mpiio.preallocate", + "relation": "has-property" + }, + { + "source": "modules.mpiio", + "target": "modules.mpiio.preallocate", + "relation": "has-property" + }, + { + "source": "modules.mpiio", + "target": "modules.mpiio.use_strided_datatype", + "relation": "has-property" + }, + { + "source": "modules.mpiio", + "target": "modules.mpiio.use_file_view", + "relation": "has-property" + }, + { + "source": "modules", + "target": "modules.dummy", + "relation": "has-module" + }, + { + "source": "modules.dummy", + "target": "modules.dummy.delay_only_rank0", + "relation": "has-propery" + }, + { + "source": "modules.dummy", + "target": "modules.dummy.delay_create_rank0", + "relation": "has-propery" + }, + { + "source": "modules.dummy", + "target": "modules.dummy.delay_close0", + "relation": "has-propery" + }, + { + "source": "modules.dummy", + "target": "modules.dummy.delay_sync0", + "relation": "has-propery" + }, + { + "source": "modules.dummy", + "target": "modules.dummy.delay_xfer0", + "relation": "has-propery" + }, + { + "source": "modules", + "target": "modules.posix", + "relation": "has-module" + }, + { + "source": "modules.posix", + "target": "modules.posix.odirect", + "relation": "has-property" + }, + { + "source": "modules.posix", + "target": "modules.posix.rangelocks", + "relation": "has-property" + }, + { + "source": "options", + "target": "options.api", + "relation": "has-option" + }, + { + "source": "options", + "target": "options.blocksize", + "relation": "has-option" + }, + { + "source": "options", + "target": "options.inter_test_delay", + "relation": "has-option" + }, + { + "source": "options", + "target": "options.deadline_for_stonewalling", + "relation": "has-option" + }, + { + "source": "options", + "target": "options.stonewalling_wear_out", + "relation": "has-option" + }, + { + "source": "options", + "target": "options.stonewalling_wear_out_iterations", + "relation": "has-option" + }, + { + "source": "options", + "target": "options.min_time_duration", + "relation": "has-option" + }, + { + "source": "options", + "target": "options.script_file", + "relation": "has-option" + }, + { + "source": "options", + "target": "options.set_timestamp_signature", + "relation": "has-option" + }, + { + "source": "options", + "target": "options.repetitions", + "relation": "has-option" + }, + { + "source": "options", + "target": "options.outlier_threshold", + "relation": "has-option" + }, + { + "source": "options", + "target": "options.num_tasks", + "relation": "has-option" + }, + { + "source": "options", + "target": "options.test_file", + "relation": "has-option" + }, + { + "source": "options", + "target": "options.task_per_node_offset", + "relation": "has-option" + }, + { + "source": "options", + "target": "options.segment_count", + "relation": "has-option" + }, + { + "source": "options", + "target": "options.transfer_size", + "relation": "has-option" + }, + { + "source": "options", + "target": "options.max_time_duration", + "relation": "has-option" + }, + { + "source": "options", + "target": "options.reorder_task_random_seed", + "relation": "has-option" + }, + { + "source": "options", + "target": "options.random_prefill", + "relation": "has-option" + }, + { + "source": "options", + "target": "options.random_offset_seed", + "relation": "has-option" + } + ], + "metadata": { + "version": "0.0.0", + "source": "https://github.com/supercontainers/compspec" + } + } +} diff --git a/compspec_ior/version.py b/compspec_ior/version.py new file mode 100644 index 0000000..2f27546 --- /dev/null +++ b/compspec_ior/version.py @@ -0,0 +1,20 @@ +__author__ = "Vanessa Sochat" +__copyright__ = "Copyright 2024, Vanessa Sochat" +__license__ = "MIT" + +__version__ = "0.0.0" +AUTHOR = "Vanessa Sochat" +AUTHOR_EMAIL = "vsoch@users.noreply.github.com" +NAME = "compspec-ior" +PACKAGE_URL = "https://github.com/compspec/compspec-ior" +KEYWORDS = "compatibility, compspec, IOR, I/O, intents" +DESCRIPTION = "Compatibility specification and extractor plugin for IOR (I/O)" +LICENSE = "LICENSE" + +################################################################################ +# Global requirements + +INSTALL_REQUIRES = (("compspec", {"min_version": "0.1.0"}),) + +TESTS_REQUIRES = (("pytest", {"min_version": "4.6.2"}),) +INSTALL_REQUIRES_ALL = INSTALL_REQUIRES + TESTS_REQUIRES diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..831adc6 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,7 @@ +[tool.black] +profile = "black" +exclude = ["^env/"] + +[tool.isort] +profile = "black" # needed for black/isort compatibility +skip = [] diff --git a/pytest.ini b/pytest.ini new file mode 100644 index 0000000..6082848 --- /dev/null +++ b/pytest.ini @@ -0,0 +1,7 @@ +[pytest] +addopts = + --doctest-modules + --doctest-glob=README.md + --ignore=docs + --verbose + -ra diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 0000000..f5d84d8 --- /dev/null +++ b/setup.cfg @@ -0,0 +1,6 @@ +[flake8] +exclude = docs +max-line-length = 100 +ignore = E1 E2 E5 W5 +per-file-ignores = + compspec_ior/__init__.py:F401 diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..edd37ca --- /dev/null +++ b/setup.py @@ -0,0 +1,101 @@ +import os + +from setuptools import find_packages, setup + + +def get_lookup(): + lookup = dict() + version_file = os.path.join("compspec_ior", "version.py") + with open(version_file) as filey: + exec(filey.read(), lookup) + return lookup + + +# Read in requirements +def get_reqs(lookup=None, key="INSTALL_REQUIRES"): + if lookup is None: + lookup = get_lookup() + + install_requires = [] + for module in lookup[key]: + module_name = module[0] + module_meta = module[1] + if "exact_version" in module_meta: + dependency = "%s==%s" % (module_name, module_meta["exact_version"]) + elif "max_version" in module_meta: + if module_meta["max_version"] is None: + dependency = module_name + else: + dependency = "%s<=%s" % (module_name, module_meta["max_version"]) + elif "min_version" in module_meta: + if module_meta["min_version"] is None: + dependency = module_name + else: + dependency = "%s>=%s" % (module_name, module_meta["min_version"]) + install_requires.append(dependency) + return install_requires + + +# Make sure everything is relative to setup.py +install_path = os.path.dirname(os.path.abspath(__file__)) +os.chdir(install_path) + +# Get version information from the lookup +lookup = get_lookup() +VERSION = lookup["__version__"] +NAME = lookup["NAME"] +AUTHOR = lookup["AUTHOR"] +AUTHOR_EMAIL = lookup["AUTHOR_EMAIL"] +PACKAGE_URL = lookup["PACKAGE_URL"] +KEYWORDS = lookup["KEYWORDS"] +DESCRIPTION = lookup["DESCRIPTION"] +LICENSE = lookup["LICENSE"] + +# Try to read description, otherwise fallback to short description +try: + with open("README.md") as filey: + LONG_DESCRIPTION = filey.read() +except Exception: + LONG_DESCRIPTION = DESCRIPTION + +################################################################################ +# MAIN ######################################################################### +################################################################################ + +if __name__ == "__main__": + INSTALL_REQUIRES = get_reqs(lookup) + TESTS_REQUIRES = get_reqs(lookup, "TESTS_REQUIRES") + INSTALL_REQUIRES_ALL = get_reqs(lookup, "INSTALL_REQUIRES_ALL") + + setup( + name=NAME, + version=VERSION, + author=AUTHOR, + author_email=AUTHOR_EMAIL, + maintainer=AUTHOR, + packages=find_packages(), + include_package_data=True, + zip_safe=False, + url=PACKAGE_URL, + license=LICENSE, + description=DESCRIPTION, + long_description=LONG_DESCRIPTION, + long_description_content_type="text/markdown", + keywords=KEYWORDS, + setup_requires=["pytest-runner"], + install_requires=INSTALL_REQUIRES, + tests_require=TESTS_REQUIRES, + extras_require={ + "all": [INSTALL_REQUIRES_ALL], + }, + classifiers=[ + "Intended Audience :: Science/Research", + "Intended Audience :: Developers", + "License :: OSI Approved :: MIT License", + "Programming Language :: Python", + "Topic :: Software Development", + "Topic :: Scientific/Engineering", + "Operating System :: Unix", + "Programming Language :: Python :: 3.10", + ], + )