Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
8de1928
Fix CITATION.cff validator for Ubuntu 24.04 runner
aromanielloNTIA Dec 12, 2024
230139d
Merge branch 'proplib-template-python-main' into dev
cheroy-ntia Dec 16, 2024
cff704b
update CITATION
cheroy-ntia Dec 17, 2024
c948c24
Update pyupgrade pre-commit hook
aromanielloNTIA Dec 18, 2024
4877693
Remove keyword resulting in misleading zenodo content
aromanielloNTIA Dec 18, 2024
51593f6
Add PropLib Wiki link to metadata
aromanielloNTIA Dec 18, 2024
60b4488
Add license and disclaimer information
aromanielloNTIA Dec 18, 2024
1b417af
Deduplicate workflow runs
aromanielloNTIA Dec 18, 2024
4ebd1f3
Merge branch 'main' into TemplateMerge
aromanielloNTIA Dec 18, 2024
78671ce
Merge remote-tracking branch 'template/main' into TemplateMerge
aromanielloNTIA Dec 18, 2024
3409b56
Fix README badge order
aromanielloNTIA Dec 18, 2024
8cfc2e9
Add pytest GitHub Actions workflow
aromanielloNTIA Jan 17, 2025
a9cb4fe
Support 32-bit windows
aromanielloNTIA Jan 17, 2025
84e80d6
Remove __all__ in package root, add check for test data
aromanielloNTIA Jan 17, 2025
02ccc53
Merge remote-tracking branch 'template/main' into TemplateMerge
aromanielloNTIA Jan 17, 2025
1abc510
Populate environment variables for pytest action
aromanielloNTIA Jan 17, 2025
78facd1
Update cff-validator to v4
aromanielloNTIA Jan 22, 2025
ece190a
Add buildwheels template workflow
aromanielloNTIA Jan 22, 2025
1414e6c
Add runtimeerror documentation
aromanielloNTIA Jan 22, 2025
6aba5cc
Merge remote-tracking branch 'template/main' into TemplateMerge
aromanielloNTIA Jan 22, 2025
d294528
Include sdist release artifacts
aromanielloNTIA Jan 22, 2025
b5a9231
Include shared library files when building sdist
aromanielloNTIA Jan 22, 2025
e17cb3b
Fix publication resource type field for related info
aromanielloNTIA Jan 22, 2025
37d4ed5
Merge remote-tracking branch 'template/main' into TemplateMerge
aromanielloNTIA Jan 22, 2025
95cb444
Update template values
aromanielloNTIA Jan 22, 2025
b8d2f6b
Fix expected shared library path on mac and linux
aromanielloNTIA Jan 22, 2025
529e396
Fix shared library path on mac and linux
aromanielloNTIA Jan 22, 2025
89c0a1f
Merge remote-tracking branch 'template/main' into TemplateMerge
aromanielloNTIA Jan 22, 2025
fc257ca
Update project name for PyPI
aromanielloNTIA Jan 22, 2025
790c6d1
Add test data submodule
aromanielloNTIA Jan 22, 2025
771f466
Merge pull request #2 from NTIA/TemplateMerge
aromanielloNTIA Jan 22, 2025
728d27a
Update to use v1.1 base library
aromanielloNTIA Jan 23, 2025
31a8350
Remove readme for review
aromanielloNTIA Jan 23, 2025
94f940d
Add files for public release
aromanielloNTIA Jan 23, 2025
fc207bf
Merge pull request #5 from NTIA/public-release-approval
aromanielloNTIA Jan 24, 2025
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
6 changes: 3 additions & 3 deletions .github/workflows/cff-validator.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@ name: Validate CITATION.cff

on:
push:
branches: ["main", "dev"]
paths:
- 'CITATION.cff'
- '.github/workflows/cff-validator.yml'
pull_request:
branches: ["main", "dev"]
paths:
- 'CITATION.cff'
- '.github/workflows/cff-validator.yml'
Expand All @@ -22,6 +24,4 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v4
- name: Validate CITATION.cff
uses: dieghernan/cff-validator@v3
with:
install-r: true
uses: dieghernan/cff-validator@v4
93 changes: 93 additions & 0 deletions .github/workflows/pytest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
name: Test with pytest

on:
workflow_dispatch:
push:
branches:
- main
pull_request:
branches:
- main
- dev

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}
cancel-in-progress: true

env:
LIBRARY_BASE_REPO: NTIA/LFMF
LIBRARY_RELEASE_TAG: v1.1
LIBRARY_DESTINATION_DIRECTORY: 'src/ITS/Propagation/LFMF'

jobs:
run-all-tests:
name: ${{ matrix.platform.os-name }} / Py${{ matrix.py }}
runs-on: ${{ matrix.platform.os-runner }}
strategy:
fail-fast: false
matrix:
platform:
- os-name: 'Windows (64-bit)'
os-runner: 'windows-latest'
arch-id: 'x64'
release-file-pattern: '*-x64.dll'
- os-name: 'Windows (32-bit)'
os-runner: 'windows-latest'
arch-id: 'x86'
release-file-pattern: '*-x86.dll'
- os-name: 'macOS (intel/x64)'
os-runner: 'macos-13'
arch-id: 'x64'
release-file-pattern: '*.dylib'
- os-name: 'macOS (apple/arm64)'
os-runner: 'macos-latest'
arch-id: 'arm64'
release-file-pattern: '*.dylib'
- os-name: 'Linux (Ubuntu)'
os-runner: 'ubuntu-latest'
arch-id: 'x64'
release-file-pattern: '*.so'
py: # Python versions to test on all platforms
- "3.9"
- "3.10"
- "3.11"
- "3.12"
steps:
- name: Check out repository
uses: actions/checkout@v4
with:
submodules: true

# Cache key is unique to the combination of runner OS + architecture (matrix.arch-id) + release tag
- name: Restore ${{ env.LIBRARY_RELEASE_TAG }} binaries from cache if available
id: cache-restore
uses: actions/cache@v4
with:
key: ${{ runner.os }}-${{ matrix.platform.arch-id }}-${{ env.LIBRARY_RELEASE_TAG }}
path: ${{ env.LIBRARY_DESTINATION_DIRECTORY}}/${{ matrix.platform.release-file-pattern }}

# Only the binaries required for the current platform are downloaded. Note that the distributed
# wheel for proplib python packages includes all binaries, so that the wheel is inherently cross-platform.
- name: Download required ${{ env.LIBRARY_RELEASE_TAG }} binaries
if: ${{ steps.cache-restore.outputs.cache-hit != 'true' }}
uses: robinraju/release-downloader@v1
with:
repository: ${{ env.LIBRARY_BASE_REPO }}
tag: ${{ env.LIBRARY_RELEASE_TAG }}
fileName: ${{ matrix.platform.release-file-pattern }}
tarBall: false
zipBall: false
out-file-path: ${{ env.LIBRARY_DESTINATION_DIRECTORY }}

- name: Set up Python ${{ matrix.py }}
uses: actions/setup-python@v5
with:
architecture: ${{ matrix.platform.arch-id }}
python-version: ${{ matrix.py }}
cache: 'pip'

- name: Install dependencies for testing
run: python -m pip install -e .[tests]

- name: Run pytest
run: pytest --cov-report=term-missing --no-cov-on-fail --cov
82 changes: 82 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
# Action builds a universal (Win32/Win64/macOS-universal/Linux-x64) Python wheel
# from the source code, using Hatchling, and uploads it as an artifact. An sdist (.tar.gz) is
# also uploaded, which includes all platform shared library files. These artifacts should be
# used when creating new releases on PyPI and GitHub. The action is triggered by pushes into `main`
# or pull_requests into `main` or `dev` (for testing). To aid in releases, the workflow is
# also triggered when new SemVer tags are created.
name: Build Release Artifacts

on:
workflow_dispatch:
push:
branches:
- main
tags:
- 'v[0-9]+.*'
pull_request:
branches:
- main
- dev

env:
LIBRARY_BASE_REPO: NTIA/LFMF
LIBRARY_RELEASE_TAG: v1.1
LIBRARY_DESTINATION_DIRECTORY: 'src/ITS/Propagation/LFMF/'

jobs:
build_wheel:
name: Build a universal, cross-platform wheel
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v4
with:
submodules: true

# Only the binaries required for the current platform are downloaded. Note that the distributed
# wheel for proplib python packages includes all binaries, so that the wheel is inherently cross-platform.
- name: Download required ${{ env.LIBRARY_RELEASE_TAG }} Windows binaries
uses: robinraju/release-downloader@v1
with:
repository: ${{ env.LIBRARY_BASE_REPO }}
tag: ${{ env.LIBRARY_RELEASE_TAG }}
fileName: '*.dll'
tarBall: false
zipBall: false
out-file-path: ${{ env.LIBRARY_DESTINATION_DIRECTORY }}

- name: Download required ${{ env.LIBRARY_RELEASE_TAG }} Linux binaries
uses: robinraju/release-downloader@v1
with:
repository: ${{ env.LIBRARY_BASE_REPO }}
tag: ${{ env.LIBRARY_RELEASE_TAG }}
fileName: '*.so'
tarBall: false
zipBall: false
out-file-path: ${{ env.LIBRARY_DESTINATION_DIRECTORY }}

- name: Download required ${{ env.LIBRARY_RELEASE_TAG }} macOS binaries
uses: robinraju/release-downloader@v1
with:
repository: ${{ env.LIBRARY_BASE_REPO }}
tag: ${{ env.LIBRARY_RELEASE_TAG }}
fileName: '*.dylib'
tarBall: false
zipBall: false
out-file-path: ${{ env.LIBRARY_DESTINATION_DIRECTORY }}

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.13'

- name: Install build dependencies
run: pip install hatchling

- name: Build wheels
run: hatchling build

- uses: actions/upload-artifact@v4
with:
name: Release Artifacts (sdist and wheel)
path: dist/*
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -164,3 +164,4 @@ cython_debug/
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/
.idea/
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "tests/data"]
path = tests/data
url = https://github.com/NTIA/LFMF-test-data
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ repos:
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/asottile/pyupgrade
rev: v3.19.0
rev: v3.19.1
hooks:
- id: pyupgrade
args: ["--py39-plus"]
Expand Down
5 changes: 2 additions & 3 deletions .zenodo.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"upload_type": "software",
"publication_date": "TODO-TEMPLATE",
"publication_date": "2025-1-23",
"title": "Low Frequency / Medium Frequency (LF/MF) Propagation Model, Python Wrapper",
"creators": [
{
Expand All @@ -15,7 +15,6 @@
}
],
"description": "This code repository contains a Python wrapper for the NTIA/ITS implementation of the Low Frequency / Medium Frequency (LF/MF) Propagation Model.",
"access_right": "open",
"keywords": [
"propagation",
"communications",
Expand All @@ -36,7 +35,7 @@
{
"identifier": "https://ntia.github.io/propagation-library-wiki/models/LFMF/",
"relation": "isDocumentedBy",
"resource_type": "softwaredocumentation"
"resource_type": "publication-softwaredocumentation"
}
],
"version": "1.1.0"
Expand Down
18 changes: 9 additions & 9 deletions GitHubRepoPublicReleaseApproval.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,21 @@
The project identified above, which is contained within the repository this
document is stored in, has met the following criteria for public release:

1. [ ] The project, including the test criteria, meets the requirements defined
1. [x] The project, including the test criteria, meets the requirements defined
in the ITS Software Development Publication Policy for making a repository public.
The major pre-established criteria for publication are listed below, and the check
mark next to each attests that the criterion has been met.
* [ ] Unit tests are available and the software has been tested against the unit tests.
* [ ] The software can be compiled and/or used on Windows, macOS, and Linux.
* [ ] The repository structure and contents follow from the ITS PropLib template, and
* [x] Unit tests are available and the software has been tested against the unit tests.
* [x] The software can be compiled and/or used on Windows, macOS, and Linux.
* [x] The repository structure and contents follow from the ITS PropLib template, and
all template or placeholder code has been removed.
* [ ] The repository includes the appropriate `LICENSE.md` file
2. [ ] Any test data necessary for the code and its unit tests to function is included in this
* [x] The repository includes the appropriate `LICENSE.md` file
2. [x] Any test data necessary for the code and its unit tests to function is included in this
GitHub repository, either directly or as a linked Git submodule.
3. [ ] The README.md file has passed editorial review from the ITS Publications Office.
4. [ ] The project complies with the ITS Code Style Guide or an appropriate style
3. [x] The README.md file has passed editorial review from the ITS Publications Office.
4. [x] The project complies with the ITS Code Style Guide or an appropriate style
guide as agreed to by the sponsor, project lead, or Supervising Division Chief.
5. [ ] Approved disclaimer and licensing language has been included.
5. [x] Approved disclaimer and licensing language has been included.

In order to complete this approval, please create a new branch, upload and commit
your version of this Markdown document to that branch, then create a pull request
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
# Low Frequency / Medium Frequency (LF/MF) Propagation Model, Python® Wrapper #

[![NTIA/ITS PropLib][proplib-badge]][proplib-link]
[![GitHub Issues][gh-issues-badge]][gh-issues-link]
[![PyPI Release][pypi-release-badge]][pypi-release-link]
[![GitHub Actions Unit Test Status][gh-actions-test-badge]][gh-actions-test-link]
[![GitHub Issues][gh-issues-badge]][gh-issues-link]
[![DOI][doi-badge]][doi-link]

[proplib-badge]: https://img.shields.io/badge/PropLib-badge?label=%F0%9F%87%BA%F0%9F%87%B8%20NTIA%2FITS&labelColor=162E51&color=D63E04
[proplib-link]: https://ntia.github.io/propagation-library-wiki
[gh-actions-test-badge]: https://img.shields.io/github/actions/workflow/status/NTIA/LFMF-python/tox.yml?branch=main&logo=pytest&logoColor=ffffff&label=Tests&labelColor=162E51
[gh-actions-test-link]: https://github.com/NTIA/LFMF-python/actions/workflows/tox.yml
[gh-actions-test-badge]: https://img.shields.io/github/actions/workflow/status/NTIA/LFMF-python/pytest.yml?branch=main&logo=pytest&logoColor=ffffff&label=Tests&labelColor=162E51
[gh-actions-test-link]: https://github.com/NTIA/LFMF-python/actions/workflows/pytest.yml
[pypi-release-badge]: https://img.shields.io/pypi/v/proplib-lfmf?logo=pypi&logoColor=ffffff&label=Release&labelColor=162E51&color=D63E04
[pypi-release-link]: https://pypi.org/project/proplib-lfmf
[gh-issues-badge]: https://img.shields.io/github/issues/NTIA/LFMF-python?logo=github&label=Issues&labelColor=162E51
Expand Down
30 changes: 5 additions & 25 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ requires = ["hatchling"]
build-backend = "hatchling.build"

[project]
name = "LFMF"
name = "proplib-lfmf"
dynamic = ["version"]
description = "A Python wrapper for the NTIA/ITS implementation of the Low Frequency / Medium Frequency (LF/MF) Propagation Model"
readme = "README.md"
Expand Down Expand Up @@ -42,7 +42,6 @@ classifiers = [
tests = [
"pytest>=8.2.0,<9.0",
"pytest-cov>=6.0.0,<7.0",
"tox>=4.21.1,<5.0", # Keep in sync with tool.tox.min_version
]
dev = [
"hatchling>=1.25.0,<2.0",
Expand All @@ -51,6 +50,7 @@ dev = [
]

[project.urls]
"PropLib Wiki" = "https://ntia.github.io/propagation-library-wiki/models/LFMF/"
"Python Wrapper Source" = "https://github.com/NTIA/LFMF-python"
"Python Wrapper Bug Tracker" = "https://github.com/NTIA/LFMF-python/issues"
"C++ Source" = "https://github.com/NTIA/LFMF"
Expand All @@ -64,29 +64,9 @@ path = "src/ITS/Propagation/LFMF/__init__.py"
packages = ["src/ITS"]
ignore-vcs = true

[tool.hatch.build.targets.sdist]
ignore-vcs = true

[tool.cibuildwheel]
test-command = "pytest ."
test-requires = "pytest"

[tool.tox]
min_version = "4.21.1"
env_list = ["3.9", "3.10", "3.11", "3.12", "3.13"]
skip_missing_interpreters = true

[tool.tox.env.testenv]
description = "Run tests with pytest and generate coverage report"
extras = "tests"
commands = [
"pytest",
"--cov-report=term-missing",
"--no-cov-on-fail",
"--cov",
{ replace = "posargs", extend = true },
]

[tool.tox.gh.python] # tox-gh config for GitHub Actions testing
"3.9" = ["3.9"]
"3.10" = ["3.10"]
"3.11" = ["3.11"]
"3.12" = ["3.12"]
"3.13" = ["3.13"]
16 changes: 13 additions & 3 deletions src/ITS/Propagation/LFMF/proplib_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
"""

import platform
import struct
from ctypes import *
from pathlib import Path

Expand All @@ -67,15 +68,24 @@ def get_lib_name(lib_name: str) -> str:

:param lib_name: The library name, with no extension or path, e.g., "P2108-1.0"
:raises NotImplementedError: For platforms other than Windows, Linux, or macOS.
:raises RuntimeError: On Windows, if unable to determine system architecture.
:return: The full filename, including path and extension, of the library.
"""
# Load the compiled library
if platform.uname()[0] == "Windows":
lib_name += ".dll"
arch = struct.calcsize("P") * 8 # 32 or 64
if arch == 64:
lib_name += "-x64.dll"
elif arch == 32:
lib_name += "-x86.dll"
else:
raise RuntimeError(
"Failed to determine system architecture for DLL loading"
)
elif platform.uname()[0] == "Linux":
lib_name += ".so"
lib_name += "-x86_64.so"
elif platform.uname()[0] == "Darwin":
lib_name += ".dylib"
lib_name += "-universal.dylib"
else:
raise NotImplementedError("Your OS is not yet supported")
# Library should be in the same directory as this file
Expand Down
1 change: 1 addition & 0 deletions tests/data
Submodule data added at d3cc4d
1 change: 0 additions & 1 deletion tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

# Check if test data directory exists and is not empty
if not TEST_DATA_DIR.exists() or not any(TEST_DATA_DIR.iterdir()):
_test_data_checked = True
raise RuntimeError(
f"Test data is not available in {TEST_DATA_DIR}.\n Try running "
+ "`git submodule init` and `git submodule update` to clone the test data submodule."
Expand Down
Loading