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

Add certifi dependency #47

Merged
merged 3 commits into from
Oct 27, 2023
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
5 changes: 3 additions & 2 deletions .github/workflows/cd-pypi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ jobs:
- name: Check if version tag and package version are equal
run: |
TAG_VERSION="${{ github.event.release.tag_name }}"
if [ ${TAG_VERSION:1} == $(cat nethsm/VERSION) ]; then exit 0; else exit 1; fi
SOURCE_VERSION="$(python3 ci-scripts/get_version.py)"
if [ ${TAG_VERSION:1} == ${SOURCE_VERSION} ]; then exit 0; else exit 1; fi
build:
name: Build
runs-on: ubuntu-latest
Expand Down Expand Up @@ -76,4 +77,4 @@ jobs:
- name: Publish release
run: |
. venv/bin/activate
flit --repository pypi publish
flit --repository pypi publish
13 changes: 13 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -101,3 +101,16 @@ jobs:
uses: codecov/codecov-action@v3
with:
files: ./coverage.xml
clean-install:
name: Try a clean install with pip
runs-on: ubuntu-latest
container: python:3.9-slim
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Create virtual environment
run: python3 -m venv venv
- name: Install package
run: venv/bin/pip install .
- name: Use package
run: venv/bin/python3 -c "import nethsm"
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ The current list of such functions is:

### Publishing a new version

- change the version in `nethsm/VERSION`. Example : 0.1.0
- change `__version__` in `nethsm/__init__.py`. Example : 0.1.0
- create a new tag, prepending `v` to the version. Example : v0.1.0
- create a new release on GitHub to trigger the ci that will publish the new version.

Expand Down
26 changes: 26 additions & 0 deletions ci-scripts/get_version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import ast

filename = "nethsm/__init__.py"
with open(filename) as f:
data = f.read()
module = ast.parse(data, filename)
assert isinstance(module, ast.Module)

values = []
for stmt in module.body:
if not isinstance(stmt, ast.Assign):
continue

is_version = False
for target in stmt.targets:
if isinstance(target, ast.Name):
if target.id == "__version__":
is_version = True
if not is_version:
continue

assert isinstance(stmt.value, ast.Constant)
values.append(stmt.value)

assert len(values) == 1
print(values[0].value)
1 change: 0 additions & 1 deletion nethsm/VERSION

This file was deleted.

10 changes: 3 additions & 7 deletions nethsm/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,20 @@
# copied, modified, or distributed except according to those terms.
"""Python Library to manage NetHSM(s)."""

import pathlib
from base64 import b64encode

import urllib3

__version_path__ = pathlib.Path(__file__).parent.resolve().absolute() / "VERSION"
__version__ = open(__version_path__).read().strip()
__version__ = "0.3.2"

import contextlib
import enum
import json
import re
from base64 import b64encode
from dataclasses import dataclass
from datetime import datetime
from io import BufferedReader
from typing import Any, Iterator, Literal, Optional, Union, cast
from urllib.parse import urlencode

import urllib3
from urllib3 import HTTPResponse, _collections
from urllib3._collections import HTTPHeaderDict

Expand Down
5 changes: 3 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@ license = {file = "LICENSE"}
classifiers = ["License :: OSI Approved :: Apache Software License"]
dynamic = ["version", "description"]
dependencies = [
"urllib3 >=2.0,<2.1",
"typing_extensions ~= 4.3.0",
"certifi",
"python-dateutil",
"typing_extensions ~= 4.3.0",
"urllib3 >=2.0,<2.1",
]

[project.urls]
Expand Down