Skip to main content

A Python gitlab template for initiating new projects in gitlab

Project description

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.
  • main script entry point with a generic argument parser implementation.
  • an automated version numbering system.
  • pylint.cfg file for source code lexical analysis.
  • 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.


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]

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:,
  -u GITLAB_URL, --gitlab-url GITLAB_URL
                        the gitlab pages url domain. Example:,
  -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 and create a new <name> project. Your local can be linked to this repository using the following commands:

git remote add origin<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:


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
git push -u origin --all

Check the gitlab pipelines and generated files,

Prepare the project for development:

pip install -r requirements-dev.txt

Run some tests:

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

Build the documentation:

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

Project details

Download files

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

Files for mrg_gitlab_template, version 0.6.3
Filename, size File type Python version Upload date Hashes
Filename, size mrg_gitlab_template-0.6.3-py2.py3-none-any.whl (77.4 kB) File type Wheel Python version 3.6 Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page