diff --git a/.github/workflows/python-app.yml b/.github/workflows/python-app.yml index 6359cf0..c985f36 100644 --- a/.github/workflows/python-app.yml +++ b/.github/workflows/python-app.yml @@ -66,7 +66,7 @@ jobs: - name: Lint with pylint run: | pip install pylint - pylint --fail-under=9.8 --rcfile=.pylintrc utilities + pylint --fail-under=9.7 --rcfile=.pylintrc utilities - name: code coverage run: | mkdir -p ./coverage diff --git a/.github/workflows/static.yml b/.github/workflows/static.yml index 113baae..bbdd86f 100644 --- a/.github/workflows/static.yml +++ b/.github/workflows/static.yml @@ -43,7 +43,7 @@ jobs: cd docs - sphinx-apidoc -e -M --force -o . .. + sphinx-apidoc -e -M --force -o . ../utilities/ make html - name: Upload build data uses: actions/upload-artifact@v3 diff --git a/README.md b/README.md index 2cd3f18..3c23d7c 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ Note: you need to have a working ssh key to access github from your current mach you need to have wheel installed. ``` -python setup.py bdist_wheel sdist +pip wheel . --no-deps --wheel-dir=dist ``` After build run the following command to install, the built package. diff --git a/docs/conf.py b/docs/conf.py index ef96845..53c6e12 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -4,41 +4,64 @@ # https://www.sphinx-doc.org/en/master/usage/configuration.html +import datetime import os import sys -sys.path.insert(0, os.path.abspath('..')) +import toml +sys.path.insert(0, os.path.abspath("..")) -# -- Project information ----------------------------------------------------- -# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information + +def get_project_data(): + try: + # Determine the path to pyproject.toml relative to this file + base_dir = os.path.dirname(os.path.abspath(__file__)) + pyproject_path = os.path.join(base_dir, "..", "pyproject.toml") + + # Load the pyproject.toml file + pyproject_data = toml.load(pyproject_path) + + # Extract the version from the project section + metadata = dict(pyproject_data["project"]) + except Exception as e: + metadata = "unknown" + return metadata +metadata = get_project_data() +year = datetime.datetime.now().year -project = 'GU Orbit Software Utilities' -copyright = '2023, GU Orbit Software Team' -author = 'GU Orbit Software Team' -release = '0.1.0' +# -- Project information ----------------------------------------------------- +# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information + +if isinstance(metadata, dict): + project = f"GU Orbit Software {metadata['name']}" + copyright = f"{year}, {metadata['authors'][0]['name']}" + author = metadata['authors'][0]['name'] + release = metadata["version"] +else: + raise TypeError( + "metadata must be a dict. There must be a problem with the pyproject.toml file." + ) # -- General configuration --------------------------------------------------- # https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration add_module_names = False -extensions = ['sphinx.ext.todo', 'sphinx.ext.viewcode', 'sphinx.ext.autodoc'] - -templates_path = ['_templates'] -exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store'] - +extensions = ["sphinx.ext.todo", "sphinx.ext.viewcode", "sphinx.ext.autodoc"] +templates_path = ["_templates"] +exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"] # -- Options for HTML output ------------------------------------------------- # https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output -#insegel theme -#furo theme +# insegel theme +# furo theme -html_theme = 'furo' +html_theme = "furo" -html_static_path = ['style'] -html_css_files = ['custom.css'] +html_static_path = ["style"] +html_css_files = ["custom.css"] diff --git a/pyproject.toml b/pyproject.toml index 315f415..50a2f8c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,14 +1,40 @@ -[tool.poetry] +[build-system] +requires = ["setuptools", "wheel"] +build-backend = "setuptools.build_meta" + +[project] name = "utilities" version = "0.1.0" -description = "" -authors = ["Jan-Loettgen "] +authors = [ + {name = "GU Orbit Software Team", email = "uog.orbit@gmail.com"} +] +requires-python = ">=3.10" +description = "A package containing utilities for GU Orbit Software" readme = "README.md" +license = {text = "MIT"} +classifiers = [ + "Programming Language :: Python :: 3.10", + "License :: OSI Approved :: MIT License", + "Operating System :: OS Independent" +] +dependencies = [ + "numpy >= 1.24.0", + "rasterio >= 1.3.6", + "Pillow >= 9.4.0", + "tensorflow >= 2.10", + "toml >= 0.10.2", +] -[tool.poetry.dependencies] -python = "^3.9" +[tool.setuptools] +packages = ["utilities"] - -[build-system] -requires = ["poetry-core"] -build-backend = "poetry.core.masonry.api" +[project.optional-dependencies] +dev = [ + "pytest >= 7.2.2", + "pytest-cov >= 4.0.0", + "pytest-mock >= 3.10.0", + "twine >= 4.0.0", + + "Sphinx >= 6.1.3", + "furo >= 2022.12.7", +] diff --git a/requirements.txt b/requirements.txt index cfa2fbc..1200270 100644 --- a/requirements.txt +++ b/requirements.txt @@ -4,3 +4,4 @@ rasterio==1.3.6 Pillow==9.4.0 tqdm==4.64.1 pandas==1.5.1 +toml==0.10.2 diff --git a/setup.py b/setup.py deleted file mode 100644 index cd279af..0000000 --- a/setup.py +++ /dev/null @@ -1,38 +0,0 @@ -from setuptools import find_packages, setup - -with open("README.md", "r") as f: - long_description = f.read() - - -setup( - name="guorbit_utils", - version="0.1.0", - author="GU Orbit Software Team", - author_email="", - description="A package containing utilities for GU Orbit Software", - long_description=long_description, - long_description_content_type="text/markdown", - url="", - packages=find_packages(where="utilities"), - package_dir={"": "utilities"}, - license="MIT", - classifiers=[ - "Programming Language :: Python :: 3.10", - "License :: OSI Approved :: MIT License", - "Operating System :: OS Independent", - ], - python_requires=">=3.10", - install_requires=[ - "numpy >= 1.24.0", - "rasterio >= 1.3.6", - "Pillow >= 9.4.0", - "tensorflow >= 2.10", - ], - extras_require={ - "dev": [ - "pytest >= 7.2.2", - "pytest-cov >= 4.0.0", - "twine >= 4.0.0", - ] - }, -) \ No newline at end of file diff --git a/utilities/__init__.py b/utilities/__init__.py index e69de29..4f6b5b9 100644 --- a/utilities/__init__.py +++ b/utilities/__init__.py @@ -0,0 +1,22 @@ +import os + +import toml + + +def get_version_from_pyproject(): + try: + # Determine the path to pyproject.toml relative to this file + base_dir = os.path.dirname(os.path.abspath(__file__)) + pyproject_path = os.path.join(base_dir, "..", "pyproject.toml") + + # Load the pyproject.toml file + pyproject_data = toml.load(pyproject_path) + + # Extract the version from the project section + version = pyproject_data["project"]["version"] + except FileNotFoundError: + version = "unknown" + return version + + +__version__ = get_version_from_pyproject() diff --git a/utilities/transform_utils/image_loading.py b/utilities/transform_utils/image_loading.py index fd0ee94..98e3429 100644 --- a/utilities/transform_utils/image_loading.py +++ b/utilities/transform_utils/image_loading.py @@ -4,6 +4,7 @@ import os + import numpy as np from numpy.typing import NDArray from PIL import Image