From 7bcc14ff2c528abdab7ed5117b95bc56d471ef48 Mon Sep 17 00:00:00 2001 From: sami-m-g Date: Thu, 28 Mar 2024 14:46:34 +0200 Subject: [PATCH] Switched to pyproject.toml --- .pre-commit-config.yaml | 18 +++-- CHANGES.md | 5 ++ pyilcd/VERSION | 1 - pyilcd/__init__.py | 4 +- pyilcd/common.py | 1 + pyilcd/config.py | 1 + pyilcd/contact_dataset.py | 1 + pyilcd/core.py | 1 + pyilcd/flow_dataset.py | 1 + pyilcd/flow_property_dataset.py | 1 + pyilcd/helpers.py | 1 + pyilcd/process_dataset.py | 1 + pyilcd/source_dataset.py | 1 + pyilcd/unit_group_dataset.py | 1 + pyilcd/version.py | 15 ---- pyproject.toml | 103 +++++++++++++++++++++++++++- tests/__init__.py | 1 + tests/conftest.py | 1 + tests/test_common.py | 1 + tests/test_config.py | 1 + tests/test_contact_dataset.py | 1 + tests/test_core.py | 1 + tests/test_flow_dataset.py | 1 + tests/test_flow_property_dataset.py | 1 + tests/test_process_dataset.py | 1 + tests/test_source_dataset.py | 1 + tests/test_unit_group_dataset.py | 1 + 27 files changed, 144 insertions(+), 23 deletions(-) delete mode 100644 pyilcd/VERSION delete mode 100644 pyilcd/version.py diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index fb735b5..0fce222 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -28,16 +28,22 @@ repos: # --remove-unused-variables, # ] +- repo: https://github.com/john-hen/Flake8-pyproject + rev: 1.2.3 + hooks: + - id: Flake8-pyproject + - repo: https://github.com/pycqa/isort - rev: 5.11.5 + rev: 5.13.2 hooks: - id: isort + args: [--settings-path=pyproject.toml] - repo: https://github.com/psf/black - rev: 22.12.0 + rev: 24.1.1 hooks: - id: black - language_version: python3 + args: [--config=pyproject.toml] ## If like to embrace black styles even in the docs: # - repo: https://github.com/asottile/blacken-docs @@ -47,11 +53,13 @@ repos: # additional_dependencies: [black] - repo: https://github.com/PyCQA/flake8 - rev: 6.0.0 + rev: 7.0.0 hooks: - id: flake8 - ## You can add flake8 plugins via `additional_dependencies`: + additional_dependencies: [Flake8-pyproject] + # You can add flake8 plugins via `additional_dependencies`: # additional_dependencies: [flake8-bugbear] + - repo: local hooks: - id: pylint diff --git a/CHANGES.md b/CHANGES.md index f1454f7..6e55f4b 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -5,6 +5,11 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [6.3.1] - 2024-03-28 + +### Fixed +- Packaging issues + ## [6.3.0] - 2023-09-26 ### Added diff --git a/pyilcd/VERSION b/pyilcd/VERSION deleted file mode 100644 index 798e389..0000000 --- a/pyilcd/VERSION +++ /dev/null @@ -1 +0,0 @@ -6.3.0 diff --git a/pyilcd/__init__.py b/pyilcd/__init__.py index 4bea6f5..0d20eca 100644 --- a/pyilcd/__init__.py +++ b/pyilcd/__init__.py @@ -1,4 +1,5 @@ """pyilcd.""" + from .config import Defaults from .contact_dataset import ContactDataSet from .core import ( @@ -45,7 +46,8 @@ from .process_dataset import ProcessDataSet from .source_dataset import SourceDataSet from .unit_group_dataset import UnitGroupDataSet -from .version import __version__ + +__version__ = "6.3.1" __all__ = ( "__version__", diff --git a/pyilcd/common.py b/pyilcd/common.py index 8054693..a9dc78c 100644 --- a/pyilcd/common.py +++ b/pyilcd/common.py @@ -1,4 +1,5 @@ """Common custom ILCD Python classes.""" + from datetime import datetime from typing import List diff --git a/pyilcd/config.py b/pyilcd/config.py index 524db15..cae1911 100644 --- a/pyilcd/config.py +++ b/pyilcd/config.py @@ -1,4 +1,5 @@ """Defaults configuration.""" + import configparser import os from dataclasses import dataclass diff --git a/pyilcd/contact_dataset.py b/pyilcd/contact_dataset.py index 796fab7..3b8b9ec 100644 --- a/pyilcd/contact_dataset.py +++ b/pyilcd/contact_dataset.py @@ -1,4 +1,5 @@ """Custom ILCD Python classes for ContactDataSet of ILCD schema.""" + from typing import List from lxml import etree diff --git a/pyilcd/core.py b/pyilcd/core.py index 502bc9d..89d688b 100644 --- a/pyilcd/core.py +++ b/pyilcd/core.py @@ -1,4 +1,5 @@ """Core ILCD module containing parsing and saving functionalities.""" + from io import StringIO from pathlib import Path from typing import Dict, List, Tuple, Union diff --git a/pyilcd/flow_dataset.py b/pyilcd/flow_dataset.py index 119183e..4efc3a5 100644 --- a/pyilcd/flow_dataset.py +++ b/pyilcd/flow_dataset.py @@ -1,4 +1,5 @@ """Custom ILCD Python classes for FlowDataSet of ILCD schema.""" + from typing import List from lxml import etree diff --git a/pyilcd/flow_property_dataset.py b/pyilcd/flow_property_dataset.py index 0863ed4..ab7f253 100644 --- a/pyilcd/flow_property_dataset.py +++ b/pyilcd/flow_property_dataset.py @@ -1,4 +1,5 @@ """Custom ILCD Python classes for FlowDataSet of ILCD schema.""" + from typing import List from lxml import etree diff --git a/pyilcd/helpers.py b/pyilcd/helpers.py index 0dc5fc5..471ce7f 100644 --- a/pyilcd/helpers.py +++ b/pyilcd/helpers.py @@ -1,4 +1,5 @@ """Internal helper classes.""" + from typing import Callable, Optional from lxmlh import create_attribute, create_attribute_list, create_element_text diff --git a/pyilcd/process_dataset.py b/pyilcd/process_dataset.py index 0de0876..ae7a60c 100644 --- a/pyilcd/process_dataset.py +++ b/pyilcd/process_dataset.py @@ -1,4 +1,5 @@ """Custom ILCD Python classes for ProcessDataSet of ILCD schema.""" + from typing import List from lxml import etree diff --git a/pyilcd/source_dataset.py b/pyilcd/source_dataset.py index d788d57..4aaf456 100644 --- a/pyilcd/source_dataset.py +++ b/pyilcd/source_dataset.py @@ -1,4 +1,5 @@ """Custom ILCD Python classes for SourceDataSet of ILCD schema.""" + from typing import List from lxml import etree diff --git a/pyilcd/unit_group_dataset.py b/pyilcd/unit_group_dataset.py index 6deaf8e..d3cdf8c 100644 --- a/pyilcd/unit_group_dataset.py +++ b/pyilcd/unit_group_dataset.py @@ -1,4 +1,5 @@ """Custom ILCD Python classes for UnitGroupDataSet of ILCD schema.""" + from typing import List from lxml import etree diff --git a/pyilcd/version.py b/pyilcd/version.py deleted file mode 100644 index 57dfe74..0000000 --- a/pyilcd/version.py +++ /dev/null @@ -1,15 +0,0 @@ -"""Version information for lxmlh package.""" -import pathlib - - -def _get_version(): - """Return the version number.""" - versionFile = pathlib.Path(__file__).parent / "VERSION" - # Read the version number from VERSION file - with open(versionFile, "r", encoding="UTF-8") as vf: - # The full version, including alpha/beta/rc tags - versionList = vf.read().strip().split(".") - return ".".join(versionList) - - -__version__ = _get_version() diff --git a/pyproject.toml b/pyproject.toml index 638dd9c..e4adbfa 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,3 +1,104 @@ [build-system] -requires = ["setuptools>=61.0"] +requires = ["setuptools>=68.0"] build-backend = "setuptools.build_meta" + +[project] +name = "pyilcd" +authors = [ + { name="Mina Sami", email="sami.mg@outlook.com" } +] +maintainers = [ + { name="Mina Sami", email="sami.mg@outlook.com" } +] +description = "A Python package that converts ILCD XML formats to their Python equivalents and export the same data back to XML." +readme = "README.md" +dynamic = ["version"] +# Add here all kinds of additional classifiers as defined under +# https://pypi.org/classifiers/ +classifiers = [ + "Development Status :: 4 - Beta", + "Programming Language :: Python", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Natural Language :: English", + "Operating System :: OS Independent", +] +requires-python = ">=3.8" +dependencies = [ + "lxml==4.9.2", + "lxmlh>=1.2.0", + "pycasreg==0.1.0", +] + +[project.urls] +source = "https://github.com/sami-m-g/pyilcd" +homepage = "https://github.com/sami-m-g/pyilcd" +tracker = "https://github.com/sami-m-g/pyilcd/issues" + +[project.optional-dependencies] +# Getting recursive dependencies to work is a pain, this +# seems to work, at least for now +testing = [ + "pyilcd", + "pytest", + "pytest-cov", + "python-coveralls" +] +dev = [ + "build", + "pre-commit", + "pylint", + "pytest", + "pytest-cov", + "pytest-randomly", + "setuptools", + "sphinx", + "sphinx-rtd-theme", +] + +[tool.setuptools] +license-files = ["LICENSE"] +include-package-data = true +packages = ["pyilcd"] + +[tool.setuptools.dynamic] +version = {attr = "pyilcd.__version__"} + +[tool.pytest.ini_options] +addopts = "--cov pyilcd --cov-report term-missing --verbose" +norecursedirs = [ + "dist", + "build", + ".tox" +] +testpaths = ["tests/*.py"] + +[tool.flake8] +# Some sane defaults for the code style checker flake8 +max_line_length = 88 +extend_ignore = ["E203", "W503"] +# ^ Black-compatible +# E203 and W503 have edge cases handled by black +exclude = [ + ".tox", + "build", + "dist", + ".eggs", + "docs/conf.py", +] + +[tool.black] +line-length = 88 + +[tool.isort] +profile = "black" +line_length = 88 +multi_line_output = 3 +include_trailing_comma = true +force_grid_wrap = 0 +use_parentheses = true +ensure_newline_before_comments = true diff --git a/tests/__init__.py b/tests/__init__.py index a9ce0bb..0363f36 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -1,4 +1,5 @@ """Test suite for the pyilcd package.""" + from pathlib import Path DIR_DATA = Path(__file__).parents[1] / "data" diff --git a/tests/conftest.py b/tests/conftest.py index d4d5f94..f3dbfc3 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,4 +1,5 @@ """Fixtures for pyilcd""" + import os import zipfile diff --git a/tests/test_common.py b/tests/test_common.py index 3ea50b2..e70215b 100644 --- a/tests/test_common.py +++ b/tests/test_common.py @@ -1,4 +1,5 @@ """Test cases for the __common__ module.""" + from pyilcd.common import ( Category, Class, diff --git a/tests/test_config.py b/tests/test_config.py index b419226..8957c2a 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -1,4 +1,5 @@ """Test cases for the __config__ module.""" + import os from pathlib import Path diff --git a/tests/test_contact_dataset.py b/tests/test_contact_dataset.py index 3b3358a..2c2e513 100644 --- a/tests/test_contact_dataset.py +++ b/tests/test_contact_dataset.py @@ -1,4 +1,5 @@ """Test cases for the __contact_dataset__ module.""" + from pyilcd.common import ClassificationInformation, GlobalReference from pyilcd.contact_dataset import ContactDataSet, DataEntryBy diff --git a/tests/test_core.py b/tests/test_core.py index 217d410..92c16c3 100644 --- a/tests/test_core.py +++ b/tests/test_core.py @@ -1,4 +1,5 @@ """Test cases for the __core__ module.""" + import os import tempfile from io import StringIO diff --git a/tests/test_flow_dataset.py b/tests/test_flow_dataset.py index 7adbbf0..b9a3d36 100644 --- a/tests/test_flow_dataset.py +++ b/tests/test_flow_dataset.py @@ -1,4 +1,5 @@ """Test cases for the __flow_dataset__ module.""" + from pyilcd.common import GlobalReference from pyilcd.flow_dataset import ( ComplianceDeclarations, diff --git a/tests/test_flow_property_dataset.py b/tests/test_flow_property_dataset.py index 43d4945..74497f0 100644 --- a/tests/test_flow_property_dataset.py +++ b/tests/test_flow_property_dataset.py @@ -1,4 +1,5 @@ """Test cases for the __flow_property_dataset__ module.""" + from pyilcd.common import ClassificationInformation, GlobalReference from pyilcd.flow_property_dataset import ( ComplianceDeclarations, diff --git a/tests/test_process_dataset.py b/tests/test_process_dataset.py index 6065290..00fc4bd 100644 --- a/tests/test_process_dataset.py +++ b/tests/test_process_dataset.py @@ -1,4 +1,5 @@ """Test cases for the __process_dataset__ module.""" + from pyilcd.common import ClassificationInformation, GlobalReference from pyilcd.process_dataset import ( Allocation, diff --git a/tests/test_source_dataset.py b/tests/test_source_dataset.py index 3390cd3..1599baa 100644 --- a/tests/test_source_dataset.py +++ b/tests/test_source_dataset.py @@ -1,4 +1,5 @@ """Test cases for the __contact_dataset__ module.""" + from pyilcd.common import ClassificationInformation, GlobalReference from pyilcd.source_dataset import DataEntryBy, ReferenceToDigitalFile, SourceDataSet diff --git a/tests/test_unit_group_dataset.py b/tests/test_unit_group_dataset.py index 3fd470f..c8bbd91 100644 --- a/tests/test_unit_group_dataset.py +++ b/tests/test_unit_group_dataset.py @@ -1,4 +1,5 @@ """Test cases for the __unit_group_dataset__ module.""" + from pyilcd.common import ClassificationInformation, GlobalReference from pyilcd.unit_group_dataset import ( DataEntryBy,