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

Switch from setup.py to pyproject.toml #1111

Open
wants to merge 26 commits into
base: main
Choose a base branch
from
Open
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
7 changes: 5 additions & 2 deletions .github/actions/build-py/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,11 @@ runs:
shell: bash
run: |
cd pycode/memilio-${{ inputs.package }}/
/opt/python/cp38-cp38/bin/python setup.py bdist_wheel
/opt/python/cp311-cp311/bin/python setup.py bdist_wheel
/opt/python/cp38-cp38/bin/python -m pip install build
/opt/python/cp38-cp38/bin/python -m build --wheel --outdir dist

/opt/python/cp311-cp311/bin/python -m pip install build
/opt/python/cp311-cp311/bin/python -m build --wheel --outdir dist
# Exclude memilio-generation, because its a pure python package, cmake is only used in the build process to retrieve data from cpp
if [[ -f "CMakeLists.txt" ]] && [ "${{ inputs.package }}" != "generation" ]; then
# includes native dependencies in the wheel
Expand Down
4 changes: 2 additions & 2 deletions .github/actions/test-pylint/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ runs:
uses: actions/download-artifact@v4
with:
name: python-wheels-${{ inputs.package }}
path: pycode/wheelhouse
- name: Install Python Wheels
shell: bash
run: |
Expand All @@ -27,8 +28,7 @@ runs:
shell: bash
run: |
cd pycode/memilio-${{ inputs.package }}
mkdir -p build_pylint
python setup.py pylint
python memilio/custom_pylint.py
pylint-json2html -f jsonextended -o build_pylint/pylint.html < build_pylint/pylint_extended.json
- name: Upload Pylint Report
uses: actions/upload-artifact@v4
Expand Down
4 changes: 2 additions & 2 deletions pycode/memilio-epidata/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,8 @@ See Installation on how to install all these dependencies automatically.
Run pylint with the commands

.. code:: sh

python setup.py pylint
memiliopylint
pylint-json2html -f jsonextended -o build_pylint/pylint.html < build_pylint/pylint_extended.json

Pylint report for actual master:
Expand Down
53 changes: 53 additions & 0 deletions pycode/memilio-epidata/memilio/custom_pylint.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
from setuptools import Command, Distribution
import os

__version__ = '1.0.0'


class PylintCommand(Command):
"""
Custom command to run pylint and get a report as html.
"""
description = "Runs pylint and outputs the report as html."
user_options = []

def initialize_options(self):
from pylint.reporters.json_reporter import JSONReporter
from pylint.reporters.text import ParseableTextReporter, TextReporter
from pylint_json2html import JsonExtendedReporter

self.lint_modules = ["memilio/"]
self.out_format = "extendedjson"

self.REPORTERS = {
"parseable": (ParseableTextReporter, "build_pylint/pylint_parseable.txt"),
"text": (TextReporter, "build_pylint/pylint.txt"),
"json": (JSONReporter, "build_pylint/pylint.json"),
"extendedjson": (JsonExtendedReporter, "build_pylint/pylint_extended.json")
}

def finalize_options(self):
self.reporter, self.out_file = self.REPORTERS.get(
self.out_format)

def run(self):
os.makedirs("build_pylint", exist_ok=True)

# Run pylint
from pylint import lint
with open(self.out_file, "w", encoding="utf-8") as report_file:
options = ["--rcfile=../pylintrc", *self.lint_modules]

lint.Run(options, reporter=self.reporter(
report_file), do_exit=False)


def main():
cmd = PylintCommand(dist=Distribution())
cmd.initialize_options()
cmd.finalize_options()
cmd.run()


if __name__ == "__main__":
main()
65 changes: 65 additions & 0 deletions pycode/memilio-epidata/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
[build-system]
requires = ["setuptools>=61.0"]
build-backend = "setuptools.build_meta"

[tool.setuptools]
packages = [ "memilio", "memilio.epidata", "memilio.epidata_test"]

[project]
name = "memilio-epidata"
version = "1.0.0"
readme = "README.rst"
authors = [{name = "DLR-SC", email = "[email protected]"}]
maintainers = [{email = "[email protected]"}]
description = "Part of MEmilio project, reads epidemiological data from different official and unofficial sources."
requires-python = ">=3.8"
dependencies = [
# pandas 2.0 is minimum for CoW
"pandas>=2.0.0",
# FutureWarning of pandas that pyarrow will be required in a future release
"pyarrow",
"matplotlib",
"tables",
# smaller numpy versions cause a security issue, 1.25 breaks testing with pyfakefs
"numpy>=1.22,<1.25",
"openpyxl",
"xlrd",
"xlsxwriter",
"requests",
"pyxlsb",
"wget",
"twill==3.1",
"PyQt6",
"python-calamine",
"python-magic-bin; sys_platform == 'win32'",
"python-magic; sys_platform != 'win32'"
]

[project.optional-dependencies]
dev = [
# first support of python 3.11 4.6
# 5.3.4 has conflicts with openpyxl
# 5.3.3 broken
"pyfakefs>=4.6,<5.3.3",
# coverage 7.0.0 can't find .whl files and breaks CI
"coverage>=7.0.1",
# pylint 2.16 creates problem with wrapt package version
"pylint>=2.13.0,<2.16",
"pylint_json2html==0.4.0",
]

[project.urls]
Repository = "https://github.com/SciCompMod/memilio"
Issues = "https://github.com/SciCompMod/memilio/issues"

[project.scripts]
getcasedata = "memilio.epidata.getCaseData:main"
getpopuldata = "memilio.epidata.getPopulationData:main"
getjhdata = "memilio.epidata.getJHData:main"
getdividata = "memilio.epidata.getDIVIData:main"
getsimdata = "memilio.epidata.getSimulationData:main"
cleandata = "memilio.epidata.cleanData:main"
getcommutermobility = "memilio.epidata.getCommuterMobility:main"
getvaccinationdata = "memilio.epidata.getVaccinationData:main"
gethospitalizationdata = "memilio.epidata.getHospitalizationData:main"
memiliopylint = "memilio.custom_pylint:main"
114 changes: 0 additions & 114 deletions pycode/memilio-epidata/setup.py

This file was deleted.

53 changes: 53 additions & 0 deletions pycode/memilio-plot/memilio/custom_pylint.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
from setuptools import Command, Distribution
import os

__version__ = '1.0.0'


class PylintCommand(Command):
"""
Custom command to run pylint and get a report as html.
"""
description = "Runs pylint and outputs the report as html."
user_options = []

def initialize_options(self):
from pylint.reporters.json_reporter import JSONReporter
from pylint.reporters.text import ParseableTextReporter, TextReporter
from pylint_json2html import JsonExtendedReporter

self.lint_modules = ["memilio/"]
self.out_format = "extendedjson"

self.REPORTERS = {
"parseable": (ParseableTextReporter, "build_pylint/pylint_parseable.txt"),
"text": (TextReporter, "build_pylint/pylint.txt"),
"json": (JSONReporter, "build_pylint/pylint.json"),
"extendedjson": (JsonExtendedReporter, "build_pylint/pylint_extended.json")
}

def finalize_options(self):
self.reporter, self.out_file = self.REPORTERS.get(
self.out_format)

def run(self):
os.makedirs("build_pylint", exist_ok=True)

# Run pylint
from pylint import lint
with open(self.out_file, "w", encoding="utf-8") as report_file:
options = ["--rcfile=../pylintrc", *self.lint_modules]

lint.Run(options, reporter=self.reporter(
report_file), do_exit=False)


def main():
cmd = PylintCommand(dist=Distribution())
cmd.initialize_options()
cmd.finalize_options()
cmd.run()


if __name__ == "__main__":
main()
55 changes: 55 additions & 0 deletions pycode/memilio-plot/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
[build-system]
requires = ["setuptools>=61.0"]
build-backend = "setuptools.build_meta"

[tool.setuptools]
packages = [ "memilio", "memilio.plot", "memilio.plot_test"]

[project]
name = "memilio-plot"
version = "1.0.0"
readme = "README.md"
authors = [{name = "DLR-SC", email = "[email protected]"}]
maintainers = [{email = "[email protected]"}]
description = "Part of MEmilio project, plots data to maps or visualizes simulation curves."
requires-python = ">=3.8"
dependencies = [
# smaller pandas versions contain a bug that sometimes prevents reading
# some excel files (e.g. population or twitter data)
"pandas>=1.2.2",
"matplotlib",
"tables",
# smaller numpy versions cause a security issue, 1.25 breaks testing with pyfakefs
"numpy>=1.22,<1.25",
"openpyxl",
"xlrd",
"requests",
"pyxlsb",
"wget",
"folium",
"mapclassify",
"geopandas",
"h5py",
"imageio",
"datetime"
]

[project.optional-dependencies]
dev = [
# first support of python 3.11 4.6
# 5.3.4 has conflicts with openpyxl
# 5.3.3 broken
"pyfakefs>=4.6,<5.3.3",
# coverage 7.0.0 can't find .whl files and breaks CI
"coverage>=7.0.1",
# pylint 2.16 creates problem with wrapt package version
"pylint>=2.13.0,<2.16",
"pylint_json2html==0.4.0",
]

[project.urls]
Repository = "https://github.com/SciCompMod/memilio"
Issues = "https://github.com/SciCompMod/memilio/issues"

[project.scripts]
memiliopylint = "memilio.custom_pylint:main"
Loading
Loading