A tutorial for new students learning how to use Github and Python
- Python
- Git
- Basic understanding of your terminal
This tutorial uses WSL (Windows Subsystem for Linux) - using the BASH terminal.
git clone https://<username>:<token>@github.com/softnanolab/github-tutorial
git checkout -b <name>
touch softnanoexample/test_function.py
#!/usr/bin/env python
"""Am example function"""
def example_function():
print("This is a test function!")
return
def main():
example_function()
return
if __name__ == '__main__':
main()
git add softnanoexample/example.py
git commit softnanoexample/example.py -m 'Adding example function'
git push --set-upstream origin <name>
git checkout -b <name>-package
import setuptools
with open("README.md", "r", encoding='utf-8') as f:
long_description = f.read()
setuptools.setup(
name="softnanoexample",
version="0.0.1",
author="Debesh Mandal",
description="Example Package",
long_description=long_description,
long_description_content_type="text/markdown",
url="https://github.com/softnanolab/github-tutorial",
packages=setuptools.find_packages(),
classifiers=[
"Programming Language :: Python :: 3",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
],
python_requires=">=3"
)
pip install .
python -c "import softnanoexample"
git commit -a -m 'added setup.py'
git push -u origin <name>-package
mkdir test
touch test/test_example.py
from softnanoexample.example import function
def test_function():
assert function() == "This is a test function!"
return
pip install .
pytest
git commit -a -m 'added tests'
mkdir .github
mkdir .github/workflows
touch .github/workflows/quick-test.yml
git add .github
git commit -a -m 'added CI'
git push