Skip to content

Commit

Permalink
Prep for pip packaging
Browse files Browse the repository at this point in the history
 - Moved files into project folder named "NanoVNASaver"
 - Added requirements
  • Loading branch information
Psynosaur committed Sep 4, 2019
1 parent cdfab82 commit 396a4c9
Show file tree
Hide file tree
Showing 13 changed files with 102 additions and 23 deletions.
3 changes: 2 additions & 1 deletion Calibration.py → NanoVNASaver/Calibration.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.

import collections
from PyQt5 import QtWidgets
from typing import List
Expand All @@ -25,7 +26,7 @@ class CalibrationWindow(QtWidgets.QWidget):
def __init__(self, app):
super().__init__()

from NanoVNASaver import NanoVNASaver
from .NanoVNASaver import NanoVNASaver

self.app: NanoVNASaver = app

Expand Down
2 changes: 1 addition & 1 deletion Chart.py → NanoVNASaver/Chart.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

from PyQt5 import QtWidgets, QtGui, QtCore

from Marker import Marker
from .Marker import Marker
Datapoint = collections.namedtuple('Datapoint', 'freq re im')


Expand Down
4 changes: 2 additions & 2 deletions LogMagChart.py → NanoVNASaver/LogMagChart.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@

from PyQt5 import QtWidgets, QtGui, QtCore

from Chart import Chart
from Marker import Marker
from .Chart import Chart
from .Marker import Marker

Datapoint = collections.namedtuple('Datapoint', 'freq re im')

Expand Down
2 changes: 1 addition & 1 deletion Marker.py → NanoVNASaver/Marker.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def __init__(self, name, initialColor, frequency=""):
self.layout.addWidget(self.btnColorPicker)

def setFrequency(self, frequency):
from NanoVNASaver import NanoVNASaver
from .NanoVNASaver import NanoVNASaver
f = NanoVNASaver.parseFrequency(frequency)
if f > 0:
self.frequency = f
Expand Down
14 changes: 7 additions & 7 deletions NanoVNASaver.py → NanoVNASaver/NanoVNASaver.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@
from PyQt5 import QtWidgets, QtCore, QtGui
from serial.tools import list_ports

import Chart
from Calibration import CalibrationWindow, Calibration
from Marker import Marker
from SmithChart import SmithChart
from SweepWorker import SweepWorker
from LogMagChart import LogMagChart
from Touchstone import Touchstone
from .Chart import Chart
from .Calibration import CalibrationWindow, Calibration
from .Marker import Marker
from .SmithChart import SmithChart
from .SweepWorker import SweepWorker
from .LogMagChart import LogMagChart
from .Touchstone import Touchstone

Datapoint = collections.namedtuple('Datapoint', 'freq re im')

Expand Down
4 changes: 2 additions & 2 deletions SmithChart.py → NanoVNASaver/SmithChart.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@

from PyQt5 import QtWidgets, QtGui, QtCore

from Chart import Chart
from Marker import Marker
from .Chart import Chart
from .Marker import Marker

Datapoint = collections.namedtuple('Datapoint', 'freq re im')

Expand Down
9 changes: 5 additions & 4 deletions SweepWorker.py → NanoVNASaver/SweepWorker.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ def __init__(self, app: NanoVNASaver):

@pyqtSlot()
def run(self):
global obj
self.percentage = 0
if not self.app.serial.is_open:
return
Expand All @@ -55,9 +56,9 @@ def run(self):
sweepFrom = 1000000
sweepTo = 800000000
else:
from NanoVNASaver import NanoVNASaver
sweepFrom = NanoVNASaver.parseFrequency(self.app.sweepStartInput.text())
sweepTo = NanoVNASaver.parseFrequency(self.app.sweepEndInput.text())
from NanoVNASaver import NanoVNASaver as obj
sweepFrom = obj.NanoVNASaver.parseFrequency(self.app.sweepStartInput.text())
sweepTo = obj.NanoVNASaver.parseFrequency(self.app.sweepEndInput.text())
if sweepFrom < 0 or sweepTo < 0:
print("Can't sweep from " + self.app.sweepStartInput.text() + " to " + self.app.sweepEndInput.text())
self.signals.finished.emit()
Expand Down Expand Up @@ -85,7 +86,7 @@ def run(self):
self.saveData(frequencies, values, values12)

# Reset the device to show the full range
self.app.setSweep(NanoVNASaver.parseFrequency(self.app.sweepStartInput.text()), NanoVNASaver.parseFrequency(self.app.sweepEndInput.text()))
self.app.setSweep(obj.NanoVNASaver.parseFrequency(self.app.sweepStartInput.text()), obj.NanoVNASaver.parseFrequency(self.app.sweepEndInput.text()))
else:
self.app.setSweep(sweepFrom, sweepTo)
sleep(0.8)
Expand Down
7 changes: 4 additions & 3 deletions Touchstone.py → NanoVNASaver/Touchstone.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,13 @@
# along with this program. If not, see <https://www.gnu.org/licenses/>.
import collections
from typing import List

Datapoint = collections.namedtuple('Datapoint', 'freq re im')


class Touchstone:
s11data : List[Datapoint] = []
s21data : List[Datapoint] = []
s11data: List[Datapoint] = []
s21data: List[Datapoint] = []

filename = ""

Expand Down Expand Up @@ -79,4 +80,4 @@ def load(self):
return

def setFilename(self, filename):
self.filename = filename
self.filename = filename
Empty file added NanoVNASaver/__init__.py
Empty file.
9 changes: 7 additions & 2 deletions nanovna-saver.py → NanoVNASaver/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,12 @@

from PyQt5 import QtWidgets

from NanoVNASaver import NanoVNASaver
from .NanoVNASaver import NanoVNASaver

version = "0.0.4"

if __name__ == '__main__':

def main():
print("NanoVNASaver " + version)
print("Copyright (C) 2019 Rune B. Broberg")
print("This program comes with ABSOLUTELY NO WARRANTY")
Expand All @@ -34,3 +35,7 @@
window = NanoVNASaver()
window.show()
app.exec_()


if __name__ == '__main__':
main()
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,20 @@ In order to run this app in Linux environment, you'll need the following package
python3 nanovna-saver.py
```

### Installation and Use with pip

1. Clone repo and cd into the directory
- `git clone https://github.com/mihtjel/nanovna-saver`
- `cd nanovna-saver`

2. Run the pip installation

`pip install .`

2. Once completed run with the following command

`NanoVNASaver`

### Using the software

Connect your NanoVNA to a serial port, and enter this serial port in the serial port box. Click "Open serial" to connect.
Expand Down
2 changes: 2 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[metadata]
description-file = README.md
55 changes: 55 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# NanoVNASaver - a python program to view and export Touchstone data from a NanoVNA
# Copyright (C) 2019. Rune B. Broberg
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.

import sys

if sys.version_info < (3, 7):
print("You need at least Python 3.7 for this application!")
if sys.version_info[0] < 3:
print("try running with python3 {}".format(" ".join(sys.argv)))
sys.exit(1)

try:
from setuptools import setup, find_packages
except ImportError:
print("Could not find setuptools")
print("Try installing them with pip install setuptools")
sys.exit(1)

with open("README.md", "r") as fh:
long_description = fh.read()

setup(
name='NanoVNASaver',
url='https://github.com/mihtjel/nanovna-saver',
version='0.0.4',
author='Rune B. Broberg',
author_email='',
packages=find_packages(),
long_description=long_description,
long_description_content_type="text/markdown",
license='LICENSE.txt',
entry_points={
'console_scripts': [
'NanoVNASaver = NanoVNASaver.__main__:main'
],
},
install_requires=[
'pyserial',
'PyQt5',
'numpy',
],
)

0 comments on commit 396a4c9

Please sign in to comment.