Skip to content

Commit

Permalink
Cleanup generated directory and fixed some python 3.12 warnings (#173)
Browse files Browse the repository at this point in the history
* fix regex warning

* fixed SyntaxWarning: invalid escape sequence

* added a requirements.txt for python 3.12+

* moved ics directory into gen directory

* packages fix

* in progress changes

* fixed init file

* fixed pathing issue

* update libicsneolegacy output directory

* silenced debug messages

* always generate files now

* update gen file

* added package metadata and auto versioning

* remove version requirement of cibuildwheel

* specify python version

* fix for artifacts v4 error.

* ci fix

* more CI fixes
  • Loading branch information
drebbe-intrepid authored Feb 21, 2024
1 parent 14c26c5 commit c676c95
Show file tree
Hide file tree
Showing 213 changed files with 874 additions and 95 deletions.
31 changes: 26 additions & 5 deletions .github/workflows/wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,41 @@ jobs:
os: [ubuntu-20.04, windows-2019, macOS-13]

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0 # needed for history/tags

# Used to host cibuildwheel
- uses: actions/setup-python@v3
- name: Set up Python 3.12
uses: actions/setup-python@v5
with:
python-version: '3.12'

- name: Get python_ics version
uses: mtkennerly/dunamai-action@v1
with:
env-var: PYTHON_ICS_VERSION
args: --format "v{base}-{commit}-{timestamp}"
- name: Print python_ics version
run: echo $PYTHON_ICS_VERSION

- name: Install cibuildwheel
run: python -m pip install cibuildwheel==2.16.2
run: python -m pip install cibuildwheel

- name: Build wheels
run: python -m cibuildwheel --output-dir wheelhouse

- uses: actions/upload-artifact@v3
- name: Upload Artifacts
uses: actions/upload-artifact@v4
with:
name: python_ics-${{ matrix.os }}-${{ env.PYTHON_ICS_VERSION }}
path: ./wheelhouse/*.whl
if-no-files-found: error
if-no-files-found: error

- name: Download artifacts
uses: actions/download-artifact@v4
with:
pattern: python_ics-*
merge-multiple: true
path: ./wheelhouse/
21 changes: 21 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) <Intrepid Control Systems, Inc.>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
4 changes: 2 additions & 2 deletions build_libicsneo.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,9 @@ def build():

def copy():
if sys.platform == "darwin":
shutil.copyfile(f"{LIBICSNEO_BUILD}/libicsneolegacy.dylib", "ics/libicsneolegacy.dylib")
shutil.copyfile(f"{LIBICSNEO_BUILD}/libicsneolegacy.dylib", "gen/ics/libicsneolegacy.dylib")
elif sys.platform == "linux":
shutil.copyfile(f"{LIBICSNEO_BUILD}/libicsneolegacy.so", "ics/libicsneolegacy.so")
shutil.copyfile(f"{LIBICSNEO_BUILD}/libicsneolegacy.so", "gen/ics/libicsneolegacy.so")


def clean():
Expand Down
41 changes: 41 additions & 0 deletions create_version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import os
import dunamai
import pathlib


def get_pkg_version() -> str:
"""
Get the package version.
Returns:
str: The package version.
"""
version = dunamai.Version.from_git()
# Set the dev version if the environment variable is set.
if os.getenv("PYTHON_ICS_DEV_BUILD") is not None:
pkg_version = version.serialize(format="v{base}.dev{distance}", style=dunamai.Style.Pep440)
else:
pkg_version = version.serialize(format="{base}", style=dunamai.Style.Pep440)
return pkg_version

def create_version_py(path: pathlib.Path = pathlib.Path("gen/ics/__version.py")) -> None:
"""
Create a version.py file with the package version and full version.
Args:
path (pathlib.Path, optional): The path to the version.py file. Defaults to pathlib.Path("gen/ics/__version.py").
Returns:
None
"""
pkg_version = get_pkg_version()
full_version = dunamai.Version.from_git().serialize(format="v{base}-{commit}-{timestamp}")
print(f"Creating '{path}' with version {pkg_version} and full version {full_version}...")
# Write the version file to disk
with open(path, "w+") as f:
f.write(f"""__version__ = "{pkg_version}"\n""")
f.write(f"""__full_version__ = "{full_version}"\n""")


if __name__ == "__main__":
create_version_py()
2 changes: 1 addition & 1 deletion extract_icsneo40_defines.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ def extract():
# DEBUG: print('\t\t' + str(line_number) + '\t' + str(sline))
if any(x in sline[1] for x in ignores):
continue
if len(sline) >= 3 and re.match("^\d+?\.\d+?$", sline[2]) is not None:
if len(sline) >= 3 and re.match(r"^\d+?\.\d+?$", sline[2]) is not None:
# Value is a float
print(
'\tresult += PyModule_AddObject(module, "{0}", PyFloat_FromDouble({0}));'.format(
Expand Down
20 changes: 20 additions & 0 deletions gen/ics/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
try:
import ics.__version
__version__ = ics.__version.__version__
__full_version__ = ics.__version.__full_version__
except Exception as ex:
print(ex)

try:
# Release environment
#print("Release")
from ics.ics import *
from ics.structures import *
from ics.hiddenimports import hidden_imports
except Exception as ex:
# Build environment
#print("Debug", ex)
from ics import *
from ics.structures import *
from ics.hiddenimports import hidden_imports

2 changes: 2 additions & 0 deletions gen/ics/__version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
__version__ = "914.14"
__full_version__ = "v914.14-3ac87bb-20240219195124"
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit c676c95

Please sign in to comment.