Skip to main content

A Python gitlab template for initiating new projects in gitlab. The boilerplate / template files that are copied are based on best-practices for Python package development. The new project contains the following features,

  • tests directory for defining unittests

  • examples directory for placing example snippets

  • docs

    Sphinx based on the RTD theme for API and architectural documentation. It also enables UML diagrams to be dynamically generated based on PlantUML and graphviz tool.

  • run.py main script entry point with a generic argument parser implementation.

  • versioneer.py an automated version numbering system.

  • pylint.cfg file for source code lexical analysis.

  • setup.py: file for wheel file building and deployment to PyPI server.

  • .gitlab-ci.yml file for continuous integration for,
    • unit testing

    • code coverage

    • lint analysis

    • Sphinx documentation building

    • Pages documentation generation

    • deployment to PyPI server.

Installation

Install using pip:

pip install mrg_gitlab_template

Or to upgrade:

pip install --upgrade --no-cache-dir mrg_gitlab_template

Command line usage

The pygitcopy is a command line utility program to create a new project. The help switch provides the command line arguments:

$ pygitcopy --help

usage: pygitcopy [-h] -g GROUP [-p PAGES_DOMAIN] [-u GITLAB_URL] [-a AUTHOR]
                 [-e EMAIL] [-y YEAR] [-d DIRECTORY] [-v]
                 package

Create new project from template

positional arguments:
  package               package name

optional arguments:
  -h, --help            show this help message and exit
  -g GROUP, --group GROUP
                        the gitlab account. Example: mrg-tools, sci-fv, your
                        account name, etc (default: None)
  -p PAGES_DOMAIN, --pages-domain PAGES_DOMAIN
                        the gitlab pages url domain. Example: gitlab.io,
                        io.esa.int (default: gitlab.io)
  -u GITLAB_URL, --gitlab-url GITLAB_URL
                        the gitlab pages url domain. Example: gitlab.com,
                        gitlab.esa.int (default: gitlab.com)
  -a AUTHOR, --author AUTHOR
                        author name (default: {{author}})
  -e EMAIL, --email EMAIL
                        author email (default: {{email}})
  -y YEAR, --year YEAR  author email (default: <this-year>)
  -d DIRECTORY, --directory DIRECTORY
                        base directory location (default: .)
  -v, --verbosity       Increase output verbosity (default: 0)

Creating a new project

Execute the following command:

pygitcopy <package> --group <group> --directory <new-project-base-dir> -vv

Execute the following commands to add the new project to gitlab:

cd <new-project-base-dir>/<name>
git init
git add .
git commit -m "First commit"

Navigate to https://gitlab.com/projects/new and create a new <name> project. Your local can be linked to this repository using the following commands:

git remote add origin https://gitlab.com/<group>/<name>.git
git push -u origin --all
git push -u origin --tags

To delete a repository from gitlab, use this link and scroll to the end,

Create “testproj” Example

This example will show you how to,

  • create a virtual environment

  • create a new gitlab repository

  • create a new local project based on this template project

  • link the local project to the repository

  • commit and push the project files to the repository

Install system requirements:

sudo apt-get install git
sudo apt-get install virtualenv
sudo apt-get install plantuml

Create the new testproj repository project in the gitlab web site:

firefox https://gitlab.com/projects/new

Create virtual environment:

mkdir ~/venv
cd ~venv
virtualenv -p python3 py3
source py3/bin/activate

Install the template package:

pip install mrg_gitlab_template

Create a new local project and upload to git:

cd ~/PycharmProjects/
pygitcopy testproj --group mrg-tools
cd testproj
git init
git add .
git remote add origin https://gitlab.com/mrg-tools/testproj.git
git push -u origin --all

Check the gitlab pipelines and generated files,

Prepare the project for development:

pip install -r requirements-dev.txt
export PYTHONPATH=$PWD

Run some tests:

pylint --pylint-rc=pylint.cfg testproj
pytest
pytest --cov

Build the documentation:

cd docs
make html
firefox build/html/index.html

Metadata

Release files for mrg_gitlab_template 0.6.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for mrg_gitlab_template 0.6.3
File Interpreter ABI Platform
mrg_gitlab_template-0.6.3-py2.py3-none-any.whl Python 3, Python 2 none any Details

Release files / mrg_gitlab_template-0.6.3-py2.py3-none-any.whl

Download URL mrg_gitlab_template-0.6.3-py2.py3-none-any.whl
Size 77.4 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
2cd53a4106e65f4953dbc01b48f4e3279ccf485cfe908916dcd5fe12db87a9d1
BLAKE2b-256 checksum
How to use checksums
04a71d0c8017940110c9d1951be35ce879fd72002747b5db5a6dd5ada705ec8c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

0.6.3 This release

1 release file

0.6.2

1 release file

0.6.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page