Skip to content

Commit 1657078

Browse files
authored
Remove distutils, update CI (#221)
* Remove distutils, update CI - Replace distutils with setuptools and shutil - Update README.md - Update CI to test Python 3.10 and 3.12 - Adding dependabot for GitHub actions * Update more CI, fix version number * Add Windows to CI
1 parent bb51f16 commit 1657078

File tree

7 files changed

+60
-43
lines changed

7 files changed

+60
-43
lines changed

.github/dependabot.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Set update schedule for GitHub Actions
2+
3+
version: 2
4+
updates:
5+
6+
- package-ecosystem: "github-actions"
7+
directory: "/"
8+
schedule:
9+
# Check for updates to GitHub Actions every week
10+
interval: "monthly"

.github/workflows/FMITest.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
timeout-minutes: 30
1212
strategy:
1313
matrix:
14-
python-version: ['3.10']
14+
python-version: ['3.12']
1515
os: ['ubuntu-latest', 'windows-latest']
1616
omc-version: ['stable', 'nightly']
1717

@@ -41,7 +41,7 @@ jobs:
4141
pip install future pyparsing numpy psutil pyzmq pytest pytest-md pytest-emoji
4242
4343
- name: Set timezone
44-
uses: szenius/set-timezone@v1.2
44+
uses: szenius/set-timezone@v2.0
4545
with:
4646
timezoneLinux: 'Europe/Berlin'
4747

@@ -53,4 +53,4 @@ jobs:
5353
job-summary: true
5454
custom-arguments: 'tests/test_FMIRegression.py -v'
5555
click-to-expand: true
56-
report-title: 'FMI_Export TEST REPORT'
56+
report-title: 'FMI_Export TEST REPORT'

.github/workflows/Test.yml

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,13 @@ jobs:
1212
timeout-minutes: 30
1313
strategy:
1414
matrix:
15-
python-version: ['3.10']
16-
os: ['ubuntu-latest']
15+
python-version: ['3.10', '3.12']
16+
os: ['ubuntu-latest', 'windows-latest']
1717
omc-version: ['stable']
1818

1919
steps:
2020
- uses: actions/checkout@v4
21+
2122
- name: "Set up OpenModelica Compiler"
2223
uses: OpenModelica/setup-openmodelica@v1.0
2324
with:
@@ -26,12 +27,10 @@ jobs:
2627
omc
2728
libraries: |
2829
'Modelica 4.0.0'
29-
3030
- run: "omc --version"
3131

32-
- uses: actions/checkout@v4
3332
- name: Set up Python ${{ matrix.python-version }}
34-
uses: actions/setup-python@v4
33+
uses: actions/setup-python@v5
3534
with:
3635
python-version: ${{ matrix.python-version }}
3736
architecture: 'x64'
@@ -42,7 +41,7 @@ jobs:
4241
pip install future pyparsing numpy psutil pyzmq pytest pytest-md pytest-emoji
4342
4443
- name: Set timezone
45-
uses: szenius/set-timezone@v1.2
44+
uses: szenius/set-timezone@v2.0
4645
with:
4746
timezoneLinux: 'Europe/Berlin'
4847

@@ -54,4 +53,4 @@ jobs:
5453
job-summary: true
5554
custom-arguments: '-v '
5655
click-to-expand: true
57-
report-title: 'Test Report'
56+
report-title: 'Test Report'

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,4 @@
1414
.vs/
1515
.DS_Store
1616
.vscode/
17+
/.venv/

OMPython/__init__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class which means it will use OMCSessionZMQ by default. If you want to use
3333
from future.utils import with_metaclass
3434
from builtins import int, range
3535
from copy import deepcopy
36-
from distutils import spawn
36+
import shutil
3737

3838
import abc
3939
import csv
@@ -129,10 +129,10 @@ def __init__(self):
129129
if omc_env_home:
130130
self.omhome = omc_env_home
131131
else:
132-
path_to_omc = spawn.find_executable("omc")
132+
path_to_omc = shutil.which("omc")
133133
if path_to_omc is None:
134134
raise ValueError("Cannot find OpenModelica executable, please install from openmodelica.org")
135-
self.omhome = os.path.split(os.path.split(os.path.realpath(path_to_omc))[0])[0]
135+
self.omhome = os.path.dirname(os.path.dirname(path_to_omc))
136136
def _get_omc_path(self):
137137
try:
138138
return os.path.join(self.omhome, 'bin', 'omc')

README.md

Lines changed: 28 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -31,45 +31,57 @@ Installation using `pip` is recommended.
3131

3232
Install the latest OMPython master by running:
3333

34-
python -m pip install -U https://github.com/OpenModelica/OMPython/archive/master.zip
34+
```bash
35+
python -m pip install -U https://github.com/OpenModelica/OMPython/archive/master.zip
36+
```
3537

3638
### Windows
3739

38-
Install the version as packaged with your OpenModelica installation by
39-
running:
40+
Install the version packed with your OpenModelica installation by running:
41+
42+
```cmd
43+
cd %OPENMODELICAHOME%\share\omc\scripts\PythonInterface
44+
python -m pip install -U .
45+
```
4046

41-
cd %OPENMODELICAHOME%\share\omc\scripts\PythonInterface
42-
python -m pip install -U .
47+
### Local installation
4348

44-
Instead, to Install the latest version of the OMPython master branch
49+
To Install the latest version of the OMPython master branch
4550
only, previously cloned into `<OMPythonPath>`, run:
4651

47-
cd <OMPythonPath>
48-
python -m pip install -U .
52+
```
53+
cd <OMPythonPath>
54+
python -m pip install -U .
55+
```
4956

5057
## Usage
5158

52-
Running the following commads should get you started
59+
Running the following commands should get you started
5360

54-
``` python
61+
```python
5562
import OMPython
5663
help(OMPython)
5764
```
5865

59-
or read the [OMPython
60-
documentation](https://openmodelica.org/doc/OpenModelicaUsersGuide/latest/ompython.html)
66+
```python
67+
from OMPython import OMCSessionZMQ
68+
omc = OMCSessionZMQ()
69+
omc.sendExpression("getVersion()")
70+
```
71+
72+
or read the [OMPython documentation](https://openmodelica.org/doc/OpenModelicaUsersGuide/latest/ompython.html)
6173
online.
6274

6375
## Bug Reports
6476

65-
- See OMPython bugs on the [OpenModelica
77+
- See OMPython bugs on the [OpenModelica
6678
trac](https://trac.openmodelica.org/OpenModelica/query?component=OMPython)
6779
or submit a [new
6880
ticket](https://trac.openmodelica.org/OpenModelica/newticket).
69-
- [Pull requests](https://github.com/OpenModelica/OMPython/pulls) are
81+
- [Pull requests](https://github.com/OpenModelica/OMPython/pulls) are
7082
welcome.
7183

7284
## Contact
7385

74-
- Adeel Asghar, <adeel.asghar@liu.se>
75-
- Arunkumar Palanisamy, <arunkumar.palanisamy@liu.se>
86+
- Adeel Asghar, <adeel.asghar@liu.se>
87+
- Arunkumar Palanisamy, <arunkumar.palanisamy@liu.se>

setup.py

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,19 @@
1-
try:
2-
from setuptools import setup
3-
except ImportError:
4-
from distutils.core import setup
5-
1+
from setuptools import setup
62
from subprocess import call
73
import os
8-
# Python 3.3 offers shutil.which()
9-
from distutils import spawn
10-
4+
import shutil
115

126
def warningOrError(errorOnFailure, msg):
137
if errorOnFailure:
148
raise Exception(msg)
159
else:
1610
print(msg)
1711

18-
1912
def generateIDL():
2013
errorOnFailure = not os.path.exists(os.path.join(os.path.dirname(__file__), 'OMPythonIDL', '__init__.py'))
2114
try:
22-
omhome = os.path.split(os.path.split(os.path.realpath(spawn.find_executable("omc")))[0])[0]
15+
path_to_omc = shutil.which("omc")
16+
omhome = os.path.dirname(os.path.dirname(os.path.split(path_to_omc)))
2317
except BaseException:
2418
omhome = None
2519
omhome = omhome or os.environ.get('OPENMODELICAHOME')
@@ -54,8 +48,9 @@ def generateIDL():
5448
OMPython_packages.extend(['OMPythonIDL', 'OMPythonIDL._OMCIDL', 'OMPythonIDL._OMCIDL__POA'])
5549

5650
setup(name='OMPython',
57-
version='3.5.2',
51+
version='3.6.0',
5852
description='OpenModelica-Python API Interface',
53+
long_description=open('README.md').read(),
5954
author='Anand Kalaiarasi Ganeson',
6055
author_email='ganan642@student.liu.se',
6156
maintainer='Adeel Asghar',
@@ -64,11 +59,11 @@ def generateIDL():
6459
url='http://openmodelica.org/',
6560
packages=OMPython_packages,
6661
install_requires=[
67-
# 'omniORB', # Required, but not part of pypi
6862
'future',
69-
'pyparsing',
7063
'numpy',
7164
'psutil',
65+
'pyparsing',
7266
'pyzmq'
73-
]
67+
],
68+
python_requires='>=3.8',
7469
)

0 commit comments

Comments
 (0)