From be54af0d5c66b512299fbca171fac151d904239a Mon Sep 17 00:00:00 2001 From: Stefan Possanner <spossann@ipp.mpg.de> Date: Wed, 26 Apr 2023 09:52:01 +0200 Subject: [PATCH 1/6] Build form pyproject.toml now, removed binary, added console scripts. --- LICENSE | 16 +++++-- bin/compile_gvec_to_python | 12 ----- pyproject.toml | 63 ++++++++++++++++++++++++-- src/gvec_to_python/console/__init__.py | 0 src/gvec_to_python/console/compile.py | 16 +++++++ setup.cfg => xx_setup.cfg | 0 setup.py => xx_setup.py | 0 7 files changed, 87 insertions(+), 20 deletions(-) delete mode 100644 bin/compile_gvec_to_python create mode 100644 src/gvec_to_python/console/__init__.py create mode 100644 src/gvec_to_python/console/compile.py rename setup.cfg => xx_setup.cfg (100%) rename setup.py => xx_setup.py (100%) diff --git a/LICENSE b/LICENSE index 29ce171..96e257a 100644 --- a/LICENSE +++ b/LICENSE @@ -1,8 +1,16 @@ Copyright 2023 (c) T.K. Cheng, F. Hindenlang, S. Possanner | Max Planck Institute for Plasma Physics -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: +Permission is hereby granted, free of charge, to any person obtaining a copy of this software +and associated documentation files (the "Software"), to deal in the Software without restriction, +including without limitation the rights to use, copy, modify, merge, publish, distribute, +sublicense, and/or sell copies of the Software, and to permit persons to whom the Software +is furnished to do so, subject to the following conditions: -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +The above copyright notice and this permission notice shall be included in all copies +or substantial portions of the Software. +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR +PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE +FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file diff --git a/bin/compile_gvec_to_python b/bin/compile_gvec_to_python deleted file mode 100644 index 53d68d2..0000000 --- a/bin/compile_gvec_to_python +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/bash -e - -# Python interpreter -PYTHON=python3 - -# Struphy installation path -cd ~ -INSTALL_PATH=$($PYTHON -c "import gvec_to_python as _; print(_.__path__[0])") - -echo "Makefile: $INSTALL_PATH/Makefile" - -command make -f $INSTALL_PATH/Makefile install_path=$INSTALL_PATH \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index 374b58c..0a25aff 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,61 @@ [build-system] -requires = [ - "setuptools>=42", - "wheel" -] +requires = ["setuptools>=61.0"] build-backend = "setuptools.build_meta" + +[project] +name = "gvec-to-python" +version = "1.1.0" +readme = "README.md" +requires-python = ">=3.7" +license = {file = "LICENSE"} +authors = [ + { name = "Tin Kei Cheng"}, + { name = "Florian Hindenlang"}, + { name = "Stefan Possanner"}, + { email = "stefan.possanner@ipp.mpg.de"}, + { email = "florian.hindenlang@ipp.mpg.de"} +] +description = "Parse GVEC output in Python" +keywords = ["plasma physics", "fusion", "numerical modeling", "mhd equilibrium"] +classifiers = [ + "Programming Language :: Python :: 3", + ] +dependencies = [ + 'matplotlib>=3.3.3', + 'numpy>=1.19.5', + 'pandas>=1.2.1', + 'pyccel', + 'scipy>=1.6.0', + 'tqdm>=4.56.0', + 'vtk>=9.0.3', +] + +[project.urls] +homepage = "https://gitlab.mpcdf.mpg.de/spossann/gvec_to_python" +documentation = "https://readthedocs.org" +repository = "https://github.com/me/spam.git" +changelog = "https://github.com/me/spam/blob/master/CHANGELOG.md" +"Bug Tracker" = "https://github.com/pypa/sampleproject/issues" + +[project.scripts] +compile-gvec-tp = "gvec_to_python.console.compile:compile_gvec_to_python" + +[tool.setuptools.package-data] +'gvec_to_python.testcases' = [ + 'circ_tok/*.dat', + 'circ_tok/*.ini', + 'ellipstell/newBC_E1D6_M6N6/*.dat', + 'ellipstell/newBC_E1D6_M6N6/*.ini', + 'ellipstell/newBC_E4D6_M6N6/*.dat', + 'ellipstell/newBC_E4D6_M6N6/*.ini', + 'ellipstell_v2/newBC_E1D6_M6N6/*.dat', + 'ellipstell_v2/newBC_E1D6_M6N6/*.ini', + 'ellipstell_v2/newBC_E4D6_M6N6/*.dat', + 'ellipstell_v2/newBC_E4D6_M6N6/*.ini', + 'ellipstell_v2/oldBC_E40D5M6N6/*.dat', + 'ellipstell_v2/oldBC_E40D5M6N6/*.ini', + ] +gvec_to_python = ['Makefile'] + + + diff --git a/src/gvec_to_python/console/__init__.py b/src/gvec_to_python/console/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/gvec_to_python/console/compile.py b/src/gvec_to_python/console/compile.py new file mode 100644 index 0000000..6e56e53 --- /dev/null +++ b/src/gvec_to_python/console/compile.py @@ -0,0 +1,16 @@ +def compile_gvec_to_python(): + + import subprocess + import os + import gvec_to_python + + libpath = gvec_to_python.__path__[0] + + print('\nCompiling gvec-to-python kernels ...') + subprocess.run(['make', + '-f', + os.path.join(libpath, 'Makefile'), + 'install_path=' + libpath, + ], check=True, cwd=libpath) + print('Done.') + diff --git a/setup.cfg b/xx_setup.cfg similarity index 100% rename from setup.cfg rename to xx_setup.cfg diff --git a/setup.py b/xx_setup.py similarity index 100% rename from setup.py rename to xx_setup.py -- GitLab From 703854ca846882aee24d59e3cd720f9d3bd07bd8 Mon Sep 17 00:00:00 2001 From: Stefan Possanner <spossann@ipp.mpg.de> Date: Wed, 26 Apr 2023 09:52:38 +0200 Subject: [PATCH 2/6] Removed old setup files --- xx_setup.cfg | 26 -------------------------- xx_setup.py | 46 ---------------------------------------------- 2 files changed, 72 deletions(-) delete mode 100644 xx_setup.cfg delete mode 100644 xx_setup.py diff --git a/xx_setup.cfg b/xx_setup.cfg deleted file mode 100644 index c051619..0000000 --- a/xx_setup.cfg +++ /dev/null @@ -1,26 +0,0 @@ -[metadata] -author = Tin Kei Cheng, Stefan Possanner -author_email = stefan.possanner@ipp.mpg.de -description = Converts GVEC output to Python callables -long_description = file: README.md -long_description_content_type = text/markdown -keywords = plasma, mhd, equilibrium, discrete differential forms, gvec -url = https://gitlab.mpcdf.mpg.de/spossann/gvec_to_python -project_urls = - Bug Tracker = https://gitlab.mpcdf.mpg.de/spossann/gvec_to_python/-/issues -classifiers = - Programming Language :: Python :: 3 - # License :: OSI Approved :: MIT License - Operating System :: OS Independent - -[options] -package_dir = - = src -packages = find: -python_requires = >=3.6 - -[options.packages.find] -where = src - -# https://www.sphinx-doc.org/en/master/usage/advanced/setuptools.html -# [build_sphinx] diff --git a/xx_setup.py b/xx_setup.py deleted file mode 100644 index a145add..0000000 --- a/xx_setup.py +++ /dev/null @@ -1,46 +0,0 @@ -from setuptools import setup, find_packages - -with open('src/gvec_to_python/version.py') as f: - exec(f.read()) - -setup( - name="gvec_to_python", - version=__version__, # auto-detected from struphy/version.py - packages=find_packages(), - package_data={ - 'gvec_to_python.testcases': [ - 'circ_tok/*.dat', - 'circ_tok/*.ini', - 'ellipstell/newBC_E1D6_M6N6/*.dat', - 'ellipstell/newBC_E1D6_M6N6/*.ini', - 'ellipstell/newBC_E4D6_M6N6/*.dat', - 'ellipstell/newBC_E4D6_M6N6/*.ini', - 'ellipstell_v2/newBC_E1D6_M6N6/*.dat', - 'ellipstell_v2/newBC_E1D6_M6N6/*.ini', - 'ellipstell_v2/newBC_E4D6_M6N6/*.dat', - 'ellipstell_v2/newBC_E4D6_M6N6/*.ini', - 'ellipstell_v2/oldBC_E40D5M6N6/*.dat', - 'ellipstell_v2/oldBC_E40D5M6N6/*.ini', - ], - 'gvec_to_python': ['Makefile'], - }, - # list of executable(s) that come with the package (if applicable)s - scripts=['bin/compile_gvec_to_python', - ], - # list of package dependencies (if necessary) - install_requires=[ - 'matplotlib>=3.3.3', - 'numpy>=1.19.5', - 'pandas>=1.2.1', - 'pyccel', - 'scipy>=1.6.0', - 'tqdm>=4.56.0', - 'vtk>=9.0.3', - ], - # more information, necessary for an upload to PyPI - author="Max Planck Institute for Plasma Physics", - author_email="stefan.possanner@ipp.mpg.de, florian.hindenlang@ipp.mpg.de", - description="Parse GVEC output in Python", - license="MIT", - keywords="plasma physics, fusion, numerical modeling, mhd equilibrium", -) -- GitLab From d235d9e18cd7570d42f5ea1f8af454e68c6cea91 Mon Sep 17 00:00:00 2001 From: Stefan Possanner <spossann@ipp.mpg.de> Date: Thu, 4 May 2023 08:17:47 +0200 Subject: [PATCH 3/6] Update ci, change version to 1.1.1 --- .gitlab-ci.yml | 41 ++++++++++++++++++++++++++--------------- pyproject.toml | 9 +++------ 2 files changed, 29 insertions(+), 21 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 9c8e491..1764d60 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -25,46 +25,57 @@ default: - ls ipp-env - echo "Bye, $GITLAB_USER_LOGIN!" +variables: + TWINE_USERNAME: __token__ + TWINE_PASSWORD: pypi-AgEIcHlwaS5vcmcCJDE4YzU1YzIwLWVhY2QtNDQyZS04ODRjLTJjYTE3OTI3MDQ4YgACKlszLCI4NzYzODllYi05NWE4LTRlOTktYjg2Ny0zNDcwNDM5NjI2ZjciXQAABiD3B8VE_t8BNsezFEMcF2ZLblhgufgnrfXgCSmGuW5H4w +stages: + - install_and_test + - release # Changes (e.g. apt install, pip install) do not persist across different GitLab CI jobs. # => Consolidate everything in GitLab CI into a single job, because the design is dumb. # => Since we only have one job, and GitLab Pages requires the job to be called `pages` for it to work, we now call this job `pages`. install_and_test: - + stage: install_and_test before_script: # Overrides global `before_script`. - - echo "Hello, $GITLAB_USER_LOGIN!" - python -V # Print out python version for debugging. - pwd - # Install everything. - - apt-get -qq update && apt-get -qq install -y gcc gfortran libblas-dev liblapack-dev libopenmpi-dev openmpi-bin rsync tree ffmpeg libsm6 libxext6 - # To output PDF document using Sphinx. - # - apt-get -qq insall -y texlive-latex-recommended texlive-fonts-recommended tex-gyre texlive-latex-extra latexmk texlive-lang-cyrillic texlive-lang-greek cm-super texlive-xetex texlive-luatex fonts-freefont-otf xindy graphviz + - apt-get -qq update && apt-get -qq install -y gcc gfortran libblas-dev liblapack-dev libopenmpi-dev openmpi-bin - python -m venv ipp-env - source ipp-env/bin/activate - - pip install -U pip build wheel pytest pytest-cov coverage - # - pip install -r requirements.txt - - # Print directory structure, but exclude virtual environment directory. - - tree -I 'ipp-env' - + - pip install -U pip build pytest pytest-cov coverage twine script: - # Build: build python package, install package. - echo "Run python build:" - python -m build - ls -lah dist - echo "Install dist:" - pip install -U dist/gvec_to_python-*.whl --force-reinstall - # compile - pip show gvec_to_python - - compile_gvec_to_python + - compile-gvec-tp # Test: run pytest and coverage report. - echo "Run pytest and coverage report:" - coverage run -m pytest - coverage xml - coverage report --skip-empty + artifacts: + paths: + - dist/ + + +# release +deploy: + stage: release + rules: + - if: $CI_COMMIT_TAG + when: never + - if: $CI_COMMIT_REF_NAME == "master" + needs: ["install_and_test"] + script: + - twine upload dist/* + diff --git a/pyproject.toml b/pyproject.toml index 0a25aff..78b5370 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "gvec-to-python" -version = "1.1.0" +version = "1.1.1" readme = "README.md" requires-python = ">=3.7" license = {file = "LICENSE"} @@ -31,11 +31,8 @@ dependencies = [ ] [project.urls] -homepage = "https://gitlab.mpcdf.mpg.de/spossann/gvec_to_python" -documentation = "https://readthedocs.org" -repository = "https://github.com/me/spam.git" -changelog = "https://github.com/me/spam/blob/master/CHANGELOG.md" -"Bug Tracker" = "https://github.com/pypa/sampleproject/issues" +repository = "https://gitlab.mpcdf.mpg.de/spossann/gvec_to_python" +"Bug Tracker" = "https://gitlab.mpcdf.mpg.de/spossann/gvec_to_python/-/issues" [project.scripts] compile-gvec-tp = "gvec_to_python.console.compile:compile_gvec_to_python" -- GitLab From f092e9a8370f822b354eee9d53206a1399f99417 Mon Sep 17 00:00:00 2001 From: Stefan Possanner <spossann@ipp.mpg.de> Date: Thu, 4 May 2023 08:28:10 +0200 Subject: [PATCH 4/6] Update README --- .gitlab-ci.yml | 1 + README.md | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 1764d60..2ae9a6c 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -26,6 +26,7 @@ default: - echo "Bye, $GITLAB_USER_LOGIN!" variables: + PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip" TWINE_USERNAME: __token__ TWINE_PASSWORD: pypi-AgEIcHlwaS5vcmcCJDE4YzU1YzIwLWVhY2QtNDQyZS04ODRjLTJjYTE3OTI3MDQ4YgACKlszLCI4NzYzODllYi05NWE4LTRlOTktYjg2Ny0zNDcwNDM5NjI2ZjciXQAABiD3B8VE_t8BNsezFEMcF2ZLblhgufgnrfXgCSmGuW5H4w diff --git a/README.md b/README.md index 49a2b94..32f35ea 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # 3D GVEC equilibria in Python -PyPI install (not yet :-): +PyPI install: ``` pip install gvec_to_python @@ -13,7 +13,7 @@ pip install -e . ``` Compile kernels for faster evaluations: ``` -compile_gvec_to_python +compile-gvec-tp ``` # Usage -- GitLab From 342f214bb61607d6f848f36e7f5b40386a7d6e0b Mon Sep 17 00:00:00 2001 From: Stefan Possanner <spossann@ipp.mpg.de> Date: Thu, 4 May 2023 08:33:01 +0200 Subject: [PATCH 5/6] Update license --- LICENSE | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LICENSE b/LICENSE index 96e257a..bfcf303 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -Copyright 2023 (c) T.K. Cheng, F. Hindenlang, S. Possanner | Max Planck Institute for Plasma Physics +Copyright 2021 (c) T.K. Cheng, F. Hindenlang, S. Possanner | Max Planck Institute for Plasma Physics Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, -- GitLab From 258da063a9dc5323e38f29b5d05600c1d23790af Mon Sep 17 00:00:00 2001 From: Stefan Possanner <spossann@ipp.mpg.de> Date: Thu, 4 May 2023 08:38:24 +0200 Subject: [PATCH 6/6] Remove tree from ci --- .gitlab-ci.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 2ae9a6c..aa6bda6 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -21,7 +21,6 @@ default: - dist/* after_script: # Global `after_script`. - - tree -I 'ipp-env' # Print directory structure, but exclude virtual environment directory. - ls ipp-env - echo "Bye, $GITLAB_USER_LOGIN!" -- GitLab