Skip to main content

A collection of Python modules and libraries for CI/CD pipelines in the jEAP context.

Project description

jeap-python-pipeline-lib

A collection of Python modules and libraries for CI/CD pipelines with jEAP context.

Local Development

Setup

  1. Clone the repository:

    git clone https://github.com/jeap-admin-ch/jeap-python-pipeline-lib.git
    cd jeap-python-pipeline-lib
    
  2. Create a virtual environment and activate it:

    python3 -m venv venv
    source venv/bin/activate
    
  3. Install the dependencies:

    pip install -r requirements.txt
    

Development basics

  • Adding New Modules:

    • Create a new Python file in the src/jeap_pipeline/ directory.
    • Ensure the new module has a corresponding test file in the tests/ directory.
    • Follow the naming conventions and structure of existing modules.
  • Writing Documentation:

    • Add docstrings to all public classes and functions.
    • Update the CHANGELOG.md with any new features or changes.
    • If necessary, add detailed documentation in the docs/ directory.
  • Changing the Version:

    • Update the version number in the pyproject.toml file.
    • Ensure the version number complies with semantic versioning and the PEP 440 standard.

Build

A more comprehensive documentation can be found here: https://packaging.python.org/en/latest/tutorials/packaging-projects/

Install the build tool via pip. Make sure you have the latest version of PyPA’s build installed:

pip install build

To create the package run this command from the same directory where pyproject.toml is located:

python -m build

This command should generate two files in the dist directory. The tar.gz file is a source distribution whereas the .whl file is a built distribution.

Upload

It should be noted that the publishing process takes place automatically in the pipeline. The following steps are only necessary for manual publishing.

First install twine via pip:

python3 -m pip install --upgrade twine

Once installed, run Twine to upload all the archives under dist:

python3 -m twine upload --repository testpypi dist/*

Use testpypi to upload the package to test instance of PyPI. To upload to the real PyPI repository, use pypi instead of testpypi. You will be prompted for an API token. Use the token value, including the pypi- prefix.

Package installation

You can use pip to install your package and verify that it works. Create a virtual environment and install your package from TestPyPI:

python3 -m pip install -i https://test.pypi.org/simple/ jeap-pipeline==0.1.0

Generate THIRD-PARTY-LICENSES.md

To generate the THIRD-PARTY-LICENSES.md file, run the following command:

python -m third_party_license_file_generator -r requirements.txt -p /usr/bin/python3 -o THIRD-PARTY-LICENSES.md
  • -r REQUIREMENTS_PATH: Path to the requirements.txt file, which contains the dependencies of the project.
  • -p PYTHON_PATH: Path to the Python interpreter, which is used to execute the license-checker.
  • -o OUTPUT_FILE: Name of the output file, which contains the license information of the dependencies.

Publishing

Versioning

The version can be set in the pyproject.toml file. The version number has to comply with semantic versioning and the PEP 440 standard. On every push a CI pipeline is triggered, which builds and uploads the artifact to the (test)-pypi repository.

  • On the main branch, the version number remains unchanged and the artifact is published as a stable release to pypi.
  • On feature branches, a valid development release suffix (.dev) is added to the version. The artifact is published to TestPyPI.

Publishing via GitHub Actions

The publishing process is automated using GitHub Actions. The CI pipeline is defined in the .github/workflows/publish.yml file. The key steps involved are:

  1. Setup Python Environment: The pipeline sets up the Python environment using the specified version in the pyproject.toml file.
  2. Install Dependencies: All necessary dependencies are installed using pip.
  3. Run Tests: The test suite is executed to ensure the code is functioning as expected.
  4. Generate Version: The version number is generated based on the branch name.
  5. Generate License File: The license file is generated using the third_party_license_file_generator tool.
  6. Build Package: The package is built using python -m build.
  7. Upload to PyPI: The built package is uploaded to PyPI or TestPyPI using twine.

Project Files

  • LICENSE Contains the license information for the project.

  • MANIFEST.in Specifies additional files to include in the distribution package.

  • pyproject.toml Modern configuration file for build systems. Contains metadata and dependencies of the project.

  • requirements.txt Lists the dependencies for development and testing.

  • THIRD-PARTY-LICENSES.md Generated file that lists the licenses of third-party dependencies.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

jeap_pipeline-0.1.2.tar.gz (9.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

jeap_pipeline-0.1.2-py3-none-any.whl (7.6 kB view details)

Uploaded Python 3

File details

Details for the file jeap_pipeline-0.1.2.tar.gz.

File metadata

  • Download URL: jeap_pipeline-0.1.2.tar.gz
  • Upload date:
  • Size: 9.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.16

File hashes

Hashes for jeap_pipeline-0.1.2.tar.gz
Algorithm Hash digest
SHA256 972ee95fa007c7f9cada0a4e917ee1cb609efa00303c8fee6b1aec334163475c
MD5 789ae8c7324b71c379041f039ab3318d
BLAKE2b-256 f087bff05e139feb678b7a473b725fad5f558fbb123ff9f87ed3680fc50abfc8

See more details on using hashes here.

File details

Details for the file jeap_pipeline-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: jeap_pipeline-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 7.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.16

File hashes

Hashes for jeap_pipeline-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 a222fd0a96ec1d11de5a6530b99872c4fa47569c056f5f844e4d35cc04f5ca6a
MD5 d03503b753881c7b02dbbd8ab2bd7910
BLAKE2b-256 b4745fad20f892fd766da3775151efe74503b2de840a8ebb6ecf7e68902006f7

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page