Skip to content

Commit

Permalink
Merge pull request #144 from Starry-OvO/develop
Browse files Browse the repository at this point in the history
v3.7.2
  • Loading branch information
lumina37 authored Aug 31, 2023
2 parents d8f6583 + 22d6bf4 commit 2118b9b
Show file tree
Hide file tree
Showing 16 changed files with 102 additions and 51 deletions.
14 changes: 3 additions & 11 deletions .github/workflows/Pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,26 +20,18 @@ jobs:
build:
runs-on: ubuntu-latest

env:
PYTHON_VER: "3.11"

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Setup Python ${{ env.PYTHON_VER }}
uses: actions/setup-python@v4
with:
python-version: ${{ env.PYTHON_VER }}

- name: Install dependencies
run: |
pip install -U pip -qq
pip install mkdocs-material mkdocstrings[python] -qq
pipx install pdm
pdm install -G doc --no-default --no-self
- name: Build
run: |
mkdocs build -d site -s
pdm run mkdocs build -d site -s
- name: Upload Artifact
uses: actions/upload-pages-artifact@v2
Expand Down
51 changes: 24 additions & 27 deletions .github/workflows/Publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,56 +17,53 @@ jobs:
steps:
- uses: actions/checkout@v3

- uses: actions/setup-python@v4
with:
python-version: "3.x"

- name: Install cibuildwheel
run: pip install cibuildwheel -qq

- name: Build wheels
run: python -m cibuildwheel --output-dir wheelhouse
uses: pypa/cibuildwheel@v2.15.0
env:
CIBW_BUILD: "cp38-* cp39-* cp310-* cp311-* pp38-* pp39-*"
CIBW_BUILD: "cp38-* cp39-* cp310-* cp311-* pp38-* pp39-* pp310-*"
CIBW_SKIP: "*-win32 *_i686 *_s390x *_ppc64le"

- uses: actions/upload-artifact@v3
with:
name: dist
path: ./wheelhouse/*.whl

build_sdist:
name: Build source distribution
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Build sdist
run: pipx run build --sdist

- uses: actions/upload-artifact@v3
with:
path: dist/*.tar.gz

publish:
name: Publish
needs: build_wheels
needs: [build_wheels, build_sdist]
runs-on: ubuntu-latest

environment:
name: publish
name: pypi

env:
PYTHON_VER: "3.11"
permissions:
id-token: write

steps:
- name: Set up Python ${{ env.PYTHON_VER }}
uses: actions/setup-python@v4
with:
python-version: ${{ env.PYTHON_VER }}

- name: Install dependencies
run: |
python -m pip install -U pip -qq
pip install -U twine -qq
- name: Download distributions
uses: actions/download-artifact@v3
with:
name: dist
name: artifact
path: dist

- name: Publish to PyPI
if: ${{ github.event_name == 'push' }}
run: twine upload dist/* -u __token__ -p ${{ secrets.PYPI_TOKEN }} --disable-progress-bar
uses: pypa/gh-action-pypi-publish@release/v1

- name: Publish to TestPyPI
if: ${{ github.event_name == 'workflow_dispatch' }}
run: twine upload -r testpypi dist/* -u __token__ -p ${{ secrets.TESTPYPI_TOKEN }} --disable-progress-bar
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: https://test.pypi.org/legacy/
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
!docs/**
!tests
!tests/**
!scripts
!scripts/**

*.py[cd]
__pycache__
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
<a href="https://pypi.org/project/aiotieba">
<img src="https://img.shields.io/pypi/pyversions/aiotieba?style=flat-square" alt="PyPI - Python Version">
</a>
</a>
<a href="https://pdm.fming.dev">
<img src="https://img.shields.io/badge/pdm-managed-blueviolet?style=flat-square" alt="pdm-managed">
</a>
</p>
</div>

Expand Down
2 changes: 1 addition & 1 deletion aiotieba/__version__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "3.7.1"
__version__ = "3.7.2"
2 changes: 1 addition & 1 deletion aiotieba/api/get_bawu_postlogs/_classdef.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ def __init__(self, data_tag: bs4.element.Tag) -> None:

text_item = post_content_item.div
self._text = text_item.string[12:]
self._medias = [Media_postlog(tag) for tag in text_item.next_sibling('a')]
self._medias = [Media_postlog(tag) for tag in text_item.next_sibling('a', class_=None)]

op_type_item = left_cell_item.next_sibling
self._op_type = op_type_item.string
Expand Down
2 changes: 1 addition & 1 deletion aiotieba/api/get_forum_detail/_classdef.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def __init__(self, data_proto: Optional[TypeMessage] = None) -> None:
self._slogan = forum_proto.slogan
self._member_num = forum_proto.member_count
self._post_num = forum_proto.thread_count
self._has_bawu = bool(data_proto.election_tab.new_manager_status)
self._has_bawu = data_proto.election_tab.new_manager_status == 5
else:
self._fid = 0
self._fname = ''
Expand Down
2 changes: 1 addition & 1 deletion aiotieba/const.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
MAIN_VERSION = "12.45.7.0"
MAIN_VERSION = "12.46.3.0"
POST_VERSION = "12.35.1.0"

APP_SECURE_SCHEME = "https"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

#define PY_SSIZE_T_CLEAN // use Py_ssize_t instead of int

#ifdef TBC_FORCE_PYTHON_NODEBUG
#ifdef TBC_PYTHON_DEBUG
#include <Python.h>
#else
#ifdef _DEBUG
#undef _DEBUG // use these steps to avoid linking with python_d.lib
#define __TBC_RESTORE_DEBUG
Expand All @@ -12,6 +14,4 @@
#define _DEBUG
#undef __TBC_RESTORE_DEBUG
#endif
#else
#include <Python.h>
#endif
2 changes: 1 addition & 1 deletion aiotieba/helper/crypto/include/tbcrypto/sign.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#pragma once

#include "tbcrypto/_python.h"
#include "tbcrypto/pywrap.h"

PyObject* sign(PyObject* Py_UNUSED(self), PyObject* args);
4 changes: 2 additions & 2 deletions aiotieba/helper/crypto/src/tbcrypto/lib.c
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#include "tbcrypto/_python.h"
#include "tbcrypto/pywrap.h"

#include "tbcrypto/const.h"
#include "tbcrypto/cuid.h"
#include "tbcrypto/error.h"
#include "tbcrypto/rc442.h"
#include "tbcrypto/sign.h"
#include "tbcrypto/zid.h"

PyObject* cuid_galaxy2(PyObject* Py_UNUSED(self), PyObject* args)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include "tbcrypto/const.h"
#include "tbcrypto/error.h"

#include "tbcrypto/zid.h"
#include "tbcrypto/rc442.h"

typedef struct rc4_42_context {
int x;
Expand Down
4 changes: 4 additions & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@
<a href="https://pypi.org/project/aiotieba">
<img src="https://img.shields.io/pypi/pyversions/aiotieba?style=flat-square" alt="PyPI - Python Version">
</a>
</a>
<a href="https://pdm.fming.dev">
<img src="https://img.shields.io/badge/pdm-managed-blueviolet?style=flat-square" alt="pdm-managed">
</a>
</p>

---
Expand Down
8 changes: 6 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,15 @@ version = { attr = "aiotieba.__version__.__version__" }
[tool.setuptools.package-data]
"*" = ["*.pyi"]

[tool.pdm.dev-dependencies]
lint = ["ruff", "black"]
test = ["aiotieba[speedup]", "pytest", "pytest-asyncio", "pytest-rerunfailures"]
doc = ["mkdocs-material", "mkdocstrings[python]"]

[tool.black]
line-length = 120
skip-string-normalization = true
target-version = ["py38"]
target-version = ["py38", "py39", "py310", "py311"]

[tool.ruff]
line-length = 120
Expand All @@ -86,7 +91,6 @@ target-version = "py38"
"*_pb2.py" = ["F401"]

[tool.pytest.ini_options]
minversion = "6.0"
addopts = "-q"
testpaths = ["tests"]
required_plugins = "pytest-asyncio pytest-rerunfailures"
Expand Down
48 changes: 48 additions & 0 deletions scripts/proto_compile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import subprocess
from pathlib import Path

commom_proto_pth = Path("aiotieba/api/_protobuf")

for fpth in commom_proto_pth.glob('*_pb2.py'):
fpth.unlink()

subprocess.run("protoc --python_out=. *.proto", cwd=str(commom_proto_pth), check=True, timeout=60.0)

for fpth in commom_proto_pth.glob('*_pb2.py'):
bak_fpth = fpth.with_suffix('.bak')
with (
fpth.open('r') as f,
bak_fpth.open('w') as bak_f,
):
for row in f.readlines():
if row.startswith('#'):
continue
if row.startswith('import'):
row = "from . " + row
bak_f.write(row)
fpth.unlink()
bak_fpth.rename(fpth)

for mod_pth in Path("aiotieba/api").glob('*/protobuf'):
for fpth in mod_pth.glob('*_pb2.py'):
fpth.unlink()

subprocess.run("protoc -I../../_protobuf -I. --python_out=. *.proto", cwd=str(mod_pth), check=True, timeout=10.0)

for fpth in mod_pth.glob('*_pb2.py'):
bak_fpth = fpth.with_suffix('.bak')
with (
fpth.open('r') as f,
bak_fpth.open('w') as bak_f,
):
for row in f.readlines():
if row.startswith('#'):
continue
if row.startswith('import'):
row = "from ..._protobuf " + row
bak_f.write(row)
fpth.unlink()
bak_fpth.rename(fpth)

subprocess.run("ruff . --fix", cwd='.', check=False, timeout=10.0)
subprocess.run("black .", cwd='.', check=False, timeout=30.0)

0 comments on commit 2118b9b

Please sign in to comment.