Skip to content

Commit

Permalink
Chore/uv (#752)
Browse files Browse the repository at this point in the history
use uv as project management tool
  • Loading branch information
redrathnure authored Jan 13, 2025
1 parent b5da81b commit 588c854
Show file tree
Hide file tree
Showing 14 changed files with 1,067 additions and 186 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/pythoncoverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ jobs:
matrix:
# os: [ubuntu-latest, macos-latest, windows-latest]
os: [ubuntu-latest]
# python-version: [3.7, 3.8]
python-version: [3.8, 3.9]
python-version: [3.10, 3.11, 3.12]

steps:
- uses: actions/checkout@v3
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,4 @@ NanoVNASaver.spec
.python-version


*.spec
85 changes: 85 additions & 0 deletions docs/DEVELOPMENT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
# Development Process

## Local Development Environment

Prerequerements:

1. Python > 3.10. Using [pyenv](https://github.com/pyenv/pyenv) / [pyenv-win](https://github.com/pyenv-win/pyenv-win) may be requered to test comaptibility with different python versions.
2. [Astral UV v1.8.x](https://docs.astral.sh/uv/). May be installed via [pipx](https://pipx.pypa.io/latest/installation/).

## Local Run and Debugging

Following commands to prepare local env and run application or run tests:

* `uv sync` - prepare virtual environment and install prod and dev dependencies
* `uv run NanoVNASaver` - run local instance
* `uv run task test` - run unit tests in current venv
* `uv run task test-cov` - run unit tests in current venv and display test coverage report
* `uv run task test-full` - run unit tests for all avialable python versions
* `uv run task clean` - remove temporally artifacts (dist, build, *.pyc etc)

## Development Routines

A few usefull commands:

* 🚧 TODO: - update dependencies in `pyproject.toml` respecting specified version constraints.
* 🚧 TODO: - update dependencies ignoring in `pyproject.toml` specified version constraints.
* `uv lock` - update dependency lock file respecting specified version constraints.

## Build Process

### Python packages

A `uv build` may be used to prepare python packages. Version would be taken from git repository.

### Windows Exeutables

Pre requirements:

* Python 3.10-3.12
* uv (see `Local Development Environment` for more details)

Execute `uv run task build-pkg-win` to get `dist\nanovna-sever*.exe` file.

### Linux Executables

Pre requirements:

* Python 3.10-3.12
* uv (see `Local Development Environment` for more details)
* Some X11 packages preinstalled

An example for Ubuntu 22.04:

```
sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt-get update
sudo apt install -y python3.11 python3-pip python3.11-venv \
python3.11-dev \
'^libxcb.*-dev' libx11-xcb-dev \
libglu1-mesa-dev libxrender-dev libxi-dev \
libxkbcommon-dev libxkbcommon-x11-dev
```

Execute `uv run task build-pkg-linux` to get `dist/nanovna-sever*` file.

### Linux Flatpack

🚧 TODO: describe me

### MacOS Package

Pre requirements:

* Python 3.10-3.12
* uv (see `Local Development Environment` for more details)
* PyQt >=6.4 installed (`brew install pyqt`)

Execute `uv run task build-pkg-macos` to get `dist/NanoVNASaver.app*.exe` file.

## Publish Process

Please configure pypi credentials, create git tag and execute `uv publish` command. Please refer [UV :: publish](https://docs.astral.sh/uv/guides/publish/) for more details.

🚧 TODO: describe git tag creation and next version selection
🚧 TODO: build and publish platform specific artefacts: deb, native bin, flatpack packages
100 changes: 79 additions & 21 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,18 +1,12 @@
[build-system]
# AVOID CHANGING REQUIRES: IT WILL BE UPDATED BY PYSCAFFOLD!
requires = [
'pyinstaller==6.11.1',
'setuptools==75.6.0',
'setuptools_scm[toml]==8.1.0',
'uv==0.5.7',
]
build-backend = 'setuptools.build_meta'

[project]
name='NanoVNASaver'
description='GUI for the NanoVNA and derivates'
requires-python = ">=3.9"
license={file = 'LICENSE'}
authors = [
{ name = "Rune B. Broberg", email = "NanoVNA-Saver@users.noreply.github.com" }
]
requires-python = ">=3.10"
license = {text = "GPL-3.0-or-later"}
readme = "README.rst"

classifiers =[
'Development Status :: 4 - Beta',
Expand All @@ -21,37 +15,101 @@ classifiers =[
'Intended Audience :: Science/Research',
'Intended Audience :: Telecommunications Industry',
'License :: OSI Approved :: GNU General Public License v3 (GPLv3)',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: 3.11',
'Programming Language :: Python :: 3.12',
'Programming Language :: Python :: 3.13',
]
keywords = ["Communications", "Ham Radio", "nanovna"]
dynamic=['version']

dependencies=[
'pyserial==3.5',
'PyQt6==6.7.1',
'PyQt6-sip==13.8.0',
'sip==6.8.6',
'numpy==2.1.3',
'scipy==1.14.1',
'Cython==3.0.11',
'pyserial~=3.5',
'PyQt6~=6.7',
'PyQt6-sip~=13.8',
'numpy~=2.1',
'scipy~=1.14',
]


[dependency-groups]
dev = [
# Static Code Analysis tools
"black~=24.10",
"flake8~=7.1",
"pylint~=3.3",

# Testing
"pytest~=8.3",
"pytest-cov~=6.0",
"tox~=4.23",
"tox-uv~=1.17",

# Build helpers
"setuptools-scm>=8",
"taskipy~=1.14",
"pyinstaller~=6.11.1",
]
dynamic=['version', 'readme']



[project.urls]
homepage = "https://github.com/NanoVNA-Saver/nanovna-saver"
repository = "https://github.com/NanoVNA-Saver/nanovna-saver"
Issues = "https://github.com/NanoVNA-Saver/nanovna-saver/issues"



[project.scripts]
NanoVNASaver = 'NanoVNASaver.__main__:main'

[project.gui-scripts]
NanoVNASaver-gui = 'NanoVNASaver.__main__:main'



[build-system]
requires = [
"setuptools>=64",
"setuptools-scm>=8"
]
build-backend = 'setuptools.build_meta'



[tool.setuptools.packages.find]
# See https://setuptools.pypa.io/en/latest/userguide/pyproject_config.html for more details
where = ["src"]



[tool.setuptools_scm]
# For smarter version schemes and other configuration options,
# check out https://github.com/pypa/setuptools_scm
root='.'
version_scheme = 'no-guess-dev'
write_to = 'src/NanoVNASaver/_version.py'



[tool.taskipy.tasks]
test = "pytest ."
test-cov = "pytest --cov=src ."
test-full = "tox"

clean = "task clean_dist & task clean_build & task clean_py & task clean_logs & task clean_pycache"
clean_dist = "rm -r dist"
clean_build = "rm -r build"
clean_py = "python -Bc \"import pathlib; [p.unlink() for p in pathlib.Path('.').rglob('*.py[co]')]\""
clean_logs = "python -Bc \"import pathlib; [p.unlink() for p in pathlib.Path('.').rglob('*.log')]\""
clean_pycache = " python -Bc \"import pathlib; [p.rmdir() for p in pathlib.Path('.').rglob('__pycache__')]\""

build-pkg-win = "pyinstaller --onefile -p src -n nanovna-saver.exe nanovna-saver.py --noconsole -i icon_48x48.ico --add-data \"icon_48x48.png:.\""
build-pkg-linux = "pyinstaller --onefile -p src -n nanovna-saver nanovna-saver.py --add-data \"icon_48x48.png:.\""
build-pkg-macos = "pyinstaller --onedir -p src -n NanoVNASaver nanovna-saver.py --window --clean -y -i icon_48x48.icns --add-data \"icon_48x48.png:.\" && tar -C dist -zcf ./dist/NanoVNASaver.app-`uname -m`.tar.gz NanoVNASaver.app"



[tool.pytest.ini_options]
pythonpath = [
'.', 'src',
Expand Down
9 changes: 0 additions & 9 deletions requirements.txt

This file was deleted.

104 changes: 0 additions & 104 deletions setup.cfg

This file was deleted.

21 changes: 0 additions & 21 deletions setup.py

This file was deleted.

9 changes: 3 additions & 6 deletions src/NanoVNASaver/About.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,12 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.

from setuptools_scm import get_version
from .app_version import APP_VERSION

try:
version = get_version(root="../..", relative_to=__file__)
except LookupError:
from NanoVNASaver._version import version

VERSION = APP_VERSION
INFO_URL = "https://github.com/NanoVNA-Saver/nanovna-saver"
INFO = f"""NanoVNASaver {version}
INFO = f"""NanoVNASaver {APP_VERSION}
Copyright (C) 2019, 2020 Rune B. Broberg
Copyright (C) 2020ff NanoVNA-Saver Authors
Expand Down
Loading

0 comments on commit 588c854

Please sign in to comment.