Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use poetry for dependency management and build #188

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
4 changes: 2 additions & 2 deletions cloudbuild.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
steps:
- id: api_python
name: python:3.7-slim
entrypoint: /bin/sh
name: python:3.7
entrypoint: /bin/bash
args:
- -c
- "./run_tests.sh -p"
463 changes: 463 additions & 0 deletions poetry.lock

Large diffs are not rendered by default.

23 changes: 23 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
[tool.poetry]
name = "datacommons"
version = "1.4.3"
description = "Python client library to access Data Commons"
authors = ["Prashanth R <pradh@dev>"]
license = "Apache-2.0"
readme = "README.md"

[tool.poetry.dependencies]
python = "^3.7.1"
requests = "^2.28.1"
typing-extensions = "^4.4.0"
pandas = "^1.2.2"

[tool.poetry.group.dev.dependencies]
mock = "^4.0.3"
pytest = "^7.2.0"
toml = "^0.10.2"
yapf = "^0.32.0"

[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
6 changes: 0 additions & 6 deletions requirements.txt

This file was deleted.

21 changes: 12 additions & 9 deletions run_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,21 @@
# See the License for the specific language governing permissions and
# limitations under the License.

function setup_python {
python3 -m venv .env
source .env/bin/activate
pip install --upgrade pip
pip3 install -r requirements.txt -q
function setup_poetry {
export PATH="$HOME/.local/bin:$PATH"
alias pyrun='poetry run python3 -m'

if ! which poetry; then
curl -sSL https://install.python-poetry.org | python
fi
poetry install
}

function run_py_test {
setup_python
python3 -m pytest -vv
setup_poetry
pyrun pytest -vv
echo -e "#### Checking Python style"
if ! yapf --recursive --diff --style='{based_on_style: google, indent_width: 2}' -p datacommons/ datacommons_pandas/; then
if ! pyrun yapf --recursive --diff --style='{based_on_style: google, indent_width: 2}' -p datacommons/ datacommons_pandas/; then
echo "Fix lint errors by running: ./run_test.sh -f"
exit 1
fi
Expand Down Expand Up @@ -67,4 +70,4 @@ done
if [ $OPTIND -eq 1 ]
then
help
fi
fi