Skip to content

Commit

Permalink
Squashed commit of the following:
Browse files Browse the repository at this point in the history
commit e06f125
Author: Kefei Mo <[email protected]>
Date:   Thu Oct 31 10:20:15 2024 -0500

    clean-up

commit 23e0856
Author: Kefei Mo <[email protected]>
Date:   Tue Oct 29 20:40:01 2024 -0500

    needs to run the tests separately.

commit 58f44ef
Author: Kefei Mo <[email protected]>
Date:   Tue Oct 29 18:00:43 2024 -0500

    flaky tests watch out

commit 5fddd62
Author: Kefei Mo <[email protected]>
Date:   Tue Oct 29 17:28:56 2024 -0500

    fixed result_master = master_new.soe_handler.db

commit 5b899e1
Author: Kefei Mo <[email protected]>
Date:   Tue Oct 29 16:52:03 2024 -0500

    manually fixed connection error

commit c766646
Author: Kefei Mo <[email protected]>
Date:   Tue Oct 29 15:23:17 2024 -0500

    cleaned up

commit 214ef87
Author: Kefei Mo <[email protected]>
Date:   Tue Oct 29 14:44:27 2024 -0500

    refactored to use station_application

commit 5c49385
Author: Kefei Mo <[email protected]>
Date:   Tue Oct 29 12:10:33 2024 -0500

    refactored to use outstation_app

commit 644c0d0
Author: Kefei Mo <[email protected]>
Date:   Mon Oct 28 16:51:50 2024 -0500

    from __future__ import annotations

commit 5a8108e
Author: Kefei Mo <[email protected]>
Date:   Mon Oct 28 16:28:59 2024 -0500

    improved print out db as a screenshot

commit 0513cc1
Author: Kefei Mo <[email protected]>
Date:   Mon Oct 28 12:19:56 2024 -0500

    refactored dnp3station, testing, db size, dnp3demo

commit e28bb34
Author: Kefei Mo <[email protected]>
Date:   Mon Oct 28 11:18:59 2024 -0500

    added testing outstation.

commit ca1e2d3
Author: Kefei Mo <[email protected]>
Date:   Thu Oct 24 14:10:03 2024 -0500

    pybind11 roll back

commit 1914a5d
Author: Kefei Mo <[email protected]>
Date:   Thu Oct 24 14:05:55 2024 -0500

    independent github workflow

commit aa57fad
Author: Kefei Mo <[email protected]>
Date:   Thu Oct 24 13:53:04 2024 -0500

    optimized github action workflow

commit 0ce490c
Author: Kefei Mo <[email protected]>
Date:   Thu Oct 24 13:46:06 2024 -0500

    added "pip install pytest"

commit 9eb6438
Author: Kefei Mo <[email protected]>
Date:   Thu Oct 24 13:38:51 2024 -0500

    rename

commit 2f54a28
Author: Kefei Mo <[email protected]>
Date:   Thu Oct 24 13:34:57 2024 -0500

    pytest -s -vv /tests/test_dnp3_python/*

commit 7c6292d
Author: Kefei Mo <[email protected]>
Date:   Thu Oct 24 13:28:08 2024 -0500

    added

commit 6f6b2b2
Author: Kefei Mo <[email protected]>
Date:   Thu Oct 24 13:26:05 2024 -0500

    added test_master

commit 3e4f049
Author: Kefei Mo <[email protected]>
Date:   Wed Oct 23 16:44:56 2024 -0500

    added fixture testing

commit fe6699f
Author: Kefei Mo <[email protected]>
Date:   Wed Oct 23 13:55:18 2024 -0500

    modified install-package.yml

commit 5ce38de
Author: Kefei Mo <[email protected]>
Date:   Wed Oct 23 13:48:23 2024 -0500

    fiexed 3.10 considered as 3.1 in github action

commit 3782b47
Author: Kefei Mo <[email protected]>
Date:   Wed Oct 23 13:45:00 2024 -0500

    added Install Package Test for github action

commit 2fe0c2b
Author: Kefei Mo <[email protected]>
Date:   Wed Oct 23 13:38:01 2024 -0500

    added test_insatllation, added __version__

commit 29590af
Author: Kefei Mo <[email protected]>
Date:   Wed Oct 23 11:21:34 2024 -0500

    rebase from v0.2.3b10

commit 1617afc
Author: Kefei Mo <[email protected]>
Date:   Wed Sep 18 15:33:53 2024 -0500

    adding new OutStationApplication class for beter usability

commit 1a1fda2
Author: Kefei Mo <[email protected]>
Date:   Wed Aug 21 16:57:44 2024 -0500

    added notes to ScanAllObjects to improve readability

commit dd534a8
Author: Kefei Mo <[email protected]>
Date:   Wed Aug 21 14:14:35 2024 -0500

    added example for Measure(value, flags, dnp3time) in data_retrieval_demo

commit 270637c
Author: Kefei Mo <[email protected]>
Date:   Mon Aug 12 09:56:13 2024 -0500

    added notebook

commit 97780a0
Author: Kefei Mo <[email protected]>
Date:   Wed Aug 7 17:21:36 2024 -0500

    mapped to pnnl database schema

commit 9c6888a
Author: Kefei Mo <[email protected]>
Date:   Wed Aug 7 13:28:29 2024 -0500

    added cmd sub-command to allow config db sizes.
  • Loading branch information
kefeimo committed Oct 31, 2024
1 parent c26c3c2 commit 1ee1987
Show file tree
Hide file tree
Showing 22 changed files with 2,153 additions and 526 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/deploy-pre-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: [ '3.8', '3.9', '3.10' , '3.11']
python-version: [ '3.8', '3.9', '3.10' ] # 3.11+ not suppport
steps:
- run: echo "🎉 The job was automatically triggered by a ${{ github.event_name }} event."
- run: echo "🐧 This job is now running on a ${{ runner.os }} server hosted by GitHub!"
Expand Down
47 changes: 47 additions & 0 deletions .github/workflows/install-package.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Install Package Test

on:
push:
branches:
- main
- develop
pull_request:
branches:
- main
- develop

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.9", "3.10"]

steps:
- uses: actions/checkout@v2
name: Check out repository code
with:
submodules: recursive # Ensures submodules are checked out

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m venv env
source env/bin/activate
- name: Install and Test Package
run: |
pip install cmake # Install CMake
python setup.py install
python -c "import dnp3_python; print(dnp3_python)"
env:
PYTHONPATH: ${{ github.workspace }}

- name: Clean up
if: always()
run: rm -rf env
54 changes: 54 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Pytests

on:
push:
branches:
- main
- develop
pull_request:
branches:
- main
- develop

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.9", "3.10"]

steps:
- uses: actions/checkout@v2
name: Check out repository code
with:
submodules: recursive # Ensures submodules are checked out

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m venv env
source env/bin/activate
- name: Install and Test Package
run: |
pip install cmake # Install CMake
python setup.py install
python -c "import dnp3_python; print(dnp3_python)"
env:
PYTHONPATH: ${{ github.workspace }}

- name: Run Tests
run: |
pip install pytest
for file in tests/test_dnp3_python/test_*.py; do echo "Running pytest on $file"; pytest -s -vv $file; done # Note: the file needs to run separately.
env:
PYTHONPATH: ${{ github.workspace }}

- name: Clean up
if: always()
run: rm -rf env
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ __pycache__/

# Distribution / packaging
.Python
env/
env*/
build/
develop-eggs/
dist/
Expand Down
2 changes: 1 addition & 1 deletion deps/pybind11
Submodule pybind11 updated 248 files
112 changes: 69 additions & 43 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,65 +36,87 @@
# under Contract DE-AC05-76RL01830
# }}}

import sys
import os
import subprocess
import re
import platform
import re
import subprocess
import sys
from distutils.version import LooseVersion
from pathlib import Path

from setuptools import setup, Extension
from setuptools import Extension, find_namespace_packages, find_packages, setup
from setuptools.command.build_ext import build_ext
from distutils.version import LooseVersion

from setuptools import find_packages, find_namespace_packages
from pathlib import Path
module_name = "dnp3_python"


__version__ = '0.3.0b1'
# Function to extract version from the __init__.py file at /src
def find_version():
here = os.path.abspath(os.path.dirname(__file__))
with open(os.path.join(here, "src", module_name, "__init__.py"), "r") as f:
contents = f.read()
version_match = re.search(r"^__version__ = ['\"]([^'\"]*)['\"]", contents, re.M)
if version_match:
return version_match.group(1)
raise RuntimeError("Unable to find version string.")


__version__ = find_version()
print(f"{__version__=}")


class CMakeExtension(Extension):
def __init__(self, name, sourcedir=''):
def __init__(self, name, sourcedir=""):
Extension.__init__(self, name, sources=[])
self.sourcedir = os.path.abspath(sourcedir)


class CMakeBuild(build_ext):
def run(self):
try:
out = subprocess.check_output(['cmake', '--version'])
out = subprocess.check_output(["cmake", "--version"])
except OSError:
raise RuntimeError("CMake must be installed to build the following extensions: " +
", ".join(e.name for e in self.extensions))
raise RuntimeError(
"CMake must be installed to build the following extensions: "
+ ", ".join(e.name for e in self.extensions)
)

if platform.system() == "Windows":
cmake_version = LooseVersion(re.search(r'version\s*([\d.]+)', out.decode()).group(1))
if cmake_version < '3.1.0':
cmake_version = LooseVersion(
re.search(r"version\s*([\d.]+)", out.decode()).group(1)
)
if cmake_version < "3.1.0":
raise RuntimeError("CMake >= 3.1.0 is required on Windows")

for ext in self.extensions:
self.build_extension(ext)

def build_extension(self, ext):
extdir = os.path.abspath(os.path.dirname(self.get_ext_fullpath(ext.name)))
cmake_args = ['-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=' + extdir,
'-DPYTHON_EXECUTABLE=' + sys.executable]
cmake_args = [
"-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=" + extdir,
"-DPYTHON_EXECUTABLE=" + sys.executable,
]

cfg = 'Debug' if self.debug else 'Release'
build_args = ['--config', cfg]
cfg = "Debug" if self.debug else "Release"
build_args = ["--config", cfg]

if platform.system() == "Windows":
cmake_args += ['-DCMAKE_LIBRARY_OUTPUT_DIRECTORY_{}={}'.format(cfg.upper(), extdir)]
cmake_args += [
"-DCMAKE_LIBRARY_OUTPUT_DIRECTORY_{}={}".format(cfg.upper(), extdir)
]
if sys.maxsize > 2**32:
cmake_args += ['-A', 'x64']
build_args += ['--', '/m']
cmake_args += ["-A", "x64"]
build_args += ["--", "/m"]
else:
cmake_args += ['-DCMAKE_BUILD_TYPE=' + cfg]
cmake_args += ['-DSTATICLIBS=ON']
build_args += ['--', '-j2']
cmake_args += ["-DCMAKE_BUILD_TYPE=" + cfg]
cmake_args += ["-DSTATICLIBS=ON"]
build_args += ["--", "-j2"]

env = os.environ.copy()
env['CXXFLAGS'] = '{} -DVERSION_INFO=\\"{}\\"'.format(env.get('CXXFLAGS', ''),
self.distribution.get_version())
env["CXXFLAGS"] = '{} -DVERSION_INFO=\\"{}\\"'.format(
env.get("CXXFLAGS", ""), self.distribution.get_version()
)
if not os.path.exists(self.build_temp):
os.makedirs(self.build_temp)

Expand All @@ -106,37 +128,41 @@ def build_extension(self, ext):
#
# subprocess.check_call(['git', 'apply', patch_path], cwd=dnp3_path)

subprocess.check_call(['cmake', ext.sourcedir] + cmake_args, cwd=self.build_temp, env=env)
subprocess.check_call(['cmake', '--build', '.'] + build_args, cwd=self.build_temp)
subprocess.check_call(
["cmake", ext.sourcedir] + cmake_args, cwd=self.build_temp, env=env
)
subprocess.check_call(
["cmake", "--build", "."] + build_args, cwd=self.build_temp
)


this_directory = Path(__file__).parent
long_description = (this_directory / "README.md").read_text()

setup(
name='dnp3-python',
name="dnp3-python",
version=__version__,
author='Volttron Team',
author_email='[email protected]',
url='https://github.com/VOLTTRON/dnp3-python',
description='pydnp3 -- python binding for opendnp3',
author="Volttron Team",
author_email="[email protected]",
url="https://github.com/VOLTTRON/dnp3-python",
description="pydnp3 -- python binding for opendnp3",
long_description=long_description,
long_description_content_type='text/markdown',
long_description_content_type="text/markdown",
install_requires=[
# 'pybind11>=2.2',
'argcomplete'],
ext_modules=[CMakeExtension('pydnp3')],
"argcomplete"
],
ext_modules=[CMakeExtension("pydnp3")],
cmdclass=dict(build_ext=CMakeBuild),
zip_safe=False,

packages=find_namespace_packages(
where='src',
include=['dnp3_python*', 'dnp3demo'] # to include sub-packages as well.
where="src",
include=[f"{module_name}*", "dnp3demo"], # to include sub-packages as well.
),
package_dir={"": "src"},
entry_points={
'console_scripts': [
'dnp3demo = dnp3demo.__main__:main',
]
},
"console_scripts": [
"dnp3demo = dnp3demo.__main__:main",
]
},
)
1 change: 1 addition & 0 deletions src/dnp3_python/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__version__ = "0.3.0b1"
Loading

0 comments on commit 1ee1987

Please sign in to comment.