Skip to content

Commit dc358fc

Browse files
authored
Merge pull request ebezzam#1 from ebezzam/feat/github_actions
Add github actions.
2 parents 3d85245 + c8744b5 commit dc358fc

3 files changed

Lines changed: 90 additions & 12 deletions

File tree

‎.github/workflows/python.yml‎

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: pydevtips
2+
3+
# on: [push, pull_request]
4+
on:
5+
# trigger on pushes and PRs to main
6+
push:
7+
branches:
8+
- main
9+
pull_request:
10+
branches:
11+
- main
12+
13+
jobs:
14+
build:
15+
16+
runs-on: ${{ matrix.os }}
17+
strategy:
18+
fail-fast: false
19+
max-parallel: 12
20+
matrix:
21+
os: [ubuntu-latest, macos-latest, windows-latest]
22+
python-version: [3.8, 3.9, "3.10"]
23+
steps:
24+
- uses: actions/checkout@v3
25+
- name: Checkout submodules
26+
shell: bash
27+
run: |
28+
auth_header="$(git config --local --get http.https://github.com/.extraheader)"
29+
git submodule sync --recursive
30+
git -c "http.extraheader=$auth_header" -c protocol.version=2 submodule update --init --force --recursive --depth=1
31+
- name: Set up Python ${{ matrix.python-version }}
32+
uses: actions/setup-python@v4
33+
with:
34+
python-version: ${{ matrix.python-version }}
35+
- name: Install dependencies and build package
36+
run: |
37+
python -m pip install --upgrade pip
38+
python -m pip install -e .
39+
- name: Lint with flake8
40+
run: |
41+
pip install flake8
42+
# stop the build if there are Python syntax errors or undefined names
43+
flake8 . --count --select=B,C,E,F,W,T4,B9 --show-source --statistics --max-complexity=18 --max-line-length=100 --ignore=E203,E266,E501,W503,F403,F401,C901
44+
- name: Format with black
45+
run: |
46+
pip install black
47+
black *.py -l 100
48+
black examples/*.py -l 100
49+
black profile/*.py -l 100
50+
black pydevtips/*.py -l 100
51+
black tests/*.py -l 100
52+
- name: Test with pytest
53+
run: |
54+
pip install -U pytest
55+
pytest

‎README.rst‎

Lines changed: 33 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,12 @@
22
python-dev-tips, `Slides <https://docs.google.com/presentation/d/1BnezhwUy22DiF72wss8GU_YIMfhjortz-uILdIFGuoM/edit?usp=sharing>`__
33
******************************************************************************************************************************************
44

5-
Creating virtual environment and install
6-
========================================
5+
Tutorial first given at ENS Ulm (January 2023) on how to develop a Python package. There is a slight focus on scientific computing, but the general principles apply to any Python project.
6+
7+
.. contents:: **Table of Contents**
8+
9+
Creating virtual environment and local install
10+
==============================================
711

812
With `Anaconda <https://www.anaconda.com/>`__ (recommended).
913
After installing Anaconda or `Miniconda <https://docs.conda.io/en/latest/miniconda.html>`__ (light version), create a new environment:
@@ -86,32 +90,51 @@ To run a specific test:
8690
(project_env) pytest tests/test_fftconvolve.py::test_fft
8791
8892
89-
Releasing package to PyPi
90-
=========================
93+
Releasing new version and deploying to PyPi
94+
===========================================
95+
96+
Uploading to PyPi is done via `twine <https://pypi.org/project/twine/>`__.
97+
98+
In the steps below and **after merging to** ``main``, replace "X.X.X" with the appropriate version number.
9199

92-
This is done through `twine <https://pypi.org/project/twine/>`__:
100+
See `Semantic Versioning <https://semver.org/>`__ for recommendations on picking version numbers.
93101

94102
.. code:: bash
95103
96104
# inside virtual environment
97105
(project_env) pip install twine
98106
107+
# edit version in setup
99108
# build package
100109
(project_env) python setup.py sdist bdist_wheel
101-
# -- create in dist folder
110+
# -- creates zip in dist folder
102111
103-
# upload to test pypi
112+
# upload to pypi
104113
(project_env) python -m twine upload dist/pydevtips-X.X.X.tar.gz
105114
# -- X.X.X is the version number in setup.py
106115
# -- enter username and password
107116
# -- check https://pypi.org/project/pydevtips/X.X.X/
108117
118+
# new tag on GitHub
119+
git tag -a X.X.X -m "version X.X.X"
120+
git push origin X.X.X
121+
122+
On `GitHub <https://github.com/ebezzam/python-dev-tips/tags>`__ create a new release by:
123+
124+
#. Clicking (the rightmost) "..." dropdown menu.
125+
#. Selecting "Create release".
126+
#. At the bottom pressing "Publish release".
127+
109128

110129
TODO
111130
====
112131

113-
- matplotlib in dev install
132+
- joblib example in profile
133+
- github page
134+
- point out features in scripts: object-oriented, asserts, tqdm, type hints
135+
- matplotlib, pytest, black in dev install
114136
- example file with hydra
115137
- manifest file to not include file in package
116-
- GitHub actions
117-
- documentation if time
138+
- GitHub actions for releasing to PyPi when changes to version
139+
- documentation (autodoc)
140+
- adding badges to README

‎setup.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
setuptools.setup(
77
name="pydevtips",
8-
version="0.0.1",
8+
version="0.0.2",
99
author="Eric Bezzam",
1010
author_email="ebezzam@gmail.com",
1111
description="Functions and scripts to demonstrate Python development tips.",
@@ -17,7 +17,7 @@
1717
"Programming Language :: Python :: 3",
1818
"Operating System :: OS Independent",
1919
],
20-
python_requires=">=3.9",
20+
python_requires=">=3.8",
2121
install_requires=[
2222
"numpy",
2323
"matplotlib",

0 commit comments

Comments
 (0)