diff --git a/CHANGELOG b/CHANGELOG index 9990366..a12610b 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,4 @@ +2024-05-23: new tool upload_firmware_6022.py (upload to different VID:PID) [c85792d] 2024-05-06: make scopevis.py example program really useful [ea05828] 2024-05-03: upversion 2.10.8; update examples and doc [ac44d00] 2024-05-02: more documentation for example programs [fb8e531] diff --git a/setup.py b/setup.py index a12f176..deac5cf 100644 --- a/setup.py +++ b/setup.py @@ -13,6 +13,7 @@ from setuptools import setup import os +import sys import platform @@ -29,10 +30,12 @@ ] # add linux specific config files and binaries +linux_udev_rules = 'udev/60-hantek6022api.rules' +linux_udev_path = '/etc/udev/rules.d/' if platform.system() == 'Linux': - data_files.append( ( '/etc/udev/rules.d/', [ 'udev/60-hantek6022api.rules' ] ) ) - data_files.append( ( 'bin/', [ 'fx2upload/fx2upload' ] ) ) - + if os.getuid() == 0: + data_files.append( ( linux_udev_path, [ linux_udev_rules ] ) ) + data_files.append( ( 'bin/', [ 'fx2upload/fx2upload' ] ) ) setup( name='hantek6022api', @@ -63,8 +66,13 @@ os.path.join( 'examples', 'fft_from_capture_6022.py' ), os.path.join( 'examples', 'set_cal_out_freq_6022.py' ), os.path.join( 'examples', 'upload_6022_firmware_from_hex.py' ), - os.path.join( 'examples', 'upload_6022_firmware.py' ), + os.path.join( 'examples', 'upload_firmware_6022.py' ), ], # generic and linux 'data_files' from top data_files = data_files ) + +if platform.system() == 'Linux' and os.getuid() != 0: + if 'build' in sys.argv or 'install' in sys.argv: + print( f'building / installing as user!' ) + print( f'to enable access to the device copy (as root) the file "{linux_udev_rules}" into "{linux_udev_path}".', file = sys.stderr )