Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrating to pyproject.toml #194

Merged
merged 18 commits into from
Mar 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions .github/workflows/publish_to_pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@ jobs:
- name: Install dependencies and Build
run: |
python -m pip install --upgrade pip
pip install setuptools wheel twine
python setup.py sdist bdist_wheel
pip install setuptools build
python -m build --sdist --wheel --outdir dist/ .
- name: Check distribution files
run: |
pip install twine
twine check dist/*
- name: Publish
uses: pypa/gh-action-pypi-publish@release/v1
6 changes: 3 additions & 3 deletions .github/workflows/pull_request_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ jobs:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.ref }}
fetch-depth: 1
fetch-depth: 0
fetch-tags: true
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
Expand All @@ -29,8 +30,7 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install pytest
python -m pip install .
python -m pip install .[test]
castelao marked this conversation as resolved.
Show resolved Hide resolved
- name: Run pytest
run: |
python -m pytest -v --disable-warnings
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ wheels/
*.egg-info/
.installed.cfg
*.egg
_version.py

# PyInstaller
# Usually these files are written by a python script from a template
Expand Down
1 change: 1 addition & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ repos:
- id: check-json
- id: check-merge-conflict
- id: check-symlinks
- id: check-toml
- id: flake8
- id: mixed-line-ending
- repo: https://github.com/PyCQA/pylint
Expand Down
71 changes: 71 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
[build-system]
requires = [
"setuptools >= 61.0",
"setuptools_scm[toml] >= 8",
]
build-backend = "setuptools.build_meta"

[project]
name = "NREL-sup3r"
dynamic = ["version"]
description = "Super Resolving Renewable Resource Data (sup3r)"
keywords = ["sup3r", "NREL"]
readme = "README.rst"
authors = [
{name = "Brandon Benton", email = "[email protected]"},
]
license = {text = "BSD-3-Clause"}
requires-python = ">= 3.8"
classifiers=[
"Development Status :: 4 - Beta",
"Intended Audience :: Science/Research",
"License :: OSI Approved :: BSD License",
"Natural Language :: English",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
]
dependencies = [
"NREL-rex>=0.2.84",
"NREL-phygnn>=0.0.23",
"NREL-gaps>=0.6.0",
"NREL-farms>=1.0.4",
"dask>=2022.0",
"google-auth-oauthlib==0.5.3",
"matplotlib>=3.1",
"numpy>=1.7.0",
"netCDF4==1.5.8",
"pandas>=2.0",
"pillow>=10.0",
"pytest>=5.2",
"scipy>=1.0.0",
"sphinx>=7.0",
"tensorflow>2.4,<2.16",
"xarray>=2023.0",
]

[project.optional-dependencies]
dev = [
"build>=0.5",
"flake8",
"pre-commit",
"pylint",
]
doc = [
"sphinx>=7.0",
]
test = [
"pytest>=5.2",
]

[project.urls]
homepage = "https://github.com/NREL/sup3r"
documentation = "https://nrel.github.io/sup3r/"
repository = "https://github.com/NREL/sup3r"

[tool.setuptools]
include-package-data = true
packages = ["sup3r"]

[tool.setuptools_scm]
version_file = "sup3r/_version.py"
16 changes: 0 additions & 16 deletions requirements.txt

This file was deleted.

44 changes: 1 addition & 43 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,27 +1,12 @@
"""
setup.py
"""
import os
from codecs import open
from setuptools import setup, find_packages
from setuptools import setup
from setuptools.command.develop import develop
from subprocess import check_call
import shlex
from warnings import warn

here = os.path.abspath(os.path.dirname(__file__))

with open(os.path.join(here, "README.rst"), encoding="utf-8") as f:
readme = f.read()

with open(os.path.join(here, "requirements.txt")) as f:
install_requires = f.readlines()

with open(os.path.join(here, "sup3r", "version.py"), encoding="utf-8") as f:
version = f.read()

version = version.split('=')[-1].strip().strip('"').strip("'")


class PostDevelopCommand(develop):
"""
Expand All @@ -42,12 +27,6 @@ def run(self):


setup(
name="NREL-sup3r",
version=version,
description="Super Resolving Renewable Resource Data (sup3r)",
long_description=readme,
author="Brandon Benton",
author_email="[email protected]",
entry_points={
"console_scripts": ["sup3r=sup3r.cli:main",
"sup3r-pipeline=sup3r.pipeline.pipeline_cli:main",
Expand All @@ -66,27 +45,6 @@ def run(self):
"data_collect_cli:main"),
],
},
url="https://github.com/NREL/sup3r",
packages=find_packages(),
package_dir={"sup3r": "sup3r"},
include_package_data=True,
license="BSD 3-Clause",
zip_safe=False,
keywords="sup3r",
classifiers=[
"Development Status :: 4 - Beta",
"Intended Audience :: Science/Research",
"License :: OSI Approved :: BSD License",
"Natural Language :: English",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
],
test_suite="tests",
python_requires='>=3.8',
install_requires=install_requires,
extras_require={
"dev": ["flake8", "pre-commit", "pylint"],
},
cmdclass={"develop": PostDevelopCommand},
)
3 changes: 2 additions & 1 deletion sup3r/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# -*- coding: utf-8 -*-
"""Super Resolving Renewable Energy Resource Data (SUP3R)"""
import os
from sup3r.version import __version__

from ._version import __version__
# Next import sets up CLI commands
# This line could be "import sup3r.cli" but that breaks sphinx as of 12/11/2023
from sup3r.cli import main
Expand Down
2 changes: 1 addition & 1 deletion sup3r/bias/bias_calc_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@

import click

from sup3r import __version__
import sup3r.bias.bias_calc
from sup3r.utilities import ModuleName
from sup3r.utilities.cli import AVAILABLE_HARDWARE_OPTIONS, BaseCLI
from sup3r.version import __version__

logger = logging.getLogger(__name__)

Expand Down
2 changes: 1 addition & 1 deletion sup3r/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

from gaps import Pipeline

from sup3r.version import __version__
from sup3r import __version__
from sup3r.utilities import ModuleName
from sup3r.pipeline.forward_pass_cli import from_config as fwp_cli
from sup3r.solar.solar_cli import from_config as solar_cli
Expand Down
2 changes: 1 addition & 1 deletion sup3r/pipeline/forward_pass_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import os

from sup3r.utilities import ModuleName
from sup3r.version import __version__
from sup3r import __version__
from sup3r.pipeline.forward_pass import ForwardPassStrategy, ForwardPass
from sup3r.utilities.cli import AVAILABLE_HARDWARE_OPTIONS, BaseCLI

Expand Down
2 changes: 1 addition & 1 deletion sup3r/postprocessing/data_collect_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@

import click

from sup3r import __version__
from sup3r.postprocessing.collection import CollectorH5, CollectorNC
from sup3r.utilities import ModuleName
from sup3r.utilities.cli import AVAILABLE_HARDWARE_OPTIONS, BaseCLI
from sup3r.utilities.utilities import get_source_type
from sup3r.version import __version__

logger = logging.getLogger(__name__)

Expand Down
2 changes: 1 addition & 1 deletion sup3r/postprocessing/file_handling.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
invert_uv,
pd_date_range,
)
from sup3r.version import __version__
from sup3r import __version__

logger = logging.getLogger(__name__)

Expand Down
2 changes: 1 addition & 1 deletion sup3r/preprocessing/data_extract_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
import click

import sup3r
from sup3r import __version__
from sup3r.utilities import ModuleName
from sup3r.utilities.cli import AVAILABLE_HARDWARE_OPTIONS, BaseCLI
from sup3r.version import __version__

logger = logging.getLogger(__name__)

Expand Down
2 changes: 1 addition & 1 deletion sup3r/qa/qa_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
import click
import logging

from sup3r import __version__
from sup3r.utilities import ModuleName
from sup3r.version import __version__
from sup3r.qa.qa import Sup3rQa
from sup3r.utilities.cli import BaseCLI

Expand Down
2 changes: 1 addition & 1 deletion sup3r/qa/stats_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
import click
import logging

from sup3r import __version__
from sup3r.utilities import ModuleName
from sup3r.version import __version__
from sup3r.qa.stats import Sup3rStatsMulti
from sup3r.utilities.cli import BaseCLI

Expand Down
2 changes: 1 addition & 1 deletion sup3r/qa/visual_qa_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
import click
import logging

from sup3r import __version__
from sup3r.utilities import ModuleName
from sup3r.version import __version__
from sup3r.qa.visual_qa import Sup3rVisualQa
from sup3r.utilities.cli import BaseCLI

Expand Down
2 changes: 1 addition & 1 deletion sup3r/solar/solar_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
import logging
import os

from sup3r import __version__
from sup3r.solar import Solar
from sup3r.utilities import ModuleName
from sup3r.version import __version__
from sup3r.utilities.cli import AVAILABLE_HARDWARE_OPTIONS, BaseCLI


Expand Down
2 changes: 1 addition & 1 deletion sup3r/utilities/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import phygnn
import rex

from sup3r.version import __version__
from sup3r import __version__


VERSION_RECORD = {'sup3r': __version__,
Expand Down
2 changes: 1 addition & 1 deletion sup3r/utilities/regridder_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
from inspect import signature
import os

from sup3r import __version__
from sup3r.utilities import ModuleName
from sup3r.version import __version__
from sup3r.utilities.regridder import RegridOutput
from sup3r.utilities.cli import AVAILABLE_HARDWARE_OPTIONS, BaseCLI

Expand Down
3 changes: 0 additions & 3 deletions sup3r/version.py

This file was deleted.

Loading