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

feat(python pkg): modify installed method from poetry to requirement.txt #1860

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
17 changes: 8 additions & 9 deletions .github/workflows/bk-login.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,19 @@ jobs:
uses: actions/setup-python@v2
with:
python-version: "3.10"
cache: 'pip'
cache-dependency-path: 'src/bk-login/requirements_dev.txt'
- name: create idp plugin symbolic link
run: |
ln -s $(pwd)/src/idp-plugins/idp_plugins $(pwd)/src/bk-login/bklogin
- name: Install dependencies
run: pip install -r src/bk-login/requirements_dev.txt
- name: Format & Lint with ruff
run: |
pip install ruff==0.5.2
ruff format src/bk-login --config=src/bk-login/pyproject.toml --no-cache
ruff check src/bk-login --config=src/bk-login/pyproject.toml --no-cache
- name: Lint with mypy
run: |
pip install mypy==1.10.1 types-requests==2.31.0.2 types-setuptools==57.4.18 types-dataclasses==0.1.7 types-redis==3.5.18 types-PyMySQL==1.1.0.1 types-six==0.1.9 types-toml==0.1.5 types-pytz==2023.3.0.0 types-urllib3==1.26.25.14
mypy src/bk-login --config-file=src/bk-login/pyproject.toml
test:
strategy:
Expand All @@ -54,16 +56,13 @@ jobs:
uses: actions/setup-python@v4
with:
python-version: "3.10"
cache: 'pip'
cache-dependency-path: 'src/bk-login/requirements_dev.txt'
- name: create idp plugin symbolic link
run: |
ln -s $(pwd)/src/idp-plugins/idp_plugins $(pwd)/src/bk-login/bklogin
- name: Set up Poetry
uses: abatilo/[email protected]
with:
poetry-version: "1.6.1"
- name: Install dependencies
working-directory: src/bk-login
run: poetry install
run: pip install -r src/bk-login/requirements_dev.txt
- name: Run unittest
working-directory: src/bk-login
run: |
Expand All @@ -77,4 +76,4 @@ jobs:
export MYSQL_PASSWORD=root_pwd
export MYSQL_HOST="127.0.0.1"
export DJANGO_SETTINGS_MODULE=bklogin.settings
poetry run pytest ./tests
pytest ./tests
17 changes: 8 additions & 9 deletions .github/workflows/bk-user.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,19 @@ jobs:
uses: actions/setup-python@v5
with:
python-version: "3.10"
cache: 'pip'
cache-dependency-path: 'src/bk-user/requirements_dev.txt'
- name: create idp plugin symbolic link
run: |
ln -s $(pwd)/src/idp-plugins/idp_plugins $(pwd)/src/bk-user/bkuser
- name: Install dependencies
run: pip install -r src/bk-user/requirements_dev.txt
- name: Format & Lint with ruff
run: |
pip install ruff==0.5.2
ruff format src/bk-user --config=src/bk-user/pyproject.toml --no-cache
ruff check src/bk-user --config=src/bk-user/pyproject.toml --no-cache
- name: Lint with mypy
run: |
pip install mypy==1.10.1 types-requests==2.31.0.2 types-setuptools==57.4.18 types-dataclasses==0.1.7 types-redis==3.5.18 types-PyMySQL==1.1.0.1 types-six==0.1.9 types-toml==0.1.5 types-pytz==2023.3.0.0 types-urllib3==1.26.25.14
mypy src/bk-user --config-file=src/bk-user/pyproject.toml
test:
strategy:
Expand All @@ -54,16 +56,13 @@ jobs:
uses: actions/setup-python@v5
with:
python-version: "3.10"
cache: 'pip'
cache-dependency-path: 'src/bk-user/requirements_dev.txt'
- name: create idp plugin symbolic link
run: |
ln -s $(pwd)/src/idp-plugins/idp_plugins $(pwd)/src/bk-user/bkuser
- name: Set up Poetry
uses: abatilo/[email protected]
with:
poetry-version: "1.5.1"
- name: Install dependencies
working-directory: src/bk-user
run: poetry install
run: pip install -r src/bk-user/requirements_dev.txt
- name: Run unittest
working-directory: src/bk-user
run: |
Expand All @@ -79,4 +78,4 @@ jobs:
export INITIAL_ADMIN_USERNAME=admin
export INITIAL_ADMIN_PASSWORD=admin_pwd
export DJANGO_SETTINGS_MODULE=bkuser.settings
poetry run pytest ./tests
pytest ./tests
6 changes: 4 additions & 2 deletions .github/workflows/idp-plugins.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,14 @@ jobs:
uses: actions/setup-python@v2
with:
python-version: "3.10"
cache: 'pip'
cache-dependency-path: 'src/idp-plugins/requirements_dev.txt'
- name: Install dependencies
run: pip install -r src/idp-plugins/requirements_dev.txt
- name: Format & Lint with ruff
run: |
pip install ruff==0.1.4
ruff format src/idp-plugins --config=src/idp-plugins/pyproject.toml --no-cache
ruff src/idp-plugins --config=src/idp-plugins/pyproject.toml --no-cache
- name: Lint with mypy
run: |
pip install mypy==1.6.1 types-requests==2.31.0.2 types-setuptools==57.4.18 types-dataclasses==0.1.7 types-redis==3.5.18 types-PyMySQL==1.1.0.1 types-six==0.1.9 types-toml==0.1.5 types-pytz==2023.3.0.0 types-urllib3==1.26.25.14
mypy src/idp-plugins --config-file=src/idp-plugins/pyproject.toml
39 changes: 38 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ repos:
.*/\.env|
.*/poetry\.lock|
.*/pyproject\.toml|
.*/requirements_dev\.txt|
\.github/workflows/bk-user.yml|
\.github/workflows/bk-login.yml|
\.github/workflows/idp-plugins.yml|
Expand Down Expand Up @@ -74,6 +75,18 @@ repos:
require_serial: true
language: system
entry: bash -c "cd src/bk-user && lint-imports"
- id: requirements-export
name: requirements-export
language: system
entry: bash -c "cd src/bk-user && poetry export -f requirements.txt --output requirements.txt --without-hashes"
pass_filenames: false
files: ^src/bk-user/poetry.lock$
- id: requirements-dev-export
name: requirements-dev-export
language: system
entry: bash -c "cd src/bk-user && poetry export --with dev -f requirements.txt --output requirements_dev.txt --without-hashes"
pass_filenames: false
files: ^src/bk-user/poetry.lock$
- repo: local
hooks:
- id: format
Expand All @@ -99,6 +112,18 @@ repos:
require_serial: true
language: system
entry: bash -c "cd src/bk-login && lint-imports"
- id: requirements-export
name: requirements-export
language: system
entry: bash -c "cd src/bk-login && poetry export -f requirements.txt --output requirements.txt --without-hashes"
pass_filenames: false
files: ^src/bk-login/poetry.lock$
- id: requirements-dev-export
name: requirements-dev-export
language: system
entry: bash -c "cd src/bk-login && poetry export --with dev -f requirements.txt --output requirements_dev.txt --without-hashes"
pass_filenames: false
files: ^src/bk-login/poetry.lock$
- repo: local
hooks:
- id: format
Expand All @@ -111,11 +136,23 @@ repos:
name: ruff
language: python
types: [python]
entry: ruff --config=src/idp-plugins/pyproject.toml --fix --no-cache
entry: ruff check --config=src/idp-plugins/pyproject.toml --fix --no-cache
files: src/idp-plugins/
- id: mypy
name: mypy
language: python
types: [python]
entry: mypy --config-file=src/idp-plugins/pyproject.toml
files: src/idp-plugins/
- id: requirements-export
name: requirements-export
language: system
entry: bash -c "cd src/idp-plugins && poetry export -f requirements.txt --output requirements.txt --without-hashes"
pass_filenames: false
files: ^src/idp-plugins/poetry.lock$
- id: requirements-dev-export
name: requirements-dev-export
language: system
entry: bash -c "cd src/idp-plugins && poetry export --with dev -f requirements.txt --output requirements_dev.txt --without-hashes"
pass_filenames: false
files: ^src/idp-plugins/poetry.lock$
6 changes: 2 additions & 4 deletions src/bk-login/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,10 @@ ENV LC_ALL=C.UTF-8 \
LANG=C.UTF-8

RUN pip install --upgrade pip setuptools
RUN pip install poetry==1.5.1

WORKDIR /app
COPY src/bk-login/pyproject.toml /app
COPY src/bk-login/poetry.lock /app
RUN poetry config virtualenvs.create false && poetry install --no-cache --only main
COPY src/bk-login/requirements.txt /app
RUN pip install -r requirements.txt

COPY src/bk-login/bklogin /app/bklogin
COPY src/bk-login/bin /app/bin
Expand Down
16 changes: 10 additions & 6 deletions src/bk-login/bklogin/component/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
specific language governing permissions and limitations under the License.
"""

import logging
import time
from typing import Dict, Tuple
Expand Down Expand Up @@ -127,12 +128,15 @@ def _http_request(method: str, url: str, **kwargs) -> Tuple[HttpStatusCode, Dict
resp.status_code,
content,
)
return INVALID_JSON_STATUS_CODE, {
"error": (
f"http response body not json, http status code is {resp.status_code}! "
f"{method} {urlparse(url).path}, response.body={content}, error:{e}"
)
}
return (
INVALID_JSON_STATUS_CODE,
{
"error": (
f"http response body not json, http status code is {resp.status_code}! " # type: ignore
f"{method} {urlparse(url).path}, response.body={content}, error:{e}"
)
},
)


def _http_request_only_20x(method: str, url: str, **kwargs) -> Tuple[bool, Dict]:
Expand Down
77 changes: 77 additions & 0 deletions src/bk-login/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
--index-url https://mirrors.tencent.com/pypi/simple

annotated-types==0.7.0 ; python_version >= "3.10" and python_version < "3.11"
asgiref==3.8.1 ; python_version >= "3.10" and python_version < "3.11"
bk-crypto-python-sdk==1.1.1 ; python_version >= "3.10" and python_version < "3.11"
bk-notice-sdk==1.3.2 ; python_version >= "3.10" and python_version < "3.11"
bkapi-client-core==1.2.0 ; python_version >= "3.10" and python_version < "3.11"
blue-krill==2.0.3 ; python_version >= "3.10" and python_version < "3.11"
certifi==2024.7.4 ; python_version >= "3.10" and python_version < "3.11"
cffi==1.16.0 ; python_version >= "3.10" and python_version < "3.11"
charset-normalizer==3.3.2 ; python_version >= "3.10" and python_version < "3.11"
click==8.1.7 ; python_version >= "3.10" and python_version < "3.11"
colorama==0.4.6 ; python_version >= "3.10" and python_version < "3.11" and platform_system == "Windows"
concurrent-log-handler==0.9.25 ; python_version >= "3.10" and python_version < "3.11"
cryptography==43.0.0 ; python_version >= "3.10" and python_version < "3.11"
curlify==2.2.1 ; python_version >= "3.10" and python_version < "3.11"
dacite==1.8.1 ; python_version >= "3.10" and python_version < "3.11"
deprecated==1.2.14 ; python_version >= "3.10" and python_version < "3.11"
django-cors-headers==4.3.0 ; python_version >= "3.10" and python_version < "3.11"
django-environ==0.8.1 ; python_version >= "3.10" and python_version < "3.11"
django-prometheus==2.3.1 ; python_version >= "3.10" and python_version < "3.11"
django==3.2.25 ; python_version >= "3.10" and python_version < "3.11"
gevent==23.9.1 ; python_version >= "3.10" and python_version < "3.11"
googleapis-common-protos==1.63.2 ; python_version >= "3.10" and python_version < "3.11"
greenlet==3.0.3 ; platform_python_implementation == "CPython" and python_version < "3.11" and python_version >= "3.10"
grpcio==1.65.1 ; python_version >= "3.10" and python_version < "3.11"
gunicorn==21.2.0 ; python_version >= "3.10" and python_version < "3.11"
idna==3.7 ; python_version >= "3.10" and python_version < "3.11"
importlib-metadata==7.1.0 ; python_version >= "3.10" and python_version < "3.11"
markupsafe==2.1.5 ; python_version >= "3.10" and python_version < "3.11"
mysqlclient==2.2.4 ; python_version >= "3.10" and python_version < "3.11"
opentelemetry-api==1.25.0 ; python_version >= "3.10" and python_version < "3.11"
opentelemetry-exporter-otlp-proto-common==1.25.0 ; python_version >= "3.10" and python_version < "3.11"
opentelemetry-exporter-otlp-proto-grpc==1.25.0 ; python_version >= "3.10" and python_version < "3.11"
opentelemetry-exporter-otlp-proto-http==1.25.0 ; python_version >= "3.10" and python_version < "3.11"
opentelemetry-exporter-otlp==1.25.0 ; python_version >= "3.10" and python_version < "3.11"
opentelemetry-instrumentation-celery==0.46b0 ; python_version >= "3.10" and python_version < "3.11"
opentelemetry-instrumentation-dbapi==0.46b0 ; python_version >= "3.10" and python_version < "3.11"
opentelemetry-instrumentation-django==0.46b0 ; python_version >= "3.10" and python_version < "3.11"
opentelemetry-instrumentation-logging==0.46b0 ; python_version >= "3.10" and python_version < "3.11"
opentelemetry-instrumentation-redis==0.46b0 ; python_version >= "3.10" and python_version < "3.11"
opentelemetry-instrumentation-requests==0.46b0 ; python_version >= "3.10" and python_version < "3.11"
opentelemetry-instrumentation-wsgi==0.46b0 ; python_version >= "3.10" and python_version < "3.11"
opentelemetry-instrumentation==0.46b0 ; python_version >= "3.10" and python_version < "3.11"
opentelemetry-proto==1.25.0 ; python_version >= "3.10" and python_version < "3.11"
opentelemetry-sdk==1.25.0 ; python_version >= "3.10" and python_version < "3.11"
opentelemetry-semantic-conventions==0.46b0 ; python_version >= "3.10" and python_version < "3.11"
opentelemetry-util-http==0.46b0 ; python_version >= "3.10" and python_version < "3.11"
packaging==24.1 ; python_version >= "3.10" and python_version < "3.11"
portalocker==2.10.1 ; python_version >= "3.10" and python_version < "3.11"
prometheus-client==0.20.0 ; python_version >= "3.10" and python_version < "3.11"
protobuf==4.25.4 ; python_version >= "3.10" and python_version < "3.11"
pycparser==2.22 ; python_version >= "3.10" and python_version < "3.11"
pycryptodomex==3.20.0 ; python_version >= "3.10" and python_version < "3.11"
pydantic-core==2.6.3 ; python_version >= "3.10" and python_version < "3.11"
pydantic==2.3.0 ; python_version >= "3.10" and python_version < "3.11"
pyjwt==2.8.0 ; python_version >= "3.10" and python_version < "3.11"
python-editor==1.0.4 ; python_version >= "3.10" and python_version < "3.11"
python-json-logger==2.0.7 ; python_version >= "3.10" and python_version < "3.11"
pytz==2024.1 ; python_version >= "3.10" and python_version < "3.11"
pywin32==306 ; python_version >= "3.10" and python_version < "3.11" and platform_system == "Windows"
requests==2.31.0 ; python_version >= "3.10" and python_version < "3.11"
sentry-sdk==1.5.6 ; python_version >= "3.10" and python_version < "3.11"
setuptools==71.1.0 ; python_version >= "3.10" and python_version < "3.11"
six==1.16.0 ; python_version >= "3.10" and python_version < "3.11"
sqlparse==0.5.1 ; python_version >= "3.10" and python_version < "3.11"
toml==0.10.2 ; python_version >= "3.10" and python_version < "3.11"
tongsuopy-crayon==1.0.2b6 ; python_version >= "3.10" and python_version < "3.11"
typing-extensions==4.12.2 ; python_version >= "3.10" and python_version < "3.11"
urllib3==2.2.2 ; python_version >= "3.10" and python_version < "3.11"
watchdog==1.0.2 ; python_version >= "3.10" and python_version < "3.11"
werkzeug==3.0.2 ; python_version >= "3.10" and python_version < "3.11"
whitenoise==6.5.0 ; python_version >= "3.10" and python_version < "3.11"
wrapt==1.16.0 ; python_version >= "3.10" and python_version < "3.11"
zipp==3.19.2 ; python_version >= "3.10" and python_version < "3.11"
zope-event==5.0 ; python_version >= "3.10" and python_version < "3.11"
zope-interface==6.4.post2 ; python_version >= "3.10" and python_version < "3.11"
Loading
Loading