diff --git a/.flake8 b/.flake8 index 4c6ab14..5d34c95 100644 --- a/.flake8 +++ b/.flake8 @@ -1,6 +1,6 @@ [flake8] per-file-ignores = */__init__.py:F401 -exclude = ['.git', '__pycache__', 'docs/source/conf.py', 'old', 'build', 'dist'] +exclude = .git,__pycache__,docs/source/conf.py,old,build,dist,.venv max-line-length = 120 count = true \ No newline at end of file diff --git a/.github/workflows/unittest.yml b/.github/workflows/unittest.yml index 17b1b74..bea6852 100644 --- a/.github/workflows/unittest.yml +++ b/.github/workflows/unittest.yml @@ -10,16 +10,29 @@ on: branches: [ "main" ] jobs: - build: + pep8: runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Set up Python 3.12 + uses: actions/setup-python@v5 + with: + python-version: 3.12 + - name: Install Python dependencies + run: | + python -m pip install poetry + poetry install --sync --with dev + - name: Lint with flake8 + run: | + poetry run flake8 . --count + test: + needs: pep8 + runs-on: ${{ matrix.os }} strategy: fail-fast: false matrix: python-version: ["3.11", "3.12"] os: [ubuntu-latest, macos-latest] - env: - OS: ${{ matrix.os }} - PYTHON: ${{ matrix.python-version }} steps: - uses: actions/checkout@v4 @@ -33,26 +46,26 @@ jobs: cd GmSSL && git checkout tags/v3.1.1 mkdir build && cd build && cmake .. make && make test && sudo make install - sudo ldconfig + if [[ "$OSTYPE" == "linux-gnu"* ]]; then + sudo ldconfig + elif [[ "$OSTYPE" == "darwin"* ]]; then + sudo update_dyld_shared_cache + fi gmssl version cd ../../ - name: Install Python dependencies run: | python -m pip install poetry poetry install --sync --with dev - - name: Lint with flake8 - run: | - # stop the build if there are Python syntax errors or undefined names - poetry run flake8 ./src --count --exit-zero - name: Test with pytest run: | - poetry run pytest --cov=src/pygmssl --cov-report=xml + poetry run pytest --cov=src --cov-report=xml - name: Upload coverage reports to Codecov uses: codecov/codecov-action@v4 with: env_vars: OS,PYTHON fail_ci_if_error: true # optional (default = false) flags: unittests - name: codecov-umbrella # optional + name: codecov-umbrella-python${{ matrix.python-version }}-${{ matrix.os }} # optional token: ${{ secrets.CODECOV_TOKEN }} verbose: true # optional (default = false) diff --git a/pyproject.toml b/pyproject.toml index 85e0e4b..e1c8b17 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,47 +1,22 @@ -[project] +[tool.poetry] name = "pygmssl" -dynamic = ["version"] -authors = [{ name = "Zhang Jie", email = "zhangj_10ujs@foxmail.com" }] -description = "A Python ctypes GmSSL implementation" +version = "0.1.0" +description = "A Python ctypes implementation of GmSSLv3.1.1" +license = "MIT" +authors = ["Zhang Jie "] +maintainers = ["Zhang Jie "] readme = "README.md" -requires-python = ">=3.10" -dependencies = ["pycryptodomex>=3.17"] -keywords=["国密", "SM2", "SM3", "SM4"] +homepage = "https://github.com/j-z10/pygmssl" +keywords=["国密", "GmSSL", "gmssl", "sm2", "sm3", "sm4"] classifiers = [ - "Development Status :: 2 - Pre-Alpha", + "Development Status :: 3 - Alpha", "Programming Language :: Python :: 3", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", ] - -[project.urls] -"Homepage" = "https://github.com/jz10ujs/pygmssl" -"Bug Tracker" = "https://github.com/jz10ujs/pygmssl/issues" - -[tool.setuptools] -packages = ["pygmssl"] - -[tool.setuptools.dynamic] -version = {attr = "pygmssl.VERSION"} - -[tool.autopep8] -indent_size = 4 -max_line_length = 120 -ignore = ["E121", "W6"] -aggressive = 3 -# in-place = true -# recursive = true - -[tool.isort] -max_line_length = 120 - -[tool.poetry] -name = "pygmssl" -version = "0.1.0" -description = "GmSSL in python ctypes" -authors = ["Zhang Jie "] -license = "GPLv3" -readme = "README.md" +packages = [ + { include = "pygmssl", from = "src" }, +] [tool.poetry.dependencies] python = "^3.11" @@ -57,3 +32,14 @@ pytest-cov = "^5.0.0" [build-system] requires = ["poetry-core"] build-backend = "poetry.core.masonry.api" + +[tool.autopep8] +indent_size = 4 +max_line_length = 120 +ignore = ["E121", "W6"] +aggressive = 3 +# in-place = true +# recursive = true + +[tool.isort] +max_line_length = 120 \ No newline at end of file diff --git a/src/pygmssl/py.typed b/src/pygmssl/py.typed new file mode 100644 index 0000000..e69de29