Skip to content

Commit

Permalink
Merge pull request #6 from FreeLeh/use-flit
Browse files Browse the repository at this point in the history
Use Flit and Add Publish Workflow
  • Loading branch information
edocsss committed Aug 31, 2022
2 parents 89666ba + a3f135f commit 719e924
Show file tree
Hide file tree
Showing 12 changed files with 88 additions and 35 deletions.
25 changes: 25 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Publish

on:
release:
types:
- created

jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: "3.7"
- name: Install Flit
run: pip install flit
- name: Install Dependencies
run: flit install --symlink
- name: Publish
env:
FLIT_USERNAME: __token__
FLIT_PASSWORD: ${{ secrets.PYPI_KEY }}
run: bash scripts/publish.sh
6 changes: 3 additions & 3 deletions .github/workflows/unit_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [ '3.7', '3.10' ]
name: Python ${{ matrix.python-version }}
python-version: ["3.7", "3.10"]
name: Python ${{ matrix.python-version }}
steps:
- uses: actions/checkout@v3
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
architecture: x64
cache: 'pip'
cache: "pip"
- run: ./scripts/dev.sh
- run: ./scripts/test.sh
- run: ./scripts/lint.sh
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ auth_client = OAuth2GoogleAuthClient.from_authorized_user_file(
)

store = GoogleSheetRowStore(
config.auth_client,
auth_client,
spreadsheet_id="<spreadsheet_id>",
sheet_name="<sheet_name>",
object_cls=Person,
Expand Down
7 changes: 0 additions & 7 deletions dev_requirements.txt

This file was deleted.

36 changes: 34 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,38 @@
[build-system]
requires = ["setuptools>=61.0"]
build-backend = "setuptools.build_meta"
requires = ["flit_core >=3.2,<4"]
build-backend = "flit_core.buildapi"

[project]
name = "pyfreedb"
authors = [
{name = "Edwin Candinegara", email = "edwin.candinegara@gmail.com"},
{name = "Fata Nugraha", email = "fatanugraha@outlook.com"}
]
readme = "README.md"
license = {file = "LICENSE"}
classifiers = ["License :: OSI Approved :: MIT License"]
requires-python = ">=3.7"
dynamic = ["version", "description"]
dependencies = [
"google-api-python-client==2.51.0",
"google-auth-httplib2==0.1.0",
"google-auth-oauthlib==0.5.2",
"requests==2.28.1"
]

[project.urls]
Home = "https://github.com/FreeLeh/PyFreeDB"

[project.optional-dependencies]
test = [
"black==22.3.0",
"mypy==0.961",
"isort==5.10.1",
"pytest==7.1.2",
"autoflake==1.4",
"types-requests==2.28.6",
"coverage==6.4.4",
]

[tool.isort]
profile = "black"
Expand Down
9 changes: 8 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
google-api-python-client==2.51.0
google-auth-httplib2==0.1.0
google-auth-oauthlib==0.5.2
requests==2.28.1
requests==2.28
black==22.3.0
mypy==0.961
isort==5.10.1
pytest==7.1.2
autoflake==1.4
types-requests==2.28.6
coverage==6.4.4
6 changes: 3 additions & 3 deletions scripts/dev.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env sh
set -eux

pip install -r requirements.txt
pip install -r dev_requirements.txt
pip install -e .
pip install flit
flit install --symlink
4 changes: 4 additions & 0 deletions scripts/publish.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env bash
set -eux

flit publish
17 changes: 0 additions & 17 deletions setup.py

This file was deleted.

3 changes: 3 additions & 0 deletions src/pyfreedb/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
"""PyFreeDB is a Python library that provides common and simple database abstractions on top of Google Sheets."""

__version__ = "0.1.0"
5 changes: 5 additions & 0 deletions src/pyfreedb/row/stmt.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ def execute(self) -> int:
"""
query = self._query.build_select([f"COUNT({self._store.RID_COLUMN_NAME})"])
rows = self._store._wrapper.query(self._store._spreadsheet_id, self._store._sheet_name, query)

# If the spreadsheet is empty, GViz will return empty rows instead.
if len(rows) == 0:
return 0

return int(rows[0][0])


Expand Down
3 changes: 2 additions & 1 deletion tests/integration/test_gsheet_row_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,12 @@ def test_gsheet_row_store_integration(config: IntegrationTestConfig) -> GoogleSh
sheet_name="row_store",
object_cls=Customer,
)

# Sheet is empty, expects empty list.
result = row_store.select("name", "age").execute()
assert result == []

assert 0 == row_store.count().execute()

# Insert some data, expects no exception raised.
rows = [
Customer(name="name1", age=10, dob="1-1-1999"),
Expand Down

0 comments on commit 719e924

Please sign in to comment.