From 9d87d876cfe96230c529b23b04d995aedcb40586 Mon Sep 17 00:00:00 2001 From: Dacheng Xu Date: Sat, 21 Sep 2024 12:21:10 -0400 Subject: [PATCH] Use `pyproject.toml` to install utilix (#126) * Use `pyproject.toml` to install utilix * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Remove usage of setup.py * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Minor change * Add utilix authors * To include all files in `utilix` folder --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .bumpversion.cfg | 6 +++- .github/workflows/pypi.yml | 4 +-- .github/workflows/test_package.yml | 4 ++- .pre-commit-config.yaml | 2 ++ pyproject.toml | 48 ++++++++++++++++++++++++++++++ setup.py | 23 -------------- utilix/mongo_files.py | 10 +++---- 7 files changed, 65 insertions(+), 32 deletions(-) create mode 100644 pyproject.toml delete mode 100644 setup.py diff --git a/.bumpversion.cfg b/.bumpversion.cfg index 29c7da1..eb1b2e4 100644 --- a/.bumpversion.cfg +++ b/.bumpversion.cfg @@ -1,5 +1,9 @@ [bumpversion] current_version = 0.8.5 -files = setup.py utilix/__init__.py +files = utilix/__init__.py commit = True tag = True + +[bumpversion:file:pyproject.toml] +search = version = "{current_version}" +replace = version = "{new_version}" diff --git a/.github/workflows/pypi.yml b/.github/workflows/pypi.yml index 58fe735..982efa9 100644 --- a/.github/workflows/pypi.yml +++ b/.github/workflows/pypi.yml @@ -17,9 +17,9 @@ jobs: - name: Checkout repo uses: actions/checkout@v2 - name: Install dependencies - run: pip install wheel + run: pip install build - name: Build package - run: python setup.py sdist bdist_wheel + run: python -m build # Do the publish - name: Publish a Python distribution to PyPI # Might want to add but does not work on workflow_dispatch : diff --git a/.github/workflows/test_package.yml b/.github/workflows/test_package.yml index 4ea4c99..64f52f7 100644 --- a/.github/workflows/test_package.yml +++ b/.github/workflows/test_package.yml @@ -26,7 +26,9 @@ jobs: - name: Install python dependencies uses: py-actions/py-dependency-install@v2 - name: Install utilix - run: python setup.py install + run: | + pip install pytest hypothesis coverage coveralls + pip install . --force-reinstall - name: Install pytest and hypothesis run: pip install pytest hypothesis flake8 pytest-cov - name: Test package diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 507e770..7968f63 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -20,6 +20,8 @@ repos: rev: v1.7.5 hooks: - id: docformatter + additional_dependencies: [tomli] + args: [--config, pyproject.toml] - repo: https://github.com/pre-commit/mirrors-mypy rev: v1.11.2 diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..187a95a --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,48 @@ +[tool] +[tool.poetry] +name = "utilix" +version = "0.8.5" +description = "User-friendly interface to various utilities for XENON users" +readme = "README.md" +authors = [ + "utilix developers", +] +classifiers = [ + "Development Status :: 5 - Production/Stable", + "License :: OSI Approved :: BSD License", + "Natural Language :: English", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Intended Audience :: Science/Research", + "Programming Language :: Python :: Implementation :: CPython", + "Topic :: Scientific/Engineering :: Physics", +] +repository = "https://github.com/XENONnT/utilix" +packages = [ + { include = "utilix" } +] + +[tool.poetry.dependencies] +python = ">=3.8,<3.13" +pymongo = "*" +requests = "*" +tqdm = "*" +pandas = "*" +commentjson = "*" +simple_slurm = "*" +pydantic = ">=1.10,<2.0" + +[build-system] +requires = ["poetry-core>=1.0.8", "setuptools>=61.0"] +build-backend = "poetry.core.masonry.api" + +[tool.black] +line-length = 100 +preview = true + +[tool.docformatter] +recursive = true +in-place = true +wrap-summaries = 100 +wrap-descriptions = 100 +blank = true diff --git a/setup.py b/setup.py deleted file mode 100644 index 9639fe4..0000000 --- a/setup.py +++ /dev/null @@ -1,23 +0,0 @@ -from setuptools import setup, find_packages - -# Get requirements from requirements.txt, stripping the version tags -with open("requirements.txt") as f: - requires = [r.split("/")[-1] if r.startswith("git+") else r for r in f.read().splitlines()] - -with open("README.md") as file: - readme = file.read() - -with open("HISTORY.md") as file: - history = file.read() - -setup( - name="utilix", - version="0.8.5", - url="https://github.com/XENONnT/utilix", - description="User-friendly interface to various utilities for XENON users", - long_description_content_type="text/markdown", - packages=find_packages(), - install_requires=requires, - python_requires=">=3.6", - long_description=readme + "\n\n" + history, -) diff --git a/utilix/mongo_files.py b/utilix/mongo_files.py index 9bee2ea..473b557 100644 --- a/utilix/mongo_files.py +++ b/utilix/mongo_files.py @@ -46,7 +46,7 @@ def __init__(self, config_identifier="config_name", **kwargs): def get_query_config(self, config): """Generate identifier to query against. This is just the configs name. - :param config: str, name of the file of interest + :param config: str, name of the file of interest :return: dict, that can be used in queries """ @@ -55,7 +55,7 @@ def get_query_config(self, config): def document_format(self, config): """Format of the document to upload. - :param config: str, name of the file of interest + :param config: str, name of the file of interest :return: dict, that will be used to add the document """ @@ -142,7 +142,7 @@ def _check_store_files_at(cache_folder_alternatives): Order does matter as we iterate until we find one folder that is willing. :param cache_folder_alternatives: tuple, this tuple must be a list of paths one can try to - store the downloaded data + store the downloaded data. :return: str, the folder that we can write to. """ @@ -232,7 +232,7 @@ def __init__( def config_exists(self, config): """Quick check if this config is already saved in the collection. - :param config: str, name of the file of interest + :param config: str, name of the file of interest :return: bool, is this config name stored in the database """ @@ -431,7 +431,7 @@ def __init__(self, config_identifier="config_name"): def config_exists(self, config): """Quick check if this config is already saved in the collection. - :param config: str, name of the file of interest + :param config: str, name of the file of interest :return: bool, is this config name stored in the database """