Package: check-connection
Template Project to create working pip packageThis package contains an check_connection function where you can enter your server adress and the number of tries, so that it connects to the server as many times as given and calculates the artihmetic mean on how long it takes to do so.Additionally a list_mean function is implemented, where you can calculate the arithmetic mean of a list.Also, this project is an example package to show how to create an own pip package.
In the following the steps to do so are explainedBuild your own package1.1 SourcetreeThe structure of the project has to contain the following files and folders:
- LICENSE.txt- README.txt- CHANGELOG.txt- pyproject.toml- requirements.txt- src/{name_of_your_package}\Files such as .flake or Jenkinsfile are optional and can be used to check your code autmatically when updated on git.1.2 Building1.2.1 pip packageAfter setting up your sourcetree and implementing the code in__init__.pythe build can be started bypy -m build.This will created all needed files and structures. Afterwards this can be published to PyPi bytwine upload --repository-url {your_repo_url} ./dist/*.You should not include "/pypi" or "/simple" in the the PyPI remote repository URL. These suffixes are added by Artifactory when accessing the remote repository and can cause an error.\Now your package is finished and can be implement by other users by usingpip install {your_package_name}.\Note:IF you want to upload to PyPI instead, entertwine upload ./dist/*.Consider that you have to have an existing PyPi Account and that your package name is not already used.For further information see:https://confluencewikiprod.intra.infineon.com/display/SCCVMP/Basic+structure+of+a+python+Projecthttps://packaging.python.org/en/latest/tutorials/packaging-projects/1.2.2 conda packageTo create a conda package, you have to open your Conda-Prompt.If you already have uploaded your pip package to PyPi, you can simply enterconda skeleton pypi {your_package_name}.Afterwards, an folder with the name of your project and the right meta.yaml file is created, so now simply enterconda build {your_package_name}and the package will be created.
 
If you do not have created a PyPi package, follow these steps:\1.3 UpdatingAfter editing make sure, that the version number in thepyproject.tomlfile has changed and then enterpy -m buildandtwine upload dist/*again.2. Working on your own package2.1 Testing:2.1.1 Unit TestsTo test the package make sure, thatpytestis installed.Now you can create an own folder called "tests" where your files including your test goals are located. Consider, that these files have to start with "test_" in order to be recognized properly. Inside these files you have to have a function also being called somethink like "test_" at the beginning so that pytest can execute the tests.Now you can enterpytestinto your terminal and these tests will be executed automatically.If you want to save your report, simply enterpytest >{name_and_type_of_report}, e.g.pytest >myoutput.txt.Also if you want to see our report in the terminal and save it at the same time, usepytest | tee {name_and_type_of_report}, e.g.pytest | tee myoutput.log.2.1.2 Static Code AnalysisIf you want to execute a static code analysis make sureflake8is installed.Also only one file can be tested by adding the path, e.g.flake8 demo.py.
Afterwards you can enterflake8in your terminal and automatically all python files will be checked and a report will be given to you into your terminal.Same procedure as forpytestcan be used to save your report in a file.2.2 Documentation:To generate a documentation automatically make sure, thatpdoc3is installed.Also consider, that you have made docstrings for every function you want to be documented.Now you can create the documentation by simply enteringpdoc3 --html {location_of_your_code}in the terminal. This will autmatically create a folder called "html"" with a html file called the same as your code file in it, where the code is documented.3. LinksLink to pip package:not available at the momentLink to conda package:not available at the moment