From 591eb43db2042eb4cf2e0cc82660036de0cbfd31 Mon Sep 17 00:00:00 2001 From: Jusong Yu Date: Sun, 17 Sep 2023 00:17:41 +0200 Subject: [PATCH] use pyproject.toml --- .github/actions/create-dev-env/action.yml | 4 +- .github/workflows/comment.yml | 18 +++----- LICENSE.txt | 24 ++++++++++ aiida_registry/__init__.py | 2 +- bin/aiida-registry => aiida_registry/cli.py | 22 ++++----- aiida_registry/test_install.py | 2 +- bin/analyze_entrypoints.py | 1 + pyproject.toml | 51 +++++++++++++++++++++ setup.py | 44 ------------------ 9 files changed, 95 insertions(+), 73 deletions(-) create mode 100644 LICENSE.txt rename bin/aiida-registry => aiida_registry/cli.py (67%) create mode 100644 pyproject.toml delete mode 100644 setup.py diff --git a/.github/actions/create-dev-env/action.yml b/.github/actions/create-dev-env/action.yml index ee759dbf..b168ae89 100644 --- a/.github/actions/create-dev-env/action.yml +++ b/.github/actions/create-dev-env/action.yml @@ -12,6 +12,6 @@ runs: - name: Install Dev Dependencies 📦 run: | - pip install --upgrade pip - pip install --upgrade .[dev] + pip install -U pip + pip install -U -e .[dev] shell: bash diff --git a/.github/workflows/comment.yml b/.github/workflows/comment.yml index ceebc2f2..6ed3f78c 100644 --- a/.github/workflows/comment.yml +++ b/.github/workflows/comment.yml @@ -1,4 +1,4 @@ -name: CI +name: Comment on PRs with plugin metadata issues on: [pull_request] @@ -6,23 +6,19 @@ jobs: check-plugin-metadata: runs-on: ubuntu-latest - timeout-minutes: 5 steps: - - uses: actions/checkout@v2 - - name: Set up Python 3.8 - uses: actions/setup-python@v2 - with: - python-version: 3.8 - - name: Install prerequisites - run: pip install --upgrade pip - - name: Install - run: pip install -e . -v + - name: Checkout Repo ⚡️ + uses: actions/checkout@v3 + - name: Create dev environment + uses: ./.github/actions/create-dev-env + - name: fetch metadata id: fetch_metadata env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: aiida-registry fetch + - name: Create commit comment if: steps.fetch_metadata.outputs.error uses: peter-evans/commit-comment@v1 diff --git a/LICENSE.txt b/LICENSE.txt new file mode 100644 index 00000000..68314cde --- /dev/null +++ b/LICENSE.txt @@ -0,0 +1,24 @@ +The MIT License (MIT) + +Copyright (c), 2014-2020, ECOLE POLYTECHNIQUE FEDERALE DE LAUSANNE +(Theory and Simulation of Materials (THEOS) and National Centre for +Computational Design and Discovery of Novel Materials (NCCR MARVEL)), +Switzerland and ROBERT BOSCH LLC, USA. All rights reserved. + +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/aiida_registry/__init__.py b/aiida_registry/__init__.py index df853b90..d2274abb 100644 --- a/aiida_registry/__init__.py +++ b/aiida_registry/__init__.py @@ -9,7 +9,7 @@ import os -__version__ = "0.1.0" +__version__ = "0.3.0" # Absolute paths pwd = os.path.split(os.path.abspath(__file__))[0] diff --git a/bin/aiida-registry b/aiida_registry/cli.py similarity index 67% rename from bin/aiida-registry rename to aiida_registry/cli.py index c3cfb440..79313342 100644 --- a/bin/aiida-registry +++ b/aiida_registry/cli.py @@ -1,11 +1,14 @@ -#!/usr/bin/env python # -*- coding: utf-8 -*- +"""CLI for AiiDA registry.""" import click +from aiida_registry.make_pages import make_pages +from aiida_registry.test_install import test_install_all + @click.group() def cli(): - pass + """CLI for AiiDA registry.""" @cli.command() @@ -22,16 +25,8 @@ def cli(): default=True, help="Allow fetching wheels from PyPI", ) -def fetch(package, fetch_pypi, fetch_wheel): - from aiida_registry.make_pages import make_pages - - make_pages() - - -@cli.command() -def html(): - from aiida_registry.make_pages import make_pages - +def fetch(package, fetch_pypi, fetch_wheel): # pylint: disable=unused-argument + """Fetch data from PyPI and write to JSON file.""" make_pages() @@ -43,8 +38,7 @@ def html(): help="Container image to use for the install", ) def test_install(container_image): - from aiida_registry.test_install import test_install_all - + """Test installing all plugins in a Docker container.""" test_install_all(container_image) diff --git a/aiida_registry/test_install.py b/aiida_registry/test_install.py index ceee37f7..1863ba32 100644 --- a/aiida_registry/test_install.py +++ b/aiida_registry/test_install.py @@ -127,7 +127,7 @@ def test_install_one_docker(container_image, plugin): ) extract_metadata = container.exec_run( workdir=_DOCKER_WORKDIR, - cmd="python ./bin/analyze_entrypoints.py -o result.json", + cmd="python ./analyze_entrypoints.py -o result.json", ) error_message = handle_error( extract_metadata, diff --git a/bin/analyze_entrypoints.py b/bin/analyze_entrypoints.py index 9d26fec5..53c77d96 100644 --- a/bin/analyze_entrypoints.py +++ b/bin/analyze_entrypoints.py @@ -1,3 +1,4 @@ +#!/usr/bin/env python # -*- coding: utf-8 -*- """" Fetch information about plugins and print it in a human-readable format. diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 00000000..9165c660 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,51 @@ +[build-system] +requires = ["flit_core >=3.4,<4"] +build-backend = "flit_core.buildapi" + +[project] +name = "aiida-registry" +dynamic = ["version"] # read from aiida_registry/__init__.py +description = "Registry of AiiDA plugins" +authors = [{name = "The AiiDA team", email = "developers@aiida.net"}] +readme = "README.md" +license = {file = "LICENSE.txt"} +classifiers = [ + "Development Status :: 5 - Production/Stable", + "Framework :: AiiDA", + "License :: OSI Approved :: MIT License", + "Operating System :: POSIX :: Linux", + "Operating System :: MacOS :: MacOS X", + "Programming Language :: Python", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Topic :: Scientific/Engineering" +] +keywords = ["aiida", "workflows"] +requires-python = ">=3.9" +dependencies = [ + "jinja2~=2.11", + "requests~=2.28.1", + "requests-cache~=0.5.2", + "requirements-parser~=0.2.0", + "poetry~=1.1.15", + "tomlkit", + "click~=7.1", + "pyyaml~=6.0", + "docker~=5.0", + # https://github.com/aws/aws-sam-cli/issues/3661 + "markupsafe~=2.0.1", + # dev dependencies + "pre-commit~=2.2", + "pylint~=2.16.1", + "pytest~=6.2.2", + "pytest-regressions~=2.5.0", +] + +[project.urls] +Home = "https://aiida-registry.github.io/" +Documentation = "https://github.com/aiidateam/aiida-registry/wiki" +Source = "https://github.com/aiidateam/aiida-core" + +[project.scripts] +aiida-registry = "aiida_registry.cli:cli" diff --git a/setup.py b/setup.py deleted file mode 100644 index 4204a810..00000000 --- a/setup.py +++ /dev/null @@ -1,44 +0,0 @@ -# -*- coding: utf-8 -*- -"""Setup for AiiDA registry.""" - -from __future__ import absolute_import - -from setuptools import find_packages, setup - -if __name__ == "__main__": - with open("README.md", encoding="utf8") as handle: - setup( - name="aiida-registry", - packages=find_packages(), - long_description=handle.read(), - long_description_content_type="text/markdown", - version="0.3.0", - description="Registry of AiiDA plugins.", - author="AiiDA Team", - author_email="aiidateam@gmail.com", - url="https://aiidateam.github.io/aiida-registry/", - scripts=["bin/aiida-registry"], - install_requires=[ - "jinja2~=2.11", - "requests~=2.28.1", - "requests-cache~=0.5.2", - "requirements-parser~=0.2.0", - "poetry~=1.1.15", - "tomlkit", - "click~=7.1", - "pyyaml~=6.0", - "docker~=5.0", - # https://github.com/aws/aws-sam-cli/issues/3661 - "markupsafe~=2.0.1", - ], - license="MIT", - extras_require={ - "dev": [ - "pre-commit~=2.2", - "pylint~=2.16.1", - "pytest~=6.2.2", - "pytest-regressions~=2.5.0", - ], - }, - include_package_data=True, - )