Skip to content

Commit 7268b79

Browse files
authored
Merge pull request #38 from smolvik1/master
Modernize packaging and dependencies
2 parents 840d27f + 80fc487 commit 7268b79

8 files changed

Lines changed: 347 additions & 211 deletions

File tree

.github/workflows/cd.yml

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: Deploy to PyPi
22
on:
33
release:
4-
types: [created]
4+
types: [published]
55
jobs:
66
upload:
77
environment:
@@ -15,20 +15,16 @@ jobs:
1515
steps:
1616
- name: "Check out code"
1717
uses: actions/checkout@v3
18-
19-
- name: "Set up Python"
20-
uses: actions/setup-python@v4
21-
with:
22-
python-version: 3.9
23-
24-
- name: "Install dependencies"
25-
run: |
26-
python3 -m pip install --upgrade pip
27-
python3 -m pip install poetry
2818

29-
- name: "Build distributions"
30-
run: |
31-
poetry build
19+
- name: "Set up uv"
20+
uses: astral-sh/setup-uv@v3
21+
with:
22+
python-version: "3.11"
23+
24+
- name: "Build distributions"
25+
run: |
26+
uv build
27+
uv tool run twine check dist/*
3228
3329
- name: "Publish package distributions to PyPI"
3430
uses: pypa/gh-action-pypi-publish@release/v1

.github/workflows/ci.yml

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,23 +21,19 @@ jobs:
2121
steps:
2222
- name: "Check out code"
2323
uses: actions/checkout@v3
24-
25-
- name: "Set up Python"
26-
uses: actions/setup-python@v4
27-
with:
28-
python-version: 3.9
29-
30-
- name: "Installs dependencies"
31-
run: |
32-
python -m pip install --upgrade pip
33-
python -m pip install poetry twine
34-
24+
25+
- name: "Set up uv"
26+
uses: astral-sh/setup-uv@v3
27+
with:
28+
python-version: "3.11"
29+
3530
- name: "Build distribution"
3631
run: |
37-
poetry build
38-
twine check dist/*
32+
uv build
33+
uv tool run twine check dist/*
3934
4035
- name: "Publish package distributions to PyPI Test"
36+
if: github.event_name != 'pull_request'
4137
uses: pypa/gh-action-pypi-publish@release/v1
4238
with:
4339
repository-url: https://test.pypi.org/legacy/

.gitignore

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,8 @@ sdist/
1010
.vscode/
1111

1212
# pytest
13-
.pytest*/
13+
.pytest*/
14+
15+
# Environment
16+
.venv/
17+
venv/

changelog.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
## 1.153
2+
* Switched packaging and dependency management from Poetry to uv
3+
* Updated CI/CD pipelines to use Python 3.11 and uv
4+
* Expanded supported Python versions from 3.9 through 3.13
5+
16
## 1.152
27
* Added automatic versioning information from pyproject.toml
38

openserver/openserver.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
import win32com.client
22
import numpy as np
33
import pythoncom
4+
from typing import Any
45

56
class OpenServer:
67
def __init__(self):
78
self.status = "Disconnected"
8-
self.server = None
9+
self.server: Any = None
910

1011
def __enter__(self):
1112
"""
@@ -35,7 +36,7 @@ def connect(self, com='PX32.OpenServer.1'):
3536
try:
3637
self.server = win32com.client.Dispatch(com)
3738
self.status = "Connected"
38-
return print("OpenServer is connected")
39+
print("OpenServer is connected")
3940
except pythoncom.com_error:
4041
raise ConnectionError("Unable to establish a connection") from None
4142

@@ -45,7 +46,7 @@ def disconnect(self):
4546
"""
4647
self.server = None
4748
self.status = "Disconnected"
48-
return print("OpenServer has been disconnected")
49+
print("OpenServer has been disconnected")
4950

5051
def DoCmd(self, Cmd):
5152
"""
@@ -125,9 +126,12 @@ def DoGet(self, Gv):
125126
value = int(value)
126127
elif '|' in value: # Checking if | in string is returned
127128
if any(x in Gv for x in (',', '[$]', '@', ':')):
128-
num_array = np.fromstring(value[0:-1], sep="|", dtype=float)
129129
str_array = np.array(value[0:-1].split('|'))
130-
if num_array.size == str_array.size:
130+
try:
131+
num_array = str_array.astype(float)
132+
except ValueError:
133+
num_array = np.array([])
134+
if num_array.size == str_array.size:
131135
value = num_array # Return numeric array
132136
else:
133137
value = str_array # Return an array of strings

poetry.lock

Lines changed: 0 additions & 165 deletions
This file was deleted.

pyproject.toml

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,25 @@
1-
[tool.poetry]
1+
[project]
22
name = "openserver"
3-
version = "1.152"
3+
version = "1.153"
44
description = "Petroleum Experts OpenServer calculations"
5-
authors = ["Stian Molvik <stimo@equinor.com>"]
6-
license = "GNU GPL"
5+
authors = [{ name = "Stian Molvik", email = "stimo@equinor.com" }]
6+
license = { text = "GNU GPL" }
77
readme = "README.md"
8+
requires-python = ">=3.9,<3.14"
9+
dependencies = [
10+
"pywin32>=307",
11+
"numpy>=1.26.1; python_version < '3.13'",
12+
"numpy>=2.1; python_version >= '3.13'",
13+
]
814

9-
[tool.poetry.dependencies]
10-
python = ">=3.9,<3.13"
11-
pywin32 = "^306"
12-
numpy = "^1.26.1"
13-
14-
[tool.poetry.group.dev.dependencies]
15-
pytest = "^7.4.3"
15+
[dependency-groups]
16+
dev = [
17+
"pytest>=7.4.3,<8",
18+
]
1619

1720
[build-system]
18-
requires = ["poetry-core"]
19-
build-backend = "poetry.core.masonry.api"
21+
requires = ["hatchling"]
22+
build-backend = "hatchling.build"
23+
24+
[tool.hatch.build.targets.wheel]
25+
packages = ["openserver"]

0 commit comments

Comments
 (0)