Skip to content

Commit

Permalink
do not install system files when building/installing as user (#27)
Browse files Browse the repository at this point in the history
Signed-off-by: Martin <Ho-Ro@users.noreply.github.com>
  • Loading branch information
Ho-Ro committed May 23, 2024
1 parent c85792d commit 9664f5f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -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]
Expand Down
16 changes: 12 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

from setuptools import setup
import os
import sys
import platform


Expand All @@ -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',
Expand Down Expand Up @@ -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 )

0 comments on commit 9664f5f

Please sign in to comment.