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

Split namespace packages and add httpx client #1

Merged
merged 20 commits into from
Jan 19, 2024
Merged
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
44 changes: 44 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Ignore Python bytecode files / cache
*.pyc
*.pyo
*.pyd
.mypy_cache
.pytest_cache
.ruff_cache
__pycache__
__pypackages__

# Ignore Python virtual environment files
venv/
.venv/
.ve/
.pdm.toml
.pdm-build
.pdm-python

# Ignore local development configuration files
.git
.env
.flake8
mypy.ini
.dockerignore
.gitignore
.gitlab-ci.yml
.python-version
README.md
.hooks
.lets
helm
.ipython
.secrets

# Ignore IDE settings
.vscode
.idea

# Ignore any compiled Python extension modules
*.so

# Ignore any build artifacts
build/
dist/
26 changes: 26 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Build & publish

# TODO: Setup release workflow
on:
push:
branches: [ "**" ]
tags:
- "v*"
# pull_request:
# branches: [main]

jobs:
deploy-client:
runs-on: ubuntu-latest
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/client-')
strategy:
matrix:
python-version: [3.7]
Copy link
Collaborator Author

@n4mespace n4mespace Dec 26, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

by the way, @kindermax, what minimun version should we support? can we start from 3.9/3.10 at least? maybe do a poll in dev channel?

steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: pdm-project/setup-pdm@v3
with:
python-version: ${{ matrix.python-version }}
- name: Upload package to pypi.org
run: pdm publish --username ${{ secrets.PYPI_USERNAME }} --password ${{ secrets.PYPI_PASSWORD }}
34 changes: 34 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Test

on:
pull_request:
branches:
- main
types:
- assigned
- opened
- synchronize
- reopened

jobs:
test-clients:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.9, "3.10", 3.11, 3.12]
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: pdm-project/[email protected]
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: python -m pip install tox tox-gh-actions tox-pdm

- name: Test with tox
run: |
tox --version
tox
37 changes: 37 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Ignore Python bytecode files / cache
*.pyc
*.pyo
*.pyd
.mypy_cache
.pytest_cache
.ruff_cache
__pycache__
__pypackages__
featureflags_protobuf

# Ignore Python virtual environment files
venv/
.venv/
.ve/
.pdm.toml
.pdm-python
.pdm-build

# Ignore local development configuration files
.env
.lets
.ipython
.ptpython
.python-version
.secrets

# Ignore IDE settings
.vscode
.idea

# Ignore any compiled Python extension modules
*.so

# Ignore any build artifacts
build/
dist/
27 changes: 27 additions & 0 deletions .hooks/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/bin/bash

HAS_STAGED_PY=$(git diff --staged --diff-filter=d --name-only '*.py')

if [ -n "$HAS_STAGED_PY" ]; then

echo "Running mypy ..."
lets mypy
if [[ $? -ne 0 ]]; then
exit 1
fi

echo "Running black ..."
lets black --diff --check
if [[ $? -ne 0 ]]; then
exit 1
fi

echo "Running ruff ..."
lets ruff-diff
if [[ $? -ne 0 ]]; then
exit 1
fi

fi

exit 0
48 changes: 48 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
FROM python:3.11-slim-bullseye as base

ENV PIP_VERSION=23.2.1
ENV PDM_VERSION=2.9.1
ENV PDM_USE_VENV=no
ENV PYTHONPATH=/app/__pypackages__/3.11/lib

WORKDIR /app

COPY ./pyproject.toml .
COPY ./pdm.lock .

RUN apt-get update && \
apt-get install -y --no-install-recommends \
libpq-dev \
gcc \
make \
g++ \
git && \
# install tools
pip install --upgrade pip==${PIP_VERSION} && \
pip install pdm==${PDM_VERSION} && \
# configure
pdm config cache_dir /pdm_cache && \
pdm config check_update false && \
# install base deps \
pdm install --no-lock --prod --no-editable && \
# cleanup base layer to keep image size small
apt purge --auto-remove -y \
gcc \
make \
g++ \
git && \
rm -rf /var/cache/apt && \
rm -rf /var/lib/apt/list && \
rm -rf $HOME/.cache

FROM base as dev
RUN pdm install --no-lock -G dev -G lint --no-editable

FROM dev as examples
RUN pdm install --no-lock -G examples

FROM dev as test
RUN pdm install --no-lock -G test

FROM base as docs
RUN pdm install --no-lock -G docs
35 changes: 35 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
FeatureFlags client library for Python

See ``examples`` directory for complete examples for some major Web frameworks.

Overview
--------

Client supports Python >=3.9.


Installation
------------

TODO:


Development
-----------

Install dependencies:
- ``pdm install -d``

Pre-commit

``./scripts/enable-hooks.sh``

``./scripts/disable-hooks.sh``


TODO:
- add docs, automate docs build
- add tests
- add `tracer` / `stats_collector` for http manager
- rm old grpc client
- add publish workflow
1 change: 0 additions & 1 deletion client/featureflags/__init__.py

This file was deleted.

22 changes: 0 additions & 22 deletions client/featureflags/client/compat.py

This file was deleted.

Loading