diff --git a/.github/actions/build-py/action.yml b/.github/actions/build-py/action.yml index ed7e937538..0def718c1b 100644 --- a/.github/actions/build-py/action.yml +++ b/.github/actions/build-py/action.yml @@ -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 diff --git a/.github/actions/test-pylint/action.yml b/.github/actions/test-pylint/action.yml index 9f9f50bc2c..5d59e09a2a 100644 --- a/.github/actions/test-pylint/action.yml +++ b/.github/actions/test-pylint/action.yml @@ -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: | @@ -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 diff --git a/pycode/memilio-epidata/README.rst b/pycode/memilio-epidata/README.rst index be21a21a89..dd120ec6ee 100644 --- a/pycode/memilio-epidata/README.rst +++ b/pycode/memilio-epidata/README.rst @@ -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: diff --git a/pycode/memilio-epidata/memilio/custom_pylint.py b/pycode/memilio-epidata/memilio/custom_pylint.py new file mode 100644 index 0000000000..0b2ff300d1 --- /dev/null +++ b/pycode/memilio-epidata/memilio/custom_pylint.py @@ -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() diff --git a/pycode/memilio-epidata/pyproject.toml b/pycode/memilio-epidata/pyproject.toml new file mode 100644 index 0000000000..f104a55886 --- /dev/null +++ b/pycode/memilio-epidata/pyproject.toml @@ -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 = "daniel.abele@dlr.de"}] +maintainers = [{email = "martin.kuehn@dlr.de"}] +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" \ No newline at end of file diff --git a/pycode/memilio-epidata/setup.py b/pycode/memilio-epidata/setup.py deleted file mode 100644 index de62cf1872..0000000000 --- a/pycode/memilio-epidata/setup.py +++ /dev/null @@ -1,114 +0,0 @@ -import os -import subprocess -import sys - -from setuptools import Command, find_packages, setup - -__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) # , self.REPORTERS.get("parseable")) - - 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) - - -# Python-magic needs DLLs for libmagic. They have to be installed only on windows. -if sys.platform == 'win32': - pymagic = 'python-magic-bin' -else: - pymagic = 'python-magic' - -setup( - name='memilio-epidata', - version=__version__, - author='DLR-SC', - author_email='daniel.abele@dlr.de', - maintainer_email='martin.kuehn@dlr.de', - url='https://github.com/SciCompMod/memilio', - description='Part of MEmilio project, reads epidemiological data from different official and unofficial sources.', - entry_points={ - 'console_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' - ], - }, - packages=find_packages(where=os.path.dirname(os.path.abspath(__file__))), - long_description='', - test_suite='memilio.epidata_test', - install_requires=[ - # 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', - pymagic - ], - extras_require={ - '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', - ], - }, - cmdclass={ - 'pylint': PylintCommand - }, -) diff --git a/pycode/memilio-plot/memilio/custom_pylint.py b/pycode/memilio-plot/memilio/custom_pylint.py new file mode 100644 index 0000000000..0b2ff300d1 --- /dev/null +++ b/pycode/memilio-plot/memilio/custom_pylint.py @@ -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() diff --git a/pycode/memilio-plot/pyproject.toml b/pycode/memilio-plot/pyproject.toml new file mode 100644 index 0000000000..b5f055e448 --- /dev/null +++ b/pycode/memilio-plot/pyproject.toml @@ -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 = "martin.kuehn@dlr.de"}] +maintainers = [{email = "martin.kuehn@dlr.de"}] +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" \ No newline at end of file diff --git a/pycode/memilio-plot/setup.py b/pycode/memilio-plot/setup.py deleted file mode 100644 index 30efd2c76f..0000000000 --- a/pycode/memilio-plot/setup.py +++ /dev/null @@ -1,96 +0,0 @@ -import os -import subprocess -import sys - -from setuptools import Command, find_packages, setup - -__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) # , self.REPORTERS.get("parseable")) - - 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) - - -setup( - name='memilio-plot', - version=__version__, - author='DLR-SC', - author_email='martin.kuehn@dlr.de', - maintainer_email='martin.kuehn@dlr.de', - url='https://github.com/SciCompMod/memilio', - description='Part of MEmilio project, plots data to maps or visualizes simulation curves.', - entry_points={ - 'console_scripts': [ - ], - }, - packages=find_packages(where=os.path.dirname(os.path.abspath(__file__))), - long_description='', - test_suite='memilio.plot_test', - install_requires=[ - # smaller pandas versions contain a bug that sometimes prevents reading - # some excel files (e.g. population or twitter data) - 'pandas>=1.2.2', - 'matplotlib', - # smaller numpy versions cause a security issue, 1.25 breaks testing with pyfakefs - 'numpy>=1.22,<1.25', - 'openpyxl', - 'xlrd', - 'requests', - 'pyxlsb', - 'wget', - 'folium', - 'matplotlib', - 'mapclassify', - 'geopandas', - 'h5py', - 'imageio', - 'datetime' - ], - extras_require={ - 'dev': [ - # first support of python 3.11 - 'pyfakefs>=4.6', - 'coverage>=7.0.1', - # pylint 2.16 creates problem with wrapt package version - 'pylint>=2.13.0,<2.16', - 'pylint_json2html==0.4.0', - ], - }, - cmdclass={ - 'pylint': PylintCommand - }, -) diff --git a/pycode/memilio-simulation/pyproject.toml b/pycode/memilio-simulation/pyproject.toml new file mode 100644 index 0000000000..e2c1c01ca1 --- /dev/null +++ b/pycode/memilio-simulation/pyproject.toml @@ -0,0 +1,22 @@ +[build-system] +requires = ["setuptools>=61.0", "cmake>=3.18"] +build-backend = "setuptools.build_meta" + +[tool.setuptools] +packages = ["memilio", "memilio.epidata", "memilio.epidata_test"] + +[project] +name = "memilio-simulation" +version = "1.0.0" +readme = "README.rst" +authors = [{name = "DLR-SC", email = "daniel.abele@dlr.de"}] +maintainers = [{email = "martin.kuehn@dlr.de"}] +description = "Part of MEmilio project, python bindings to the C++ libraries that contain the models and simulations." + +[project.optional-dependencies] +dev = ["numpy>=1.22,<1.25", + "pandas>=2.0.0"] + +[project.urls] +Repository = "https://github.com/SciCompMod/memilio" +Issues = "https://github.com/SciCompMod/memilio/issues" \ No newline at end of file diff --git a/pycode/memilio-simulation/setup.py b/pycode/memilio-simulation/setup.py index 873b65eee3..182fdc12c4 100644 --- a/pycode/memilio-simulation/setup.py +++ b/pycode/memilio-simulation/setup.py @@ -1,34 +1,16 @@ import os -import subprocess -import sys -from setuptools import find_packages, setup +from setuptools import find_packages -try: - from skbuild import setup -except ImportError: - print('scikit-build is required to build from source.') - print('Installation: python -m pip install scikit-build') - subprocess.check_call( - [sys.executable, "-m", "pip", "install", "scikit-build"]) - from skbuild import setup - -__version__ = '1.0.0' +from skbuild import setup setup( - name='memilio-simulation', version=__version__, author='DLR-SC', - author_email='daniel.abele@dlr.de', maintainer_email='Martin.Kuehn@DLR.de', - url='https://github.com/SciCompMod/memilio', - description='Part of MEmilio project, python bindings to the C++ libraries that contain the models and simulations.', packages=find_packages(where=os.path.dirname(os.path.abspath(__file__))), setup_requires=['cmake'], # need shared libs so there is one shared log level cmake_args=['-DMEMILIO_BUILD_SHARED_LIBS:BOOL=ON'], - install_requires=[ - ], extras_require={ 'dev': [ - # smaller numpy versions cause a security issue, 1.25 breaks testing with pyfakefs 'numpy>=1.22,<1.25', # smaller pandas versions contain a bug that sometimes prevents reading # some excel files (e.g. population or twitter data)