Pybhub is a Python library for interfacing with the Github API.
- Python 3.* (tested on 3.6 and 3.9) with pip.
- Windows (tested on Windows 11)
- Linux (tested on Ubuntu via WSL)
Use virtualenv. Optional, but recommended:
pip install virtualenv
python -m virtualenv pyghub
pyghub\Scripts\activate.bat # `source ./pyghub/bin/activate` for Linux
Then...
pip install -r requirements.txt
set GH_TOKEN=<github personal access token>
python -m pyghub.cli get_repo -o Microsoft -r Terminal
To invoke Pyghub directly from a command line, see CLI.md.
from pyghub.providers.github import Github
from pyghub.providers.git import Git
# Get Repo information for https://github.com/microsoft/terminal
gh = Github("api_key")
info = gh.get_repo("microsoft", "terminal")
# Clone the same repo to c:\git\terminal
g = Git()
g.clone_repo("https://github.com/microsoft/terminal", "c:\\git\\terminal")
# Pull, push
g.pull("c:\\git\\terminal", "origin", "main")
g.push("https://username:[email protected]/microsoft/terminal", "origin", "main") # note the credentials required for pushing)
# Install dev dependencies
pip install -r dev-requirements.txt
# Linting
python -m pylint pyghub
# Unit tests (with code coverage)
python -m pytest --cov
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Please make sure to update tests as appropriate.