taers232c / GAMADV-XTD3

Command line tool to manage Google Workspace
691 stars 86 forks source link

Update Python Library install instructions #357

Closed thekaveman closed 1 year ago

thekaveman commented 1 year ago

Thanks for the work on this library!

I've been playing around with integrating it in my Python project, and I wanted to list as a dependency along with others in my pyproject.yaml (or requirements.txt) and found that the existing instructions/format don't quite translate to the required PEP 508 style.

A suggestion for how to describe referencing this library using a Requirements Reference:

Existing wiki page

https://github.com/taers232c/GAMADV-XTD3/wiki/Install-GAM-as-Python-Library

Updated content

Thanks to Jay Lee for showing me how to do this.

On Windows, you need to install Git to use the pip command.

You can install GAM as a Python library directly with pip:

pip install git+https://github.com/taers232c/GAMADV-XTD3.git#subdirectory=src --use-pep517

Or as a PEP 508 Requirement Specifier, e.g. in requirements.txt file:

advanced-gam-for-google-workspace @ git+https://github.com/taers232c/GAMADV-XTD3.git#subdirectory=src

Or a pyproject.toml file:

[project]
name = "your-project"
# ...
dependencies = [
    "advanced-gam-for-google-workspace @ git+https://github.com/taers232c/GAMADV-XTD3.git#subdirectory=src"
]

Target a specific revision or tag:

advanced-gam-for-google-workspace @ git+https://github.com/taers232c/GAMADV-XTD3.git@v6.57.11#subdirectory=src

Using the library

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
""" Sample Python script to call GAM"""

import multiprocessing
import platform

from gam import initializeLogging, CallGAMCommand

if __name__ == '__main__':
# One time initialization
  if platform.system() != 'Linux':
    multiprocessing.freeze_support()
    multiprocessing.set_start_method('spawn')
  initializeLogging()
#
  CallGAMCommand(['gam', 'version'])
  # Issue command, output goes to stdout/stderr
  rc = CallGAMCommand(['gam', 'info', 'domain'])
  # Issue command, redirect stdout/stderr
  rc = CallGAMCommand(['gam', 'redirect', 'stdout', 'domain.txt', 'redirect', 'stderr', 'stdout', 'info', 'domain'])
taers232c commented 1 year ago

Done.

Thanks,

Ross

thekaveman commented 1 year ago

Awesome, thank you! 👍