From c74987ed18e3780e94554ef25189a31f0d0574fb Mon Sep 17 00:00:00 2001 From: bitranox Date: Fri, 21 Jul 2023 11:40:47 +0200 Subject: [PATCH] v1.2.9 -------- 2023-07-21: - require minimum python 3.8 - remove python 3.7 tests - introduce PEP517 packaging standard - introduce pyproject.toml build-system - remove mypy.ini - remove pytest.ini - remove setup.cfg - remove setup.py - remove .bettercodehub.yml - remove .travis.yml - update black config - clean ./tests/test_cli.py - add codeql badge - move 3rd_party_stubs outside the src directory to ``./.3rd_party_stubs`` - add pypy 3.10 tests - add python 3.12-dev tests --- .../readme.txt | 6 +- .bettercodehub.yml | 6 - .coveragerc | 10 +- .docs/README_template.rst | 6 +- .docs/badges.rst | 23 +- .docs/commandline_help.rst | 2 +- .docs/installation.rst | 12 +- .docs/installation_via_pypi.rst | 10 +- .docs/tested_under.rst | 4 +- .flake8 | 5 + .github/workflows/codeql-analysis.yml | 70 +++++ .github/workflows/python-package.yml | 259 ++++++++++++++++++ .travis.yml | 217 --------------- CHANGES.rst | 20 ++ CODE_OF_CONDUCT.md | 88 +++--- LICENSE | 2 +- Makefile | 2 + README.rst | 85 ++++-- conftest.py | 15 +- lib_platform.ipynb | 2 +- lib_platform/__init__conf__.py | 6 +- lib_platform/lib_platform_cli.py | 4 +- pyproject.toml | 85 +++++- requirements.txt | 4 +- requirements_test.txt | 7 +- setup.cfg | 19 -- setup.py | 124 --------- tests/local_testscripts/lib_bash_functions.sh | 90 ++++-- tests/local_testscripts/run_testloop.sh | 14 +- ..._testloop_pytest_and_mypy_only_no_setup.sh | 61 +++++ travis_secrets/create_secrets.sh | 26 -- travis_secrets/create_secrets_bash_helpers.sh | 90 ------ .../secrets/CC_TEST_REPORTER_ID.secret.txt | 1 - .../secrets/PYPI_PASSWORD.secret.txt | 1 - travis_secrets/shellcheck.sh | 50 ---- 35 files changed, 740 insertions(+), 686 deletions(-) rename {lib_platform/3rd_party_stubs => .3rd_party_stubs}/readme.txt (83%) delete mode 100644 .bettercodehub.yml create mode 100644 .flake8 create mode 100644 .github/workflows/codeql-analysis.yml create mode 100644 .github/workflows/python-package.yml delete mode 100644 .travis.yml delete mode 100644 setup.cfg delete mode 100644 setup.py create mode 100644 tests/local_testscripts/run_testloop_pytest_and_mypy_only_no_setup.sh delete mode 100644 travis_secrets/create_secrets.sh delete mode 100644 travis_secrets/create_secrets_bash_helpers.sh delete mode 100644 travis_secrets/secrets/CC_TEST_REPORTER_ID.secret.txt delete mode 100644 travis_secrets/secrets/PYPI_PASSWORD.secret.txt delete mode 100644 travis_secrets/shellcheck.sh diff --git a/lib_platform/3rd_party_stubs/readme.txt b/.3rd_party_stubs/readme.txt similarity index 83% rename from lib_platform/3rd_party_stubs/readme.txt rename to .3rd_party_stubs/readme.txt index 1284afd..63da825 100644 --- a/lib_platform/3rd_party_stubs/readme.txt +++ b/.3rd_party_stubs/readme.txt @@ -1,6 +1,6 @@ -put 3rd party stubs in this directory needed to pass mypy on travis. +put 3rd party stubs in this directory needed to pass mypy on Github Actions. -in the travis.yml the MYPYPATH is set to this directory. +in the Github Actions the MYPYPATH is set to this directory. for local testing, put the *.pyi Files into another central directory and set the mypy path accordingly. the reason for that is, that a certain *.pyi have to be only found once by mypy, otherwise it will throw an error. @@ -17,6 +17,6 @@ the module "external_test" is used in project_a, and project_b, and package_a im -- project_B ------- package_b_dir --- 3rd_party_stubs --- external_test.pyi -for travis test of project_A we need to set the MYPYPATH to .../projects/project_A/package_a_dir/3rd_party_stubs +for travis test of project_A we need to set the MYPYPATH to .../projects/project_A/3rd_party_stubs for local tests, we need to set the MYPYPATH to .../projects/stub_directory , not to find external_test.pyi twice. diff --git a/.bettercodehub.yml b/.bettercodehub.yml deleted file mode 100644 index 5565464..0000000 --- a/.bettercodehub.yml +++ /dev/null @@ -1,6 +0,0 @@ -component_depth: 4 -languages: - - python -exclude: - # regex pattern, see https://bettercodehub.com/docs/configuration-manual - - .*/setup\.py diff --git a/.coveragerc b/.coveragerc index 20f3c68..10b6609 100644 --- a/.coveragerc +++ b/.coveragerc @@ -7,6 +7,11 @@ # (boolean, default False): whether to measure branch coverage in addition to statement coverage branch = True +omit = + venv/* + tests/* + setup.py + [report] # Regexes for lines to exclude from consideration @@ -29,8 +34,3 @@ exclude_lines= ignore_errors = True -omit = - venv/* - tests/* - setup.py - conf_lib_platform.py diff --git a/.docs/README_template.rst b/.docs/README_template.rst index 7840de8..1bd6ab5 100644 --- a/.docs/README_template.rst +++ b/.docs/README_template.rst @@ -2,7 +2,7 @@ lib_platform ============ -Version v1.2.7 as of 2020-10-09 see `Changelog`_ +Version v1.2.9 as of 2023-07-21 see `Changelog`_ .. include:: ./badges.rst @@ -11,10 +11,10 @@ Version v1.2.7 as of 2020-10-09 see `Changelog`_ ---- -automated tests, Travis Matrix, Documentation, Badges, etc. are managed with `PizzaCutter `_ (cookiecutter on steroids) -Python version required: 3.6.0 or newer +Python version required: 3.8.0 or newer .. include:: ./tested_under.rst diff --git a/.docs/badges.rst b/.docs/badges.rst index e874d59..c47ee67 100644 --- a/.docs/badges.rst +++ b/.docs/badges.rst @@ -1,16 +1,20 @@ -|travis_build| |license| |jupyter| |pypi| +|build_badge| |codeql| |license| |jupyter| |pypi| +|pypi-downloads| |black| |codecov| |cc_maintain| |cc_issues| |cc_coverage| |snyk| -|codecov| |better_code| |cc_maintain| |cc_issues| |cc_coverage| |snyk| -.. |travis_build| image:: https://img.shields.io/travis/bitranox/lib_platform/master.svg - :target: https://travis-ci.org/bitranox/lib_platform +.. |build_badge| image:: https://github.com/bitranox/lib_platform/actions/workflows/python-package.yml/badge.svg + :target: https://github.com/bitranox/lib_platform/actions/workflows/python-package.yml + + +.. |codeql| image:: https://github.com/bitranox/lib_platform/actions/workflows/codeql-analysis.yml/badge.svg?event=push + :target: https://github.com//bitranox/lib_platform/actions/workflows/codeql-analysis.yml .. |license| image:: https://img.shields.io/github/license/webcomics/pywine.svg :target: http://en.wikipedia.org/wiki/MIT_License .. |jupyter| image:: https://mybinder.org/badge_logo.svg - :target: https://mybinder.org/v2/gh/bitranox/lib_platform/master?filepath=lib_platform.ipynb + :target: https://mybinder.org/v2/gh/bitranox/lib_platform/master?filepath=lib_platform.ipynb .. for the pypi status link note the dashes, not the underscore ! .. |pypi| image:: https://img.shields.io/pypi/status/lib-platform?label=PyPI%20Package @@ -19,9 +23,6 @@ .. |codecov| image:: https://img.shields.io/codecov/c/github/bitranox/lib_platform :target: https://codecov.io/gh/bitranox/lib_platform -.. |better_code| image:: https://bettercodehub.com/edge/badge/bitranox/lib_platform?branch=master - :target: https://bettercodehub.com/results/bitranox/lib_platform - .. |cc_maintain| image:: https://img.shields.io/codeclimate/maintainability-percentage/bitranox/lib_platform?label=CC%20maintainability :target: https://codeclimate.com/github/bitranox/lib_platform/maintainability :alt: Maintainability @@ -34,8 +35,12 @@ :target: https://codeclimate.com/github/bitranox/lib_platform/test_coverage :alt: Code Coverage -.. |snyk| image:: https://img.shields.io/snyk/vulnerabilities/github/bitranox/lib_platform +.. |snyk| image:: https://snyk.io/test/github/bitranox/lib_platform/badge.svg :target: https://snyk.io/test/github/bitranox/lib_platform .. |black| image:: https://img.shields.io/badge/code%20style-black-000000.svg :target: https://github.com/psf/black + +.. |pypi-downloads| image:: https://img.shields.io/pypi/dm/lib-platform + :target: https://pypi.org/project/lib-platform/ + :alt: PyPI - Downloads diff --git a/.docs/commandline_help.rst b/.docs/commandline_help.rst index fc78aa5..e57601c 100644 --- a/.docs/commandline_help.rst +++ b/.docs/commandline_help.rst @@ -1,4 +1,4 @@ -.. code-block:: bash +.. code-block:: Usage: lib_platform [OPTIONS] COMMAND [ARGS]... diff --git a/.docs/installation.rst b/.docs/installation.rst index 4d56e45..87b7f01 100644 --- a/.docs/installation.rst +++ b/.docs/installation.rst @@ -1,7 +1,7 @@ - Before You start, its highly recommended to update pip and setup tools: -.. code-block:: bash +.. code-block:: python -m pip --upgrade pip python -m pip --upgrade setuptools @@ -12,14 +12,14 @@ - to install the latest version from github via pip: -.. code-block:: bash +.. code-block:: python -m pip install --upgrade git+https://github.com/bitranox/lib_platform.git - include it into Your requirements.txt: -.. code-block:: bash +.. code-block:: # Insert following line in Your requirements.txt: # for the latest Release on pypi: @@ -32,14 +32,14 @@ python -m pip install --upgrade -r //requirements.txt -- to install the latest development version from source code: +- to install the latest development version, including test dependencies from source code: -.. code-block:: bash +.. code-block:: # cd ~ $ git clone https://github.com/bitranox/lib_platform.git $ cd lib_platform - python setup.py install + python -m pip install -e .[test] .. include:: ./installation_via_makefile.rst diff --git a/.docs/installation_via_pypi.rst b/.docs/installation_via_pypi.rst index fc4fa39..1c467cb 100644 --- a/.docs/installation_via_pypi.rst +++ b/.docs/installation_via_pypi.rst @@ -1,5 +1,13 @@ - to install the latest release from PyPi via pip (recommended): -.. code-block:: bash +.. code-block:: python -m pip install --upgrade lib_platform + + +- to install the latest release from PyPi via pip, including test dependencies: + +.. code-block:: + + python -m pip install --upgrade lib_platform[test] + diff --git a/.docs/tested_under.rst b/.docs/tested_under.rst index 28f7141..2d64680 100644 --- a/.docs/tested_under.rst +++ b/.docs/tested_under.rst @@ -1,3 +1,3 @@ -tested on linux "bionic" with python 3.6, 3.7, 3.8, 3.9-dev, pypy3 - architectures: amd64, ppc64le, s390x, arm64 +tested on recent linux with python 3.8, 3.9, 3.10, 3.11, 3.12-dev, pypy-3.9, pypy-3.10 - architectures: amd64 -`100% code coverage `_, flake8 style checking ,mypy static type checking ,tested under `Linux, macOS, Windows `_, automatic daily builds and monitoring +`100% code coverage `_, flake8 style checking ,mypy static type checking ,tested under `Linux, macOS, Windows `_, automatic daily builds and monitoring diff --git a/.flake8 b/.flake8 new file mode 100644 index 0000000..7e38a25 --- /dev/null +++ b/.flake8 @@ -0,0 +1,5 @@ +[flake8] +max_line_length = 160 +ignore = E123, E203, E402, F401, F403, F405, W503 +exclude = .git, __pycache__, build, dist, .eggs, .hg, .mypy_cache, .nox, .tox, .venv, _build, buck-out +max-complexity = 20 diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml new file mode 100644 index 0000000..89a294a --- /dev/null +++ b/.github/workflows/codeql-analysis.yml @@ -0,0 +1,70 @@ +# For most projects, this workflow file will not need changing; you simply need +# to commit it to your repository. +# +# You may wish to alter this file to override the set of languages analyzed, +# or to provide custom queries or build logic. +# +# ******** NOTE ******** +# We have attempted to detect the languages in your repository. Please check +# the `language` matrix defined below to confirm you have the correct set of +# supported CodeQL languages. +# +name: "CodeQL" + +on: + push: + branches: [ master, development ] + pull_request: + # The branches below must be a subset of the branches above + branches: [ master, development ] + schedule: + - cron: '40 13 * * 6' + +jobs: + analyze: + name: Analyze + runs-on: ubuntu-latest + permissions: + actions: read + contents: read + security-events: write + + strategy: + fail-fast: false + matrix: + language: [ 'python' ] + # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ] + # Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + # Initializes the CodeQL tools for scanning. + - name: Initialize CodeQL + uses: github/codeql-action/init@v2 + with: + languages: ${{ matrix.language }} + # If you wish to specify custom queries, you can do so here or in a config file. + # By default, queries listed here will override any specified in a config file. + # Prefix the list here with "+" to use these queries and those in the config file. + # queries: ./path/to/local/query, your-org/your-repo/queries@main + + # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). + # If this step fails, then you should remove it and run the build manually (see below) + - name: Autobuild + uses: github/codeql-action/autobuild@v2 + + # ℹ️ Command-line programs to run using the OS shell. + # πŸ“š See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun + + # ✏️ If the Autobuild fails above, remove it and uncomment the following three lines + # and modify them (or add more) to build your code if your project + # uses a compiled language + + #- run: | + # make bootstrap + # make release + + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v2 diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml new file mode 100644 index 0000000..6a01b4f --- /dev/null +++ b/.github/workflows/python-package.yml @@ -0,0 +1,259 @@ +# This workflow will install Python dependencies, run tests and lint with a variety of Python versions +# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions + +name: Python package + +on: + push: + branches: [ master, development ] + pull_request: + branches: [ master, development ] + release: + branches: [ master, development ] + # release types see : https://docs.github.com/en/actions/reference/events-that-trigger-workflows#release + # he prereleased type will not trigger for pre-releases published from draft releases, but the published type will trigger. + # If you want a workflow to run when stable and pre-releases publish, subscribe to published instead of released and prereleased. + types: [published] + + schedule: + # * is a special character in YAML, so you have to quote this string + # | minute | hour (UTC) | day of month (1-31) | month (1-2) | day of week (0-6 or SUN-SAT) + # every day at 05:40 am UTC - avoid 05:00 because of high load at the beginning of every hour + - cron: '40 5 * * *' + + +jobs: + + build: + runs-on: ${{ matrix.os }} + + env: + # prefix before commands - used for wine, there the prefix is "wine" + cPREFIX: "" + # command to launch python interpreter (it's different on macOS, there we need python3) + cPYTHON: "python" + # command to launch pip (it's different on macOS, there we need pip3) + cPIP: "python -m pip" + # switch off wine fix me messages + WINEDEBUG: fixme-all + + # PYTEST + PYTEST_DO_TESTS: "True" + + # FLAKE8 tests + DO_FLAKE8_TESTS: "True" + + # MYPY tests + MYPY_DO_TESTS: "True" + MYPY_OPTIONS: "--follow-imports=normal --ignore-missing-imports --implicit-reexport --install-types --no-warn-unused-ignores --non-interactive --strict" + MYPYPATH: "./.3rd_party_stubs" + + # coverage + DO_COVERAGE: "True" + DO_COVERAGE_UPLOAD_CODECOV: "True" + DO_COVERAGE_UPLOAD_CODE_CLIMATE: "True" + + # package name + PACKAGE_NAME: "lib_platform" + # the registered CLI Command + CLI_COMMAND: "lib_platform" + # the source file for rst_include (rebuild rst file includes) + RST_INCLUDE_SOURCE: "./.docs/README_template.rst" + # the target file for rst_include (rebuild rst file includes) + RST_INCLUDE_TARGET: "./README.rst" + # make Code Coverage Secret available in Environment + CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }} + # make PyPi Password available in Environment + PYPI_PASSWORD: ${{ secrets.PYPI_PASSWORD }} + + + strategy: + matrix: + include: + # https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners#supported-software + # https://github.com/actions/setup-python/blob/main/docs/advanced-usage.md#available-versions-of-python-and-pypy + + - os: windows-latest + python-version: "3.11" + env: + cEXPORT: "SET" + BUILD_DOCS: "False" + BUILD: "False" + BUILD_TEST: "False" + MYPY_DO_TESTS: "True" + # Setup tests + DO_SETUP_INSTALL: "True" + DO_SETUP_INSTALL_TEST: "True" + # Test registered CLI Command + DO_CLI_TEST: "True" + + + - os: ubuntu-latest + python-version: "3.8" + env: + BUILD_DOCS: "False" + BUILD: "True" + BUILD_TEST: "True" + MYPY_DO_TESTS: "True" + DO_SETUP_INSTALL: "True" + DO_SETUP_INSTALL_TEST: "True" + DO_CLI_TEST: "True" + + - os: ubuntu-latest + python-version: "3.9" + env: + BUILD_DOCS: "False" + BUILD: "True" + BUILD_TEST: "True" + MYPY_DO_TESTS: "True" + DO_SETUP_INSTALL: "True" + DO_SETUP_INSTALL_TEST: "True" + DO_CLI_TEST: "True" + + - os: ubuntu-latest + python-version: "3.10" + env: + BUILD_DOCS: "False" + BUILD: "True" + BUILD_TEST: "True" + MYPY_DO_TESTS: "True" + DO_SETUP_INSTALL: "True" + DO_SETUP_INSTALL_TEST: "True" + DO_CLI_TEST: "True" + + - os: ubuntu-latest + python-version: "3.11" + env: + BUILD_DOCS: "True" + BUILD: "True" + BUILD_TEST: "True" + MYPY_DO_TESTS: "True" + DO_SETUP_INSTALL: "True" + DO_SETUP_INSTALL_TEST: "True" + DO_CLI_TEST: "True" + + - os: ubuntu-latest + python-version: "3.12-dev" + env: + BUILD_DOCS: "True" + BUILD: "True" + BUILD_TEST: "True" + MYPY_DO_TESTS: "True" + DO_SETUP_INSTALL: "True" + DO_SETUP_INSTALL_TEST: "True" + DO_CLI_TEST: "True" + + - os: ubuntu-latest + python-version: "pypy-3.9" + env: + BUILD_DOCS: "False" + BUILD: "True" + BUILD_TEST: "True" + MYPY_DO_TESTS: "True" + DO_SETUP_INSTALL: "True" + DO_SETUP_INSTALL_TEST: "True" + DO_CLI_TEST: "True" + + - os: ubuntu-latest + python-version: "pypy-3.10" + env: + BUILD_DOCS: "False" + BUILD: "True" + BUILD_TEST: "True" + MYPY_DO_TESTS: "True" + DO_SETUP_INSTALL: "True" + DO_SETUP_INSTALL_TEST: "True" + DO_CLI_TEST: "True" + + - os: macos-latest + python-version: "3.11" + env: + cPREFIX: "" # prefix before commands - used for wine, there the prefix is "wine" + cPYTHON: "python3" # command to launch python interpreter (it's different on macOS, there we need python3) + cPIP: "python3 -m pip" # command to launch pip (it's different on macOS, there we need pip3) + BUILD_DOCS: "False" + BUILD: "True" + BUILD_TEST: "True" + MYPY_DO_TESTS: "True" + # Setup tests + DO_SETUP_INSTALL: "True" + DO_SETUP_INSTALL_TEST: "True" + # Test registered CLI Command + DO_CLI_TEST: "True" + + + name: "${{ matrix.os }} Python ${{ matrix.python-version }}" + + steps: + # see : https://github.com/actions/checkout + - uses: actions/checkout@v3 + + - name: Setting up Python ${{ matrix.python-version }} + # see: https://github.com/actions/setup-python + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} + + - name: Install dependencies + # see: https://github.community/t/github-actions-new-bug-unable-to-create-environment-variables-based-matrix/16104/3 + env: ${{ matrix.env }} # make matrix env variables accessible + # lib_cicd_github install: upgrades pip, setuptools, wheel and pytest-pycodestyle + run: | + ${{ env.cPIP }} install git+https://github.com/bitranox/lib_cicd_github.git + lib_cicd_github install + + - name: Debug - printenv and colortest + env: + # make matrix env variables accessible + ${{ matrix.env }} + shell: bash + run: | + # export for current step + export "BRANCH=$(lib_cicd_github get_branch)" + # export for subsequent steps + echo "BRANCH=$BRANCH" >> $GITHUB_ENV + log_util --level=SPAM "working on branch $BRANCH" + log_util --level=SPAM "GITHUB_REF $GITHUB_REF" + log_util --level=VERBOSE "github.base_ref: ${{ github.base_ref }}" + log_util --level=VERBOSE "github.event: ${{ github.event }}" + log_util --level=VERBOSE "github.event_name: ${{ github.event_name }}" + log_util --level=VERBOSE "github.head_ref: ${{ github.head_ref }}" + log_util --level=VERBOSE "github.job: ${{ github.job }}" + log_util --level=VERBOSE "github.ref: ${{ github.ref }}" + log_util --level=VERBOSE "github.repository: ${{ github.repository }}" + log_util --level=VERBOSE "github.repository_owner: ${{ github.repository_owner }}" + log_util --level=VERBOSE "runner.os: ${{ runner.os }}" + log_util --level=VERBOSE "matrix.python-version: ${{ matrix.python-version }}" + printenv + log_util --colortest + + - name: Run Tests + env: + # make matrix env variables accessible + ${{ matrix.env }} + shell: bash + run: | + # export for current step + export "BRANCH=$(lib_cicd_github get_branch)" + # export for subsequent steps + echo "BRANCH=$BRANCH" >> $GITHUB_ENV + # run the tests + lib_cicd_github script + + - name: After Success + env: + ${{matrix.env }} + shell: bash + continue-on-error: true + run: | + lib_cicd_github after_success + + - name: Deploy + env: + # see: https://docs.github.com/en/actions/reference/context-and-expression-syntax-for-github-actions#github-context + # see : https://github.com/rlespinasse/github-slug-action + # make matrix env variables accessible + ${{matrix.env }} + shell: bash + run: | + lib_cicd_github deploy diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index edd1599..0000000 --- a/.travis.yml +++ /dev/null @@ -1,217 +0,0 @@ -language: python -group: travis_latest -dist: bionic -sudo: true - -env: - global: - # prefix before commands - used for wine, there the prefix is "wine" - - cPREFIX="" - # command to launch python interpreter (its different on macOs, there we need python3) - - cPYTHON="python" - # command to launch pip (its different on macOs, there we need pip3) - - cPIP="python -m pip" - # switch off wine fix me messages - - WINEDEBUG=fixme-all - - # PYTEST - - PYTEST_DO_TESTS="True" - - # FLAKE8 tests - - DO_FLAKE8_TESTS="True" - - # MYPY tests - - MYPY_DO_TESTS="True" - - MYPY_OPTIONS="--follow-imports=normal --implicit-reexport --no-warn-unused-ignores --strict" - - MYPYPATH="./lib_platform/3rd_party_stubs" - - # coverage - - DO_COVERAGE="True" - - DO_COVERAGE_UPLOAD_CODECOV="True" - - DO_COVERAGE_UPLOAD_CODE_CLIMATE="True" - - # package name - - PACKAGE_NAME="lib_platform" - # the registered CLI Command - - CLI_COMMAND="lib_platform" - # the source file for rst_include (rebuild rst file includes) - - RST_INCLUDE_SOURCE="./.docs/README_template.rst" - # the target file for rst_include (rebuild rst file includes) - - RST_INCLUDE_TARGET="./README.rst" - - # secure environment variable - - secure: "IDAldo6HWLAFHnQg4SRyMO4og923nEjeQ/jeOeFUhvgb8/p8Sq01NZR+CH6EC/YRucTjbuBwociJXgQ88hkYprczbWGiijU0MgV/iiRPHd0/f8ZLOTXsOKK81pKV1wcrZMOsqRwwXCjRZHRr2dwK7kJKlV/5p/ESFI9ZscMZrOllS/vEwoPkyWo8rkMjV/oVvC9N8LENvCDjVseODYBXKMpN9TmrICIghiqnndNU0zdOUmNUqquQajxWRiCfowktkmPBkZpJvCDRm6TEgckVHdnczZE4Hzm8SIqEnQK/FAvy+9N65dbH7yiKufTBBdsQrwtwH1+CAAlIbeWnGtezOSON9zRkJYAjeeE1/ax28coh0NiIg0hNCzSawEjp0mVJnvwYDpW06szvBURaOYtCz9FZ8//Ql5xIKCM9IxX3FMiwhoEKHsmbkYEc5KmljkBBNaKOoxI8rFN26XvqoI9y2aRR7I/fFWxfFiIgVsRo1CL1qFhl+R0dnHbNK0abcGLQ6mRmvqXvQb3tW67So13NBueLfBibARR6uE7lh27JG0rLa92Xez2TPBr0mUOS4QDyrNNXv94LHUzO6rrSO3ZCXqXadqX340EcB9J8TG7a6jLp6R03uLCeGCda7ZWpF/9jbD4iAsDExCb+twwfaN0FCKxYn0VTDFLcJRHv2l4wIGM=" # CC_TEST_REPORTER_ID.secret - - secure: "wK8WmNhbVEkbI8V3vSGKFtme/75tL/DItotP66lUleD0sgQyNs3EM+USZPtkFkpJYnIyaX+qfH1zMR+nwLcOmbWHFAcyRBJXmDDDU3E3+UGEJ8DcLEktYOvnY5fGPdbjN5OMDbNdDYwwkC1Ggq/Cqbt1IwYNBCiuzxVtKIPo7oPFShg1mzkvmRTWD4MGygOUYlNTx9/x8OrnXrbj15tGRbrgjF3QE1HC87E464DUN77RZkNmV4ObW/sjo0LqubYeo5Je32oYk7Ys1akFQnPNxYgk+sFA2EvlvLdqDwK/GrV8KTB2OmhA0pgEFR505pCvHiPIA6WbShj2fffqNXUfFHHULo/sgHxI59Fk+lM5jjBQ+OiQuS41BoNhs02pLeuHsNBwRcqFu9MTrDKOtyIuMfbjG4MUTf6x6yleDRkGIkxZLQ0X6QDLOikEb0bVVxZ/xC3lrNfpgz6kRlXfopsBZK1AVrA3HnvhAeI+WjgsYxnHnLLuFddmKn6JpUaYn6GsS+k8gml0t82hi5d77dzVjycgdihk0nEwxbXLpSNuOSEIQu+TXnQZwpV8GOsnpHNYdvfAZIyQ7NZNQqO3O1hrA3qy3bbK87ZgwtkOg4/iZdVjBzEDHF6x2Hw/275WY/b9E3VL1yW+p5w1txG3tPb+wy7kVHmuW3SdmbP12y+a8aE=" # PYPI_PASSWORD.secret - - - -addons: - apt: - packages: - - xvfb # install xvfb virtual framebuffer - this we need for WINE - - winbind # needed for WINE - -services: # start services - - xvfb # is needed for WINE on headless installation - -matrix: - include: - - - os: windows - if: true - language: sh - name: "Windows Python 3.9" - - # oddly a secure password under env: global: causes that choco fails - # so we need to put the option : filter_secrets: false - # this can be a security issue, check that You dont leak secrets here ! - filter_secrets: false - before_install: - - git clone https://github.com/bitranox/lib_bash.git /usr/local/lib_bash - - chmod -R 0755 /usr/local/lib_bash - - chmod -R +x /usr/local/lib_bash/*.sh - - /usr/local/lib_bash/lib_retry.sh retry choco install python3 - - export PATH="/c/Python310:/c/Python310/Scripts:/c/Python39:/c/Python39/Scripts:/c/Python38:/c/Python38/Scripts:$PATH" - - export BUILD_DOCS="False" - - export DEPLOY_SDIST="False" - - export DEPLOY_WHEEL="False" - - export DEPLOY_TEST="False" - - export MYPY_DO_TESTS="True" - - - - os: linux - arch: "amd64" - if: true - language: python - python: "3.6" - before_install: - - export BUILD_DOCS="False" - - export DEPLOY_SDIST="True" - - export DEPLOY_WHEEL="True" - - export BUILD_TEST="True" - - export MYPY_DO_TESTS="True" - - - os: linux - arch: "amd64" - if: true - language: python - python: "3.7" - before_install: - - export BUILD_DOCS="False" - - export DEPLOY_SDIST="True" - - export DEPLOY_WHEEL="False" - - export BUILD_TEST="True" - - export MYPY_DO_TESTS="True" - - - os: linux - arch: "amd64" - if: true - language: python - python: "3.8" - before_install: - - export BUILD_DOCS="True" - - export DEPLOY_SDIST="True" - - export DEPLOY_WHEEL="True" - - export BUILD_TEST="True" - - export MYPY_DO_TESTS="True" - - - os: linux - arch: "amd64" - if: true - language: python - python: "3.9-dev" - before_install: - - export BUILD_DOCS="False" - - export DEPLOY_SDIST="True" - - export DEPLOY_WHEEL="True" - - export BUILD_TEST="True" - - export MYPY_DO_TESTS="True" - - - os: linux - arch: "amd64" - if: true - language: python - python: "pypy3" - before_install: - - export BUILD_DOCS="False" - - export DEPLOY_SDIST="True" - - export DEPLOY_WHEEL="True" - - export BUILD_TEST="True" - - export MYPY_DO_TESTS="False" - - - os: linux - arch: "ppc64le" - if: tag IS present - language: python - python: "3.8" - before_install: - - export BUILD_DOCS="False" - - export DEPLOY_SDIST="True" - - export DEPLOY_WHEEL="True" - - export BUILD_TEST="True" - - export MYPY_DO_TESTS="True" - - - os: linux - arch: "s390x" - if: tag IS present - language: python - python: "3.8" - before_install: - - export BUILD_DOCS="False" - - export DEPLOY_SDIST="True" - - export DEPLOY_WHEEL="True" - - export BUILD_TEST="True" - - export MYPY_DO_TESTS="True" - - - os: linux - arch: "arm64" - if: tag IS present - language: python - python: "3.8" - before_install: - - export BUILD_DOCS="False" - - export DEPLOY_SDIST="True" - - export DEPLOY_WHEEL="True" - - export BUILD_TEST="True" - - export MYPY_DO_TESTS="True" - - - os: osx - if: true - language: sh - name: "macOS 10.15.4" - python: "3.8" - osx_image: xcode11.5 - env: - # on osx pip and python points to python 2.7 - therefore we have to use pip3 and python3 here - - cPREFIX="" # prefix before commands - used for wine, there the prefix is "wine" - - cPYTHON="python3" # command to launch python interpreter (its different on macOs, there we need python3) - - cPIP="python3 -m pip" # command to launch pip (its different on macOs, there we need pip3) - - export BUILD_DOCS="False" - - export DEPLOY_SDIST="False" - - export DEPLOY_WHEEL="False" - - export DEPLOY_TEST="True" - - export MYPY_DO_TESTS="True" - - -install: - - ${cPIP} install lib_travis - - log_util --colortest - - lib_travis install - -script: - - BRANCH=$(lib_travis get_branch) - - log_util --level=NOTICE --banner "working on branch ${BRANCH}" - - lib_travis script - -after_success: - - lib_travis after_success - - lib_travis deploy - - ls -l ./dist - -notifications: - email: - recipients: - - bitranox@gmail.com - # on_success default: change - on_success: never - on_failure: always diff --git a/CHANGES.rst b/CHANGES.rst index a90ef22..cf9fb24 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -5,6 +5,26 @@ Changelog - new MINOR version for added functionality in a backwards compatible manner - new PATCH version for backwards compatible bug fixes +v1.2.9 +-------- +2023-07-21: + - require minimum python 3.8 + - remove python 3.7 tests + - introduce PEP517 packaging standard + - introduce pyproject.toml build-system + - remove mypy.ini + - remove pytest.ini + - remove setup.cfg + - remove setup.py + - remove .bettercodehub.yml + - remove .travis.yml + - update black config + - clean ./tests/test_cli.py + - add codeql badge + - move 3rd_party_stubs outside the src directory to ``./.3rd_party_stubs`` + - add pypy 3.10 tests + - add python 3.12-dev tests + v1.2.8 -------- 2022-11-09: diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md index 7fb9e5a..487af65 100644 --- a/CODE_OF_CONDUCT.md +++ b/CODE_OF_CONDUCT.md @@ -2,73 +2,67 @@ ## Our Pledge -In the interest of fostering an open and welcoming environment, we as -contributors and maintainers pledge to making participation in our project and -our community a harassment-free experience for everyone, regardless of age, body -size, disability, ethnicity, sex characteristics, gender identity and expression, -level of experience, education, socio-economic status, nationality, personal -appearance, race, religion, or sexual identity and orientation. +We as members, contributors, and leaders pledge to make participation +in our community a harassment-free experience for everyone, regardless +of age, body size, visible or invisible disability, ethnicity, +sex characteristics, gender identity and expression, level of experience, +education, socio-economic status, nationality, personal appearance, +race, caste, color, religion, or sexual identity and orientation. + +We pledge to act and interact in ways that contribute to an open, +welcoming, diverse, inclusive, and healthy community. ## Our Standards -Examples of behavior that contributes to creating a positive environment -include: +Examples of behavior that contributes to a positive environment for our community include: + +* Demonstrating empathy and kindness toward other people +* Being respectful of differing opinions, viewpoints, and experiences +* Giving and gracefully accepting constructive feedback +* Accepting responsibility and apologizing to those affected by our mistakes, + and learning from the experience +* Focusing on what is best not just for us as individuals, but for the overall community -* Using welcoming and inclusive language -* Being respectful of differing viewpoints and experiences -* Gracefully accepting constructive criticism -* Focusing on what is best for the community -* Showing empathy towards other community members -Examples of unacceptable behavior by participants include: +Examples of unacceptable behavior include: -* The use of sexualized language or imagery and unwelcome sexual attention or - advances -* Trolling, insulting/derogatory comments, and personal or political attacks +* The use of sexualized language or imagery, and sexual attention or advances of any kind +* Trolling, insulting or derogatory comments, and personal or political attacks * Public or private harassment -* Publishing others' private information, such as a physical or electronic - address, without explicit permission -* Other conduct which could reasonably be considered inappropriate in a - professional setting +* Publishing others’ private information, such as a physical or email address, + without their explicit permission +* Other conduct which could reasonably be considered inappropriate in a professional setting -## Our Responsibilities +## Enforcement Responsibilities -Project maintainers are responsible for clarifying the standards of acceptable -behavior and are expected to take appropriate and fair corrective action in -response to any instances of unacceptable behavior. +Community leaders are responsible for clarifying and enforcing our standards of +acceptable behavior and will take appropriate and fair corrective action in response +to any behavior that they deem inappropriate, threatening, offensive, or harmful. -Project maintainers have the right and responsibility to remove, edit, or -reject comments, commits, code, wiki edits, issues, and other contributions -that are not aligned to this Code of Conduct, or to ban temporarily or -permanently any contributor for other behaviors that they deem inappropriate, -threatening, offensive, or harmful. +Community leaders have the right and responsibility to remove, edit, or reject comments, +commits, code, wiki edits, issues, and other contributions that are not aligned +to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate. ## Scope -This Code of Conduct applies both within project spaces and in public spaces -when an individual is representing the project or its community. Examples of -representing a project or community include using an official project e-mail -address, posting via an official social media account, or acting as an appointed -representative at an online or offline event. Representation of a project may be -further defined and clarified by project maintainers. +This Code of Conduct applies within all community spaces, +and also applies when an individual is officially representing the community in public spaces. +Examples of representing our community include using an official e-mail address, +posting via an official social media account, +or acting as an appointed representative at an online or offline event. ## Enforcement -Instances of abusive, harassing, or otherwise unacceptable behavior may be -reported by contacting the project team at bitranox@gmail.com. All -complaints will be reviewed and investigated and will result in a response that -is deemed necessary and appropriate to the circumstances. The project team is -obligated to maintain confidentiality with regard to the reporter of an incident. -Further details of specific enforcement policies may be posted separately. +Instances of abusive, harassing, or otherwise unacceptable behavior may be reported +to the community leaders responsible for enforcement at bitranox@gmail.com . All complaints will be reviewed and investigated promptly and fairly. -Project maintainers who do not follow or enforce the Code of Conduct in good -faith may face temporary or permanent repercussions as determined by other -members of the project's leadership. +All community leaders are obligated to respect the privacy and security +of the reporter of any incident. ## Attribution -This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, -available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html +This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.1, +available at https://www.contributor-covenant.org/version/2/1/code_of_conduct/ [homepage]: https://www.contributor-covenant.org diff --git a/LICENSE b/LICENSE index 62cafd4..b4540a5 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 1990-2020 Robert Nowotny +Copyright (c) 1990-2023 Robert Nowotny Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/Makefile b/Makefile index 04c6df2..a8561d7 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,5 @@ ## create virtual environment +## see: https://earthly.dev/blog/python-makefile/ venv: echo "ToDo - MakeFile is still in Development, contact bitranox@gmail.com if You need it" ## virtualenv venv @@ -27,3 +28,4 @@ uninstall: ## ideas - create make targets for "normal" installation and virtual environments, ## and to be able to pass the virtual environment directory alternatively ## not a priority now, since there are many other ways to install this package +## see: https://earthly.dev/blog/python-makefile/ diff --git a/README.rst b/README.rst index b9be23d..4778aaf 100644 --- a/README.rst +++ b/README.rst @@ -2,21 +2,25 @@ lib_platform ============ -Version v1.2.7 as of 2020-10-09 see `Changelog`_ +Version v1.2.9 as of 2023-07-21 see `Changelog`_ -|travis_build| |license| |jupyter| |pypi| +|build_badge| |codeql| |license| |jupyter| |pypi| +|pypi-downloads| |black| |codecov| |cc_maintain| |cc_issues| |cc_coverage| |snyk| -|codecov| |better_code| |cc_maintain| |cc_issues| |cc_coverage| |snyk| -.. |travis_build| image:: https://img.shields.io/travis/bitranox/lib_platform/master.svg - :target: https://travis-ci.org/bitranox/lib_platform +.. |build_badge| image:: https://github.com/bitranox/lib_platform/actions/workflows/python-package.yml/badge.svg + :target: https://github.com/bitranox/lib_platform/actions/workflows/python-package.yml + + +.. |codeql| image:: https://github.com/bitranox/lib_platform/actions/workflows/codeql-analysis.yml/badge.svg?event=push + :target: https://github.com//bitranox/lib_platform/actions/workflows/codeql-analysis.yml .. |license| image:: https://img.shields.io/github/license/webcomics/pywine.svg :target: http://en.wikipedia.org/wiki/MIT_License .. |jupyter| image:: https://mybinder.org/badge_logo.svg - :target: https://mybinder.org/v2/gh/bitranox/lib_platform/master?filepath=lib_platform.ipynb + :target: https://mybinder.org/v2/gh/bitranox/lib_platform/master?filepath=lib_platform.ipynb .. for the pypi status link note the dashes, not the underscore ! .. |pypi| image:: https://img.shields.io/pypi/status/lib-platform?label=PyPI%20Package @@ -25,9 +29,6 @@ Version v1.2.7 as of 2020-10-09 see `Changelog`_ .. |codecov| image:: https://img.shields.io/codecov/c/github/bitranox/lib_platform :target: https://codecov.io/gh/bitranox/lib_platform -.. |better_code| image:: https://bettercodehub.com/edge/badge/bitranox/lib_platform?branch=master - :target: https://bettercodehub.com/results/bitranox/lib_platform - .. |cc_maintain| image:: https://img.shields.io/codeclimate/maintainability-percentage/bitranox/lib_platform?label=CC%20maintainability :target: https://codeclimate.com/github/bitranox/lib_platform/maintainability :alt: Maintainability @@ -40,24 +41,28 @@ Version v1.2.7 as of 2020-10-09 see `Changelog`_ :target: https://codeclimate.com/github/bitranox/lib_platform/test_coverage :alt: Code Coverage -.. |snyk| image:: https://img.shields.io/snyk/vulnerabilities/github/bitranox/lib_platform +.. |snyk| image:: https://snyk.io/test/github/bitranox/lib_platform/badge.svg :target: https://snyk.io/test/github/bitranox/lib_platform .. |black| image:: https://img.shields.io/badge/code%20style-black-000000.svg :target: https://github.com/psf/black +.. |pypi-downloads| image:: https://img.shields.io/pypi/dm/lib-platform + :target: https://pypi.org/project/lib-platform/ + :alt: PyPI - Downloads + some platform related functions, which also work correctly on wine ---- -automated tests, Travis Matrix, Documentation, Badges, etc. are managed with `PizzaCutter `_ (cookiecutter on steroids) -Python version required: 3.6.0 or newer +Python version required: 3.8.0 or newer -tested on linux "bionic" with python 3.6, 3.7, 3.8, 3.9-dev, pypy3 - architectures: amd64, ppc64le, s390x, arm64 +tested on recent linux with python 3.8, 3.9, 3.10, 3.11, 3.12-dev, pypy-3.9, pypy-3.10 - architectures: amd64 -`100% code coverage `_, flake8 style checking ,mypy static type checking ,tested under `Linux, macOS, Windows `_, automatic daily builds and monitoring +`100% code coverage `_, flake8 style checking ,mypy static type checking ,tested under `Linux, macOS, Windows `_, automatic daily builds and monitoring ---- @@ -133,7 +138,7 @@ Usage Usage from Commandline ------------------------ -.. code-block:: bash +.. code-block:: Usage: lib_platform [OPTIONS] COMMAND [ARGS]... @@ -153,28 +158,35 @@ Installation and Upgrade - Before You start, its highly recommended to update pip and setup tools: -.. code-block:: bash +.. code-block:: python -m pip --upgrade pip python -m pip --upgrade setuptools - to install the latest release from PyPi via pip (recommended): -.. code-block:: bash +.. code-block:: python -m pip install --upgrade lib_platform + +- to install the latest release from PyPi via pip, including test dependencies: + +.. code-block:: + + python -m pip install --upgrade lib_platform[test] + - to install the latest version from github via pip: -.. code-block:: bash +.. code-block:: python -m pip install --upgrade git+https://github.com/bitranox/lib_platform.git - include it into Your requirements.txt: -.. code-block:: bash +.. code-block:: # Insert following line in Your requirements.txt: # for the latest Release on pypi: @@ -187,14 +199,14 @@ Installation and Upgrade python -m pip install --upgrade -r //requirements.txt -- to install the latest development version from source code: +- to install the latest development version, including test dependencies from source code: -.. code-block:: bash +.. code-block:: # cd ~ $ git clone https://github.com/bitranox/lib_platform.git $ cd lib_platform - python setup.py install + python -m pip install -e .[test] - via makefile: makefiles are a very convenient way to install. Here we can do much more, @@ -226,8 +238,8 @@ following modules will be automatically installed : ## Project Requirements click - cli_exit_tools @ git+https://github.com/bitranox/cli_exit_tools.git - lib_registry @ git+https://github.com/bitranox/lib_registry.git + cli_exit_tools + lib_registry Acknowledgements ---------------- @@ -254,6 +266,31 @@ Changelog - new MINOR version for added functionality in a backwards compatible manner - new PATCH version for backwards compatible bug fixes +v1.2.9 +-------- +2023-07-21: + - require minimum python 3.8 + - remove python 3.7 tests + - introduce PEP517 packaging standard + - introduce pyproject.toml build-system + - remove mypy.ini + - remove pytest.ini + - remove setup.cfg + - remove setup.py + - remove .bettercodehub.yml + - remove .travis.yml + - update black config + - clean ./tests/test_cli.py + - add codeql badge + - move 3rd_party_stubs outside the src directory to ``./.3rd_party_stubs`` + - add pypy 3.10 tests + - add python 3.12-dev tests + +v1.2.8 +-------- +2022-11-09: + - fix get hostname, if something is tinkering with the loopback interface on Windows - for instance 'Solid Works 3DExperience' + v1.2.7 -------- 2020-10-09: service release diff --git a/conftest.py b/conftest.py index 497a2cf..ce93a86 100644 --- a/conftest.py +++ b/conftest.py @@ -1,19 +1,10 @@ +import pytest from typing import List collect_ignore: List[str] = [] -def pytest_cmdline_preparse(args: List[str]) -> None: - """ - # run tests on multiple processes if pytest-xdist plugin is available - # unfortunately it does not work with codecov - import sys - if "xdist" in sys.modules: # pytest-xdist plugin - import multiprocessing - - num = int(max(multiprocessing.cpu_count() / 2, 1)) - args[:] = ["-n", str(num)] + args - """ - +def pytest_load_initial_conftests(early_config: pytest.Config, parser: pytest.Parser, args: List[str]) -> None: + # PizzaCutter Template can add here additional pytest args additional_pytest_args: List[str] = [] args[:] = list(set(args + additional_pytest_args)) diff --git a/lib_platform.ipynb b/lib_platform.ipynb index 1551faa..91c70be 100644 --- a/lib_platform.ipynb +++ b/lib_platform.ipynb @@ -1 +1 @@ -{"metadata":{"language_info":{"name":"python","version":"3.7.6","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"},"kernelspec":{"name":"python3","display_name":"Python 3","language":"python"}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"code","source":"# update pip and setuptools\nimport sys\n!{sys.executable} -m pip install --upgrade pip\n!{sys.executable} -m pip install --upgrade setuptools","metadata":{"trusted":true},"execution_count":2,"outputs":[{"name":"stdout","text":"/bin/sh: 1: sys.executable: not found\n/bin/sh: 1: sys.executable: not found\n","output_type":"stream"}]},{"cell_type":"code","source":"# install lib_platform\n!{sys.executable} -m pip install lib_platform","metadata":{"trusted":true},"execution_count":4,"outputs":[{"name":"stdout","text":"Collecting lib_platform\n Downloading lib_platform-1.0.3-py3-none-any.whl (5.9 kB)\nCollecting pytest\n Downloading pytest-5.4.3-py3-none-any.whl (248 kB)\n\u001b[K |β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 248 kB 3.0 MB/s eta 0:00:01\n\u001b[?25hCollecting typing\n Downloading typing-3.7.4.1-py3-none-any.whl (25 kB)\nCollecting lib-registry\n Downloading lib_registry-1.0.2.tar.gz (6.3 kB)\nRequirement already satisfied: attrs>=17.4.0 in /srv/conda/envs/notebook/lib/python3.7/site-packages (from pytest->lib_platform) (19.3.0)\nRequirement already satisfied: wcwidth in /srv/conda/envs/notebook/lib/python3.7/site-packages (from pytest->lib_platform) (0.2.3)\nCollecting py>=1.5.0\n Downloading py-1.9.0-py2.py3-none-any.whl (99 kB)\n\u001b[K |β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 99 kB 6.4 MB/s eta 0:00:01\n\u001b[?25hRequirement already satisfied: importlib-metadata>=0.12; python_version < \"3.8\" in /srv/conda/envs/notebook/lib/python3.7/site-packages (from pytest->lib_platform) (1.6.0)\nCollecting more-itertools>=4.0.0\n Downloading more_itertools-8.4.0-py3-none-any.whl (43 kB)\n\u001b[K |β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 43 kB 1.8 MB/s eta 0:00:011\n\u001b[?25hCollecting pluggy<1.0,>=0.12\n Downloading pluggy-0.13.1-py2.py3-none-any.whl (18 kB)\nRequirement already satisfied: packaging in /srv/conda/envs/notebook/lib/python3.7/site-packages (from pytest->lib_platform) (20.4)\nRequirement already satisfied: zipp>=0.5 in /srv/conda/envs/notebook/lib/python3.7/site-packages (from importlib-metadata>=0.12; python_version < \"3.8\"->pytest->lib_platform) (3.1.0)\nRequirement already satisfied: pyparsing>=2.0.2 in /srv/conda/envs/notebook/lib/python3.7/site-packages (from packaging->pytest->lib_platform) (2.4.7)\nRequirement already satisfied: six in /srv/conda/envs/notebook/lib/python3.7/site-packages (from packaging->pytest->lib_platform) (1.15.0)\nBuilding wheels for collected packages: lib-registry\n Building wheel for lib-registry (setup.py) ... \u001b[?25ldone\n\u001b[?25h Created wheel for lib-registry: filename=lib_registry-1.0.2-py3-none-any.whl size=6278 sha256=4c742611375c7f057a81255ce8493e2cf100e1fde52a87cd99b05c7f22ec5201\n Stored in directory: /home/jovyan/.cache/pip/wheels/53/4d/2a/14531ab44c6f8dab7c55f1108a14d28b4c7e4a4a8024aabfd8\nSuccessfully built lib-registry\nInstalling collected packages: py, more-itertools, pluggy, pytest, typing, lib-registry, lib-platform\nSuccessfully installed lib-platform-1.0.3 lib-registry-1.0.2 more-itertools-8.4.0 pluggy-0.13.1 py-1.9.0 pytest-5.4.3 typing-3.7.4.1\n","output_type":"stream"}]},{"cell_type":"code","source":"import lib_platform","metadata":{"trusted":true},"execution_count":11,"outputs":[]},{"cell_type":"code","source":"# get system as string\nlib_platform.system","metadata":{"trusted":true},"execution_count":12,"outputs":[{"execution_count":12,"output_type":"execute_result","data":{"text/plain":"'linux'"},"metadata":{}}]},{"cell_type":"code","source":"# bool is_platform_linux\nlib_platform.is_platform_linux","metadata":{"trusted":true},"execution_count":13,"outputs":[{"execution_count":13,"output_type":"execute_result","data":{"text/plain":"True"},"metadata":{}}]},{"cell_type":"code","source":"# bool is_platform_darwin\nlib_platform.is_platform_darwin","metadata":{"trusted":true},"execution_count":14,"outputs":[{"execution_count":14,"output_type":"execute_result","data":{"text/plain":"False"},"metadata":{}}]},{"cell_type":"code","source":"# bool is_platform_posix\n# either darwin or linux\nlib_platform.is_platform_posix","metadata":{"trusted":true},"execution_count":15,"outputs":[{"execution_count":15,"output_type":"execute_result","data":{"text/plain":"True"},"metadata":{}}]},{"cell_type":"code","source":"# bool is_platform_windows\n# also True for windows_xp or windows_wine\nlib_platform.is_platform_windows","metadata":{"trusted":true},"execution_count":16,"outputs":[{"execution_count":16,"output_type":"execute_result","data":{"text/plain":"False"},"metadata":{}}]},{"cell_type":"code","source":"# bool is_platform_windows_xp\nlib_platform.is_platform_windows_xp","metadata":{"trusted":true},"execution_count":17,"outputs":[{"execution_count":17,"output_type":"execute_result","data":{"text/plain":"False"},"metadata":{}}]},{"cell_type":"code","source":"# bool is_platform_windows_wine\nlib_platform.is_platform_windows_wine","metadata":{"trusted":true},"execution_count":18,"outputs":[{"execution_count":18,"output_type":"execute_result","data":{"text/plain":"False"},"metadata":{}}]},{"cell_type":"code","source":"# bool is_platform_windows_wine_xp\nlib_platform.is_platform_windows_wine_xp","metadata":{"trusted":true},"execution_count":19,"outputs":[{"execution_count":19,"output_type":"execute_result","data":{"text/plain":"False"},"metadata":{}}]},{"cell_type":"code","source":"# string username lib_platform.username\nlib_platform.username\n","metadata":{"trusted":true},"execution_count":20,"outputs":[{"execution_count":20,"output_type":"execute_result","data":{"text/plain":"'jovyan'"},"metadata":{}}]},{"cell_type":"code","source":"# string fqdn hostname\nlib_platform.hostname","metadata":{"trusted":true},"execution_count":21,"outputs":[{"execution_count":21,"output_type":"execute_result","data":{"text/plain":"'jupyter-jupyterlab-2djupyterlab-2ddemo-2d87x99clo'"},"metadata":{}}]},{"cell_type":"code","source":"# string hostname short\nlib_platform.hostname_short","metadata":{"trusted":true},"execution_count":22,"outputs":[{"execution_count":22,"output_type":"execute_result","data":{"text/plain":"'jupyter-jupyterlab-2djupyterlab-2ddemo-2d87x99clo'"},"metadata":{}}]},{"cell_type":"code","source":"# path to userhome\nlib_platform.path_userhome","metadata":{"trusted":true},"execution_count":23,"outputs":[{"execution_count":23,"output_type":"execute_result","data":{"text/plain":"'/home/jovyan'"},"metadata":{}}]},{"cell_type":"code","source":"# is user administrator (has user admin rights)\nlib_platform.is_user_admin","metadata":{"trusted":true},"execution_count":24,"outputs":[{"execution_count":24,"output_type":"execute_result","data":{"text/plain":"False"},"metadata":{}}]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]}]} \ No newline at end of file +{"cells":[{"metadata":{"trusted":true},"cell_type":"code","source":"# update pip and setuptools\nimport sys\n!{sys.executable} -m pip install --upgrade pip\n!{sys.executable} -m pip install --upgrade setuptools","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"# install lib_platform\n!{sys.executable} -m pip install lib_platform","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"import lib_platform","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"# get system as string\nlib_platform.system","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"# bool is_platform_linux\nlib_platform.is_platform_linux","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"# bool is_platform_darwin\nlib_platform.is_platform_darwin","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"# bool is_platform_posix\n# either darwin or linux\nlib_platform.is_platform_posix","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"# bool is_platform_windows\n# also True for windows_xp or windows_wine\nlib_platform.is_platform_windows","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"# bool is_platform_windows_xp\nlib_platform.is_platform_windows_xp","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"# bool is_platform_windows_wine\nlib_platform.is_platform_windows_wine","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"# bool is_platform_windows_wine_xp\nlib_platform.is_platform_windows_wine_xp","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"# string username lib_platform.username\nlib_platform.username\n","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"# string fqdn hostname\nlib_platform.hostname","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"# string hostname short\nlib_platform.hostname_short","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"# path to userhome\nlib_platform.path_userhome","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"# is user administrator (has user admin rights)\nlib_platform.is_user_admin","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"","execution_count":null,"outputs":[]}],"metadata":{"language_info":{"name":"python","version":"3.10.11","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"},"kernelspec":{"name":"python3","display_name":"Python 3 (ipykernel)","language":"python"}},"nbformat":4,"nbformat_minor":4} \ No newline at end of file diff --git a/lib_platform/__init__conf__.py b/lib_platform/__init__conf__.py index 0544205..5c4cb8a 100644 --- a/lib_platform/__init__conf__.py +++ b/lib_platform/__init__conf__.py @@ -1,6 +1,8 @@ +# CONF + name = 'lib_platform' title = 'some platform related functions, which also work correctly on wine' -version = 'v1.2.7' +version = 'v1.2.9' url = 'https://github.com/bitranox/lib_platform' author = 'Robert Nowotny' author_email = 'bitranox@gmail.com' @@ -14,7 +16,7 @@ def print_info() -> None: some platform related functions, which also work correctly on wine - Version : v1.2.7 + Version : v1.2.9 Url : https://github.com/bitranox/lib_platform Author : Robert Nowotny Email : bitranox@gmail.com""") diff --git a/lib_platform/lib_platform_cli.py b/lib_platform/lib_platform_cli.py index 60ee1b3..7233bbd 100644 --- a/lib_platform/lib_platform_cli.py +++ b/lib_platform/lib_platform_cli.py @@ -30,7 +30,7 @@ def info() -> None: __init__conf__.print_info() -@click.group(help=__init__conf__.title, context_settings=CLICK_CONTEXT_SETTINGS) +@click.group(help=__init__conf__.title, context_settings=CLICK_CONTEXT_SETTINGS) # type: ignore @click.version_option(version=__init__conf__.version, prog_name=__init__conf__.shell_command, message=f'{__init__conf__.shell_command} version {__init__conf__.version}') @@ -49,7 +49,7 @@ def cli_info() -> None: # entry point if main if __name__ == '__main__': try: - cli_main() + cli_main() # type: ignore except Exception as exc: cli_exit_tools.print_exception_message() sys.exit(cli_exit_tools.get_system_exit_code(exc)) diff --git a/pyproject.toml b/pyproject.toml index ad4b2d5..cf9c153 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,7 +1,88 @@ +[build-system] +requires = ['setuptools', 'setuptools-scm'] +build-backend = "setuptools.build_meta" + +[project] +# see: https://setuptools.pypa.io/en/latest/userguide/pyproject_config.html +name = "lib_platform" +authors = [ + {name = "Robert Nowotny", email = "bitranox@gmail.com"}, +] +description = "some platform related functions, which also work correctly on wine" +readme = "README.rst" +requires-python = ">=3.8.0" +keywords = [ +] +license = {text = "MIT"} +classifiers = [ + "Development Status :: 5 - Production/Stable", + "Intended Audience :: Developers", + "License :: OSI Approved :: MIT License", + "Natural Language :: English", + "Operating System :: OS Independent", + "Programming Language :: Python", + "Topic :: Software Development :: Libraries :: Python Modules", +] +# dependencies - former setup.cfg "install_requires" +# see: https://setuptools.pypa.io/en/latest/userguide/dependency_management.html +dependencies = [ + "click", + "cli_exit_tools", + "lib_registry", +] +version = "v1.2.9" +# seems to be not allowed anymore +# zip-save = false + +[project.urls] +Homepage = "https://github.com/bitranox/lib_platform" +Documentation = "https://github.com/bitranox/lib_platform/blob/master/README.rst" +Repository = "https://github.com/bitranox/lib_platform.git" +Changelog = "https://github.com/bitranox/lib_platform/blob/master/CHANGES.rst" + +[project.optional-dependencies] +test = [ + "black", + "codecov", + "coloredlogs", + "coverage", + "dill", + "flake8", + "mypy", + "pytest", + "pytest-cov", + "pytest-runner", + "readme_renderer", +] + +[project.scripts] + lib_platform = "lib_platform.lib_platform_cli:cli_main" + +[tool.setuptools.package-data] +lib_platform = [ + "py.typed", + "*.pyi", + "__init__.pyi", +] [tool.black] -line-length = 88 -target-version = ['py36'] +line-length = 160 +#You should include all Python versions that you want your code to run under +target-version = ['py37', 'py38', 'py39', 'py310', 'py311'] # Note that you have to use single-quoted strings in TOML for regular expressions include = '\.pyi?$' exclude = '/(\.eggs|\.git|\.hg|\.mypy_cache|\.nox|\.tox|\.venv|_build|buck-out|build|dist)/' + +[tool.mypy] +verbosity=0 +warn_unused_configs = true +ignore_missing_imports = true +no_implicit_optional = true +no_strict_optional = true +show_error_context = true + +[tool.pytest.ini_options] +addopts = "-vvl --doctest-modules" +doctest_optionflags = "NORMALIZE_WHITESPACE ELLIPSIS ALLOW_UNICODE ALLOW_BYTES IGNORE_EXCEPTION_DETAIL" +log_cli = true +log_cli_level = "CRITICAL" diff --git a/requirements.txt b/requirements.txt index 172c860..66fa92a 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ ## Project Requirements click -cli_exit_tools @ git+https://github.com/bitranox/cli_exit_tools.git -lib_registry @ git+https://github.com/bitranox/lib_registry.git +cli_exit_tools +lib_registry diff --git a/requirements_test.txt b/requirements_test.txt index b793f92..c299019 100644 --- a/requirements_test.txt +++ b/requirements_test.txt @@ -1,13 +1,14 @@ ## Test Requirements ## following Requirements will be installed temporarily for ## "setup.py install test" or "pip install --install-option test" -black ; platform_python_implementation != "PyPy" -black==19.3b0 ; platform_python_implementation == "PyPy" +black codecov coloredlogs coverage dill flake8 -mypy ; platform_python_implementation != "PyPy" +mypy pytest pytest-cov +pytest-runner +readme_renderer diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index fdec284..0000000 --- a/setup.cfg +++ /dev/null @@ -1,19 +0,0 @@ -[flake8] -max_line_length = 160 -ignore = E123, E203, E402, F401, F403, F405, W503 -exclude = .git, __pycache__, build, dist, .eggs, .hg, .mypy_cache, .nox, .tox, .venv, _build, buck-out -max-complexity = 20 - -[mypy] -verbosity=0 -warn_unused_configs = True -ignore_missing_imports = True -no_implicit_optional = True -no_strict_optional = True -show_error_context = True - -[tool:pytest] -addopts = -vvl --doctest-modules -doctest_optionflags = NORMALIZE_WHITESPACE ELLIPSIS ALLOW_UNICODE ALLOW_BYTES IGNORE_EXCEPTION_DETAIL -log_cli = True -log_cli_level = CRITICAL diff --git a/setup.py b/setup.py deleted file mode 100644 index d64f782..0000000 --- a/setup.py +++ /dev/null @@ -1,124 +0,0 @@ -#!/usr/bin/env python3 - -import codecs -import os -import pathlib -from typing import Any, List, Dict - -from setuptools import setup # type: ignore -from setuptools import find_packages - - -def is_travis_deploy() -> bool: - if os.getenv("DEPLOY_SDIST", "") or os.getenv("DEPLOY_WHEEL", ""): - return is_tagged_commit() - else: - return False - - -def is_tagged_commit() -> bool: - if "TRAVIS_TAG" in os.environ: - if os.environ["TRAVIS_TAG"]: - return True - return False - - -def strip_links_from_required(l_required: List[str]) -> List[str]: - """ - >>> required = ['lib_regexp @ git+https://github.com/bitranox/lib_regexp.git', 'test'] - >>> assert strip_links_from_required(required) == ['lib_regexp', 'test'] - - """ - l_req_stripped: List[str] = list() - for req in l_required: - req_stripped = req.split("@")[0].strip() - l_req_stripped.append(req_stripped) - return l_req_stripped - - -# will be overwritten with long_description if exists ! -long_description = "some platform related functions, which also work correctly on wine" -path_readme = pathlib.Path(__file__).parent / "README.rst" - -if path_readme.exists(): - # noinspection PyBroadException - try: - readme_content = codecs.open(str(path_readme), encoding="utf-8").read() - long_description = readme_content - except Exception: - pass - - -def get_requirements_from_file(requirements_filename: str) -> List[str]: - """ - >>> assert len(get_requirements_from_file('requirements.txt')) > 0 - """ - l_requirements = list() - try: - with open( - str(pathlib.Path(__file__).parent / requirements_filename), mode="r" - ) as requirements_file: - for line in requirements_file: - line_data = get_line_data(line) - if line_data: - l_requirements.append(line_data) - except FileNotFoundError: - pass - return l_requirements - - -def get_line_data(line: str) -> str: - line = line.strip() - if "#" in line: - line = line.split("#", 1)[0].strip() - return line - - -tests_require = get_requirements_from_file("requirements_test.txt") -install_requires = get_requirements_from_file("requirements.txt") -setup_requires = list(set(tests_require + install_requires)) - -# for deploy on pypi we must not rely on imports from github -if is_travis_deploy() and is_tagged_commit(): - setup_requires = strip_links_from_required(setup_requires) - tests_require = strip_links_from_required(tests_require) - install_requires = strip_links_from_required(install_requires) - -setup_kwargs: Dict[str, Any] = dict() -setup_kwargs["name"] = "lib_platform" -setup_kwargs["version"] = "v1.2.7" -setup_kwargs["url"] = "https://github.com/bitranox/lib_platform" -setup_kwargs["packages"] = find_packages() -setup_kwargs["package_data"] = {"lib_platform": ["py.typed", "*.pyi", "__init__.pyi"]} -setup_kwargs[ - "description" -] = "some platform related functions, which also work correctly on wine" -setup_kwargs["long_description"] = long_description -setup_kwargs["long_description_content_type"] = "text/x-rst" -setup_kwargs["author"] = "Robert Nowotny" -setup_kwargs["author_email"] = "bitranox@gmail.com" -setup_kwargs["classifiers"] = [ - "Development Status :: 5 - Production/Stable", - "Intended Audience :: Developers", - "License :: OSI Approved :: MIT License", - "Natural Language :: English", - "Operating System :: OS Independent", - "Programming Language :: Python", - "Topic :: Software Development :: Libraries :: Python Modules", -] -setup_kwargs["entry_points"] = { - "console_scripts": ["lib_platform = lib_platform.lib_platform_cli:cli_main"] -} -# minimally needs to run tests - no project requirements here -setup_kwargs["tests_require"] = tests_require -# specify what a project minimally needs to run correctly -setup_kwargs["install_requires"] = install_requires -# minimally needs to run the setup script, dependencies needs also to put here for "setup.py install test" -# dependencies must not be put here for pip install -setup_kwargs["setup_requires"] = setup_requires -setup_kwargs["python_requires"] = ">=3.6.0" -setup_kwargs["zip_safe"] = False - - -if __name__ == "__main__": - setup(**setup_kwargs) diff --git a/tests/local_testscripts/lib_bash_functions.sh b/tests/local_testscripts/lib_bash_functions.sh index f7d45d6..7b73dd9 100644 --- a/tests/local_testscripts/lib_bash_functions.sh +++ b/tests/local_testscripts/lib_bash_functions.sh @@ -22,6 +22,7 @@ export PYTHONPATH="$(python3 ./testing_tools.py append_directory_to_python_path # following lines are not only a comment, they get actually replaced export PYTHONPATH="$(python3 ./testing_tools.py append_directory_to_python_path "/media/srv-main-softdev/rotek-apps/lib")" export MYPYPATH="$(python3 ./testing_tools.py append_immediate_subdirs_to_mypy_path "/media/srv-main-softdev/rotek-apps/lib/bitranox")" +export MYPYPATH="$(python3 ./testing_tools.py append_immediate_subdirs_to_mypy_path "/media/srv-main-softdev/rotek-apps/lib/libs_local")" cd "$save_dir"||exit function install_or_update_lib_bash() { @@ -62,6 +63,7 @@ function clean_caches() { } function install_virtualenv_debian() { + # installs the debian python3-virtualenv package if ! is_package_installed python3-virtualenv; then banner "python3-virtualenv is not installed, I will install it for You" wait_for_enter @@ -74,15 +76,16 @@ function install_test_requirements() { clr_green "installing/updating pip, setuptools, wheel" sudo chmod -R 0777 ~/.eggs # make already installed eggs accessible, just in case they were installed as root - python3 -m pip install --upgrade pip - python3 -m pip install --upgrade setuptools - python3 -m pip install --upgrade wheel + /opt/python3/bin/python3 -m pip install --upgrade pip + /opt/python3/bin/python3 -m pip install --upgrade setuptools + /opt/python3/bin/python3 -m pip install --upgrade wheel # this we need for local testscripts - python3 -m pip install --upgrade click + /opt/python3/bin/python3 -m pip install --upgrade click + /opt/python3/bin/python3 -m pip install --upgrade black if test -f "${project_root_dir}/requirements_test.txt"; then clr_green "installing/updating test requirements from \"requirements_test.txt\"" - python3 -m pip install --upgrade -r "${project_root_dir}/requirements_test.txt" + /opt/python3/bin/python3 -m pip install --upgrade -r "${project_root_dir}/requirements_test.txt" else clr_red "requirements_test.txt not found" fi @@ -102,6 +105,8 @@ function install_clean_virtual_environment() { clr_green "installing venv" delete_virtual_environment virtualenv ~/venv + sudo chmod -R 0777 ~/venv + sudo chmod -R 0777 /usr/local/lib/python3.*/dist-packages } @@ -109,6 +114,8 @@ function cleanup() { trap '' 2 # disable Ctrl+C delete_virtual_environment clean_caches + # delete the link to commandline interface + rm -f /usr/local/bin/lib_platform cd "${save_dir}" || exit trap 2 # enable Ctrl+C } @@ -117,7 +124,7 @@ function cleanup() { function run_black() { # run black for *.py files my_banner "running black with settings from ${project_root_dir}/pyproject.toml" - if ! python3 -m black "${project_root_dir}"/**/*.py; then + if ! /opt/python3/bin/python3 -m black "${project_root_dir}"/**/*.py; then my_banner_warning "black ERROR" beep sleep "${sleeptime_on_error}" @@ -129,7 +136,7 @@ function run_black() { function run_flake8_tests() { # run flake8, settings from setup.cfg my_banner "running flake8 with settings from ${project_root_dir}/setup.cfg" - if ! python3 -m flake8 --append-config="${project_root_dir}/setup.cfg" "$@" "${project_root_dir}"; then + if ! /opt/python3/bin/python3 -m flake8 --append-config="${project_root_dir}/setup.cfg" "$@" "${project_root_dir}"; then my_banner_warning "flake8 ERROR" beep sleep "${sleeptime_on_error}" @@ -140,7 +147,7 @@ function run_flake8_tests() { function run_mypy_tests() { my_banner "mypy tests" - if ! python3 -m mypy "${project_root_dir}" --follow-imports=normal --implicit-reexport --no-warn-unused-ignores --strict; then + if ! /opt/python3/bin/python3 -m mypy "${project_root_dir}" --follow-imports=normal --ignore-missing-imports --implicit-reexport --install-types --no-warn-unused-ignores --non-interactive --strict; then my_banner_warning "mypy tests ERROR" beep sleep "${sleeptime_on_error}" @@ -152,7 +159,7 @@ function run_mypy_tests() { function run_pytest() { # run pytest, accepts additional pytest parameters like --disable-warnings and so on my_banner "running pytest with settings from pytest.ini, mypy.ini and conftest.py" - if ! python3 -m pytest "${project_root_dir}" "$@" --cov=lib_platform; then + if ! /opt/python3/bin/python3 -m pytest "${project_root_dir}" "$@" --cov="${project_root_dir}" --cov-config=.coveragerc; then my_banner_warning "pytest ERROR" beep sleep "${sleeptime_on_error}" @@ -161,11 +168,26 @@ function run_pytest() { } -function install_pip_requirements_venv() { +function run_pytest_venv() { + # run pytest, accepts additional pytest parameters like --disable-warnings and so on + my_banner "running pytest with settings from pytest.ini, mypy.ini and conftest.py" + if ! ~/venv/local/bin/python3 -m pytest "${project_root_dir}" "$@" --cov="${project_root_dir}" --cov-config=.coveragerc; then + my_banner_warning "pytest ERROR" + beep + sleep "${sleeptime_on_error}" + return 1 + fi +} + + +# todo wip delete me +function install_pip_requirements_venv_old() { + # install the requirements in the virtual environment if test -f "${project_root_dir}/requirements.txt on virtual environment"; then + my_banner_warning "install_pip_requirements_venv is deprecated - setup_install_venv installiert requirements ohnehin" my_banner "pip install -r requirements.txt" install_clean_virtual_environment - if ! ~/venv/bin/python3 -m pip install -r "${project_root_dir}/requirements.txt"; then + if ! ~/venv/local/bin/python3 -m pip install -r "${project_root_dir}/requirements.txt"; then my_banner_warning "pip install -r requirements.txt ERROR" beep sleep "${sleeptime_on_error}" @@ -176,12 +198,29 @@ function install_pip_requirements_venv() { function setup_install_venv() { + if test -f "${project_root_dir}/pyproject.toml"; then + my_banner "install via pip and pyproject.toml on virtual environment" + install_clean_virtual_environment + cd "${project_root_dir}" || exit + if ! ~/venv/local/bin/python3 -m pip install -e ".[test]"; then + my_banner_warning "pip install [test] ERROR" + beep + sleep "${sleeptime_on_error}" + return 1 + fi + fi +} + + +# todo wip delete me +function setup_test_venv_old() { if test -f "${project_root_dir}/setup.py"; then - my_banner "setup.py install on virtual environment" + my_banner_warning "setup_test_venv is deprecated - benutze run_pytest_venv" + my_banner "setup.py test on virtual environment" install_clean_virtual_environment cd "${project_root_dir}" || exit - if ! ~/venv/bin/python3 "${project_root_dir}/setup.py" install; then - my_banner_warning "setup.py install ERROR" + if ! ~/venv/local/bin/python3 "${project_root_dir}/setup.py" test; then + my_banner_warning "setup.py test ERROR" beep sleep "${sleeptime_on_error}" return 1 @@ -191,11 +230,10 @@ function setup_install_venv() { function test_commandline_interface_venv() { - # this will fail if rotek lib directory is in the path - keep this as a reminder my_banner "test commandline interface on virtual environment" - clr_green "issuing command : $HOME/venv/bin/lib_platform --version" - if ! "$HOME/venv/bin/lib_platform" --version; then + clr_green "issuing command : /usr/local/bin/lib_platform --version" + if ! "/usr/local/bin/lib_platform" --version; then my_banner_warning "test commandline interface on virtual environment ERROR" beep sleep "${sleeptime_on_error}" @@ -204,12 +242,26 @@ function test_commandline_interface_venv() { } -function test_setup_test_venv() { +function test_commandline_interface_venv_old() { + # this will fail if rotek lib directory is in the path - keep this as a reminder + my_banner "test commandline interface on virtual environment" + + clr_green "issuing command : $HOME/venv/local/bin/lib_platform --version" + if ! "$HOME/venv/local/bin/lib_platform" --version; then + my_banner_warning "test commandline interface on virtual environment ERROR" + beep + sleep "${sleeptime_on_error}" + return 1 + fi +} + +# todo wip delete me +function test_setup_test_venv_old() { if test -f "${project_root_dir}/setup.py"; then my_banner "setup.py test" install_clean_virtual_environment cd "${project_root_dir}" || exit - if ! ~/venv/bin/python3 "${project_root_dir}/setup.py" test; then + if ! ~/venv/local/bin/python3 "${project_root_dir}/setup.py" test; then my_banner_warning "setup.py test ERROR" beep sleep "${sleeptime_on_error}" diff --git a/tests/local_testscripts/run_testloop.sh b/tests/local_testscripts/run_testloop.sh index 2eb5b6a..2d5e515 100644 --- a/tests/local_testscripts/run_testloop.sh +++ b/tests/local_testscripts/run_testloop.sh @@ -13,11 +13,11 @@ project_root_dir="${project_root_dir}" DO_FLAKE8_TESTS="True" DO_MYPY_TESTS="True" DO_PYTEST="True" -DO_BLACK="False" +DO_BLACK="True" # cleanup on cntrl-c trap cleanup EXIT -# install dependencies +# install dependencies which needed on local python, like venv install_dependencies function pytest_loop { @@ -34,17 +34,17 @@ function pytest_loop { if ! run_flake8_tests; then continue; fi fi + if [ "${DO_PYTEST}" == "True" ]; then + if ! run_pytest --disable-warnings; then continue; fi + fi + # we prefer to run tests on its own, not within pytest, due to shaky and outdated pytest plugins if [ "${DO_MYPY_TESTS}" == "True" ]; then if ! run_mypy_tests; then continue; fi fi - if [ "${DO_PYTEST}" == "True" ]; then - if ! run_pytest --disable-warnings; then continue; fi - fi - # if ! install_pip_requirements_venv; then continue; fi - # if ! test_setup_test_venv; then continue; fi + if ! setup_test_venv; then continue; fi if ! setup_install_venv; then continue; fi if ! test_commandline_interface_venv; then continue; fi diff --git a/tests/local_testscripts/run_testloop_pytest_and_mypy_only_no_setup.sh b/tests/local_testscripts/run_testloop_pytest_and_mypy_only_no_setup.sh new file mode 100644 index 0000000..1331cda --- /dev/null +++ b/tests/local_testscripts/run_testloop_pytest_and_mypy_only_no_setup.sh @@ -0,0 +1,61 @@ +#!/bin/bash +own_dir="$( cd "$(dirname "${BASH_SOURCE[0]}")" || exit && pwd -P )" # this gives the full path, even for sourced scripts + +# shellcheck disable=SC2050 +if [[ "True" != "True" ]]; then + echo "exit - ${BASH_SOURCE[0]} is not configured by PizzaCutter" + exit 0 +fi + +# shellcheck disable=SC1090 +source "${own_dir}/lib_bash_functions.sh" +project_root_dir="${project_root_dir}" +DO_FLAKE8_TESTS="True" +DO_MYPY_TESTS="True" +DO_PYTEST="True" +DO_BLACK="True" +# cleanup on cntrl-c +trap cleanup EXIT + +# install dependencies +install_dependencies + +function pytest_loop { + while true; do + banner "Project Root Dir: ${project_root_dir}" + cleanup + + if [ "${DO_BLACK}" == "True" ]; then + if ! run_black; then continue; fi + fi + + # we prefer to run tests on its own, not within pytest, due to shaky and outdated pytest plugins + if [ "${DO_FLAKE8_TESTS}" == "True" ]; then + if ! run_flake8_tests; then continue; fi + fi + + if [ "${DO_PYTEST}" == "True" ]; then + if ! run_pytest --disable-warnings; then continue; fi + fi + + # we prefer to run tests on its own, not within pytest, due to shaky and outdated pytest plugins + if [ "${DO_MYPY_TESTS}" == "True" ]; then + if ! run_mypy_tests; then continue; fi + fi + + # if ! install_pip_requirements_venv; then continue; fi + # if ! setup_test_venv; then continue; fi + # if ! setup_install_venv; then continue; fi + if ! test_commandline_interface_venv; then continue; fi + + banner "ALL TESTS PASSED for ${project_root_dir}" + banner "ALL TESTS PASSED for ${project_root_dir}" + banner "ALL TESTS PASSED for ${project_root_dir}" + sleep 5 + done + +} + +# upgrade_pytest +# upgrade_mypy +pytest_loop diff --git a/travis_secrets/create_secrets.sh b/travis_secrets/create_secrets.sh deleted file mode 100644 index f26778c..0000000 --- a/travis_secrets/create_secrets.sh +++ /dev/null @@ -1,26 +0,0 @@ -#!/bin/bash -save_dir="$PWD" -own_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" || exit && pwd -P)" # this gives the full path, even for sourced scripts - -# shellcheck disable=SC1090 -source "${own_dir}/create_secrets_bash_helpers.sh" - -project_root_dir="${project_root_dir}" - -install_dependencies - -banner "this will encrypt the name and the value of a secret environment variable for travis. -common secrets for the PizzaCutter Python Template are: -\"CC_TEST_REPORTER_ID\" and \"PYPI_PASSWORD\"" - -read -rp 'variable name :' var_name -read -rp 'variable value :' var_value - -cd "${project_root_dir}"||exit -travis encrypt "${var_name}=${var_value}" --no-interactive > "${own_dir}/secrets/${var_name}.secret.txt" - -banner "the secret for \"${var_name}\" was created and exported to: -${own_dir}/secrets/${var_name}.secret.txt. -it will be imported to travis.yml the next time You run PizzaCutter" -wait_for_enter -cd "${save_dir}" || exit diff --git a/travis_secrets/create_secrets_bash_helpers.sh b/travis_secrets/create_secrets_bash_helpers.sh deleted file mode 100644 index a03ea33..0000000 --- a/travis_secrets/create_secrets_bash_helpers.sh +++ /dev/null @@ -1,90 +0,0 @@ -#!/bin/bash -save_dir="$PWD" -# this gives the full path, even for sourced scripts -dir_own="$(cd "$(dirname "${BASH_SOURCE[0]}")" || exit && pwd -P)" - -sudo_askpass="$(command -v ssh-askpass)" -export SUDO_ASKPASS="${sudo_askpass}" -# get rid of (ssh-askpass:25930): dbind-WARNING **: 18:46:12.019: Couldn't register with accessibility bus: Did not receive a reply. -export NO_AT_BRIDGE=1 - -dir_travis_secrets="${dir_own}" -# one level up -project_root_dir="$(dirname "${dir_travis_secrets}")" - -# CONSTANTS -True=0 -False=1 - -function install_or_update_lib_bash() { - if [[ ! -f /usr/local/lib_bash/install_or_update.sh ]]; then - sudo git clone https://github.com/bitranox/lib_bash.git /usr/local/lib_bash 2>/dev/null - sudo chmod -R 0755 /usr/local/lib_bash 2>/dev/null - sudo chmod -R +x /usr/local/lib_bash/*.sh 2>/dev/null - sudo /usr/local/lib_bash/install_or_update.sh 2>/dev/null - else - /usr/local/lib_bash/install_or_update.sh - fi -} - -install_or_update_lib_bash - -source /usr/local/lib_bash/lib_helpers.sh - -function my_banner() { - banner "${project_root_dir}: ${1}" -} - -function my_banner_warning() { - banner_warning "${project_root_dir}: ${1}" -} - -function purge_linux_package_ruby() { - # purges ruby and all ruby gems - sudo apt-get purge ruby -y - sudo apt-get purge ruby-dev -y - sudo rm -rf /usr/share/rubygems-integration - sudo rm -rf /var/lib/gems - sudo rm -rf /usr/bin/gems - sudo rm -rf /usr/share/ri -} - - -function is_travis_gem_installed() { - if [[ $(sudo gem list | grep -c travis) == 0 ]]; then - return $False - else - return $True - fi -} - - -function install_travis_gem() { - sudo gem install travis -} - - -function check_install_travis_gem() { - if ! is_travis_gem_installed ; then - banner "Ruby Travis Gem is not installed, I will install it for You" - wait_for_enter - install_travis_gem - fi -} - - -function check_install_ruby_dev() { - if ! is_package_installed ruby-dev; then - banner "Linux Package ruby-dev is not installed, I will install it for You" - wait_for_enter - install_package_if_not_present ruby-dev - fi -} - -function install_dependencies() { - clr_green "installing dependencies" - check_install_ruby_dev - check_install_travis_gem -} - -cd "${save_dir}"||exit diff --git a/travis_secrets/secrets/CC_TEST_REPORTER_ID.secret.txt b/travis_secrets/secrets/CC_TEST_REPORTER_ID.secret.txt deleted file mode 100644 index 7003542..0000000 --- a/travis_secrets/secrets/CC_TEST_REPORTER_ID.secret.txt +++ /dev/null @@ -1 +0,0 @@ -"IDAldo6HWLAFHnQg4SRyMO4og923nEjeQ/jeOeFUhvgb8/p8Sq01NZR+CH6EC/YRucTjbuBwociJXgQ88hkYprczbWGiijU0MgV/iiRPHd0/f8ZLOTXsOKK81pKV1wcrZMOsqRwwXCjRZHRr2dwK7kJKlV/5p/ESFI9ZscMZrOllS/vEwoPkyWo8rkMjV/oVvC9N8LENvCDjVseODYBXKMpN9TmrICIghiqnndNU0zdOUmNUqquQajxWRiCfowktkmPBkZpJvCDRm6TEgckVHdnczZE4Hzm8SIqEnQK/FAvy+9N65dbH7yiKufTBBdsQrwtwH1+CAAlIbeWnGtezOSON9zRkJYAjeeE1/ax28coh0NiIg0hNCzSawEjp0mVJnvwYDpW06szvBURaOYtCz9FZ8//Ql5xIKCM9IxX3FMiwhoEKHsmbkYEc5KmljkBBNaKOoxI8rFN26XvqoI9y2aRR7I/fFWxfFiIgVsRo1CL1qFhl+R0dnHbNK0abcGLQ6mRmvqXvQb3tW67So13NBueLfBibARR6uE7lh27JG0rLa92Xez2TPBr0mUOS4QDyrNNXv94LHUzO6rrSO3ZCXqXadqX340EcB9J8TG7a6jLp6R03uLCeGCda7ZWpF/9jbD4iAsDExCb+twwfaN0FCKxYn0VTDFLcJRHv2l4wIGM=" diff --git a/travis_secrets/secrets/PYPI_PASSWORD.secret.txt b/travis_secrets/secrets/PYPI_PASSWORD.secret.txt deleted file mode 100644 index 914e294..0000000 --- a/travis_secrets/secrets/PYPI_PASSWORD.secret.txt +++ /dev/null @@ -1 +0,0 @@ -"wK8WmNhbVEkbI8V3vSGKFtme/75tL/DItotP66lUleD0sgQyNs3EM+USZPtkFkpJYnIyaX+qfH1zMR+nwLcOmbWHFAcyRBJXmDDDU3E3+UGEJ8DcLEktYOvnY5fGPdbjN5OMDbNdDYwwkC1Ggq/Cqbt1IwYNBCiuzxVtKIPo7oPFShg1mzkvmRTWD4MGygOUYlNTx9/x8OrnXrbj15tGRbrgjF3QE1HC87E464DUN77RZkNmV4ObW/sjo0LqubYeo5Je32oYk7Ys1akFQnPNxYgk+sFA2EvlvLdqDwK/GrV8KTB2OmhA0pgEFR505pCvHiPIA6WbShj2fffqNXUfFHHULo/sgHxI59Fk+lM5jjBQ+OiQuS41BoNhs02pLeuHsNBwRcqFu9MTrDKOtyIuMfbjG4MUTf6x6yleDRkGIkxZLQ0X6QDLOikEb0bVVxZ/xC3lrNfpgz6kRlXfopsBZK1AVrA3HnvhAeI+WjgsYxnHnLLuFddmKn6JpUaYn6GsS+k8gml0t82hi5d77dzVjycgdihk0nEwxbXLpSNuOSEIQu+TXnQZwpV8GOsnpHNYdvfAZIyQ7NZNQqO3O1hrA3qy3bbK87ZgwtkOg4/iZdVjBzEDHF6x2Hw/275WY/b9E3VL1yW+p5w1txG3tPb+wy7kVHmuW3SdmbP12y+a8aE=" diff --git a/travis_secrets/shellcheck.sh b/travis_secrets/shellcheck.sh deleted file mode 100644 index 24bac1f..0000000 --- a/travis_secrets/shellcheck.sh +++ /dev/null @@ -1,50 +0,0 @@ -#!/bin/bash -# test the shellscripts in the current directory - -save_dir="$PWD" - -# install bash helper scripts -function install_or_update_lib_bash() { - if [[ ! -f /usr/local/lib_bash/install_or_update.sh ]]; then - sudo git clone https://github.com/bitranox/lib_bash.git /usr/local/lib_bash 2>/dev/null - sudo chmod -R 0755 /usr/local/lib_bash 2>/dev/null - sudo chmod -R +x /usr/local/lib_bash/*.sh 2>/dev/null - sudo /usr/local/lib_bash/install_or_update.sh 2>/dev/null - else - /usr/local/lib_bash/install_or_update.sh - fi -} - -install_or_update_lib_bash - -source /usr/local/lib_bash/lib_helpers.sh - - -function check_shellcheck_installed { - # check if shellcheck is installed, otherwise install it - if ! is_package_installed shellcheck; then - banner "shellcheck is not installed, I will install it for You" - wait_for_enter - install_package_if_not_present shellcheck - fi -} - - -function shell_check { - banner "checking shellscripts" - # exclude Codes : - # SC1091 not following external sources -> so we dont check /usr/local/lib_bash/lib_helpers.sh - if shellcheck --shell=bash --color=always \ - --exclude=SC1091 \ - ./*.sh \ - ; then - banner "finished shellcheck without errors" - else - banner_warning "finished shellcheck, some errors occured, check the output" - fi - -} - -check_shellcheck_installed -shell_check -cd "${save_dir}"||exit