mirror of
https://github.com/DJ2LS/FreeDATA
synced 2024-05-14 08:04:33 +00:00
first test with pip package
This commit is contained in:
parent
5958820540
commit
5eac888f34
6 changed files with 70 additions and 8 deletions
26
.github/workflows/pip_package.yml
vendored
Normal file
26
.github/workflows/pip_package.yml
vendored
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
name: Deploy Python Package
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
tags:
|
||||||
|
- '*'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
deploy:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- name: Set up Python
|
||||||
|
uses: actions/setup-python@v2
|
||||||
|
with:
|
||||||
|
python-version: '3.11'
|
||||||
|
|
||||||
|
- name: Build package
|
||||||
|
run: |
|
||||||
|
python setup.py sdist bdist_wheel
|
||||||
|
|
||||||
|
- name: Publish to PyPI
|
||||||
|
uses: pypa/gh-action-pypi-publish@v1.4.2
|
||||||
|
with:
|
||||||
|
user: __token__
|
||||||
|
password: ${{ secrets.PYPI_API_TOKEN }}
|
0
modem/__init__.py
Normal file
0
modem/__init__.py
Normal file
|
@ -82,14 +82,14 @@ def freedv_get_mode_name_by_value(mode: int) -> str:
|
||||||
"""
|
"""
|
||||||
return FREEDV_MODE(mode).name
|
return FREEDV_MODE(mode).name
|
||||||
|
|
||||||
|
|
||||||
# Get the directory of the current script file
|
# Get the directory of the current script file
|
||||||
script_dir = os.path.dirname(os.path.abspath(__file__))
|
script_dir = os.path.dirname(os.path.abspath(__file__))
|
||||||
sys.path.append(script_dir)
|
sys.path.append(script_dir)
|
||||||
|
|
||||||
# Use script_dir to construct the paths for file search
|
# Use script_dir to construct the paths for file search
|
||||||
if sys.platform == "linux":
|
if sys.platform == "linux":
|
||||||
files = glob.glob(os.path.join(script_dir, "**/*libcodec2*"), recursive=True)
|
files = glob.glob(os.path.join(script_dir, "**/*libcodec2*"), recursive=True)
|
||||||
files.append(os.path.join(script_dir, "libcodec2.so"))
|
#files.append(os.path.join(script_dir, "libcodec2.so"))
|
||||||
elif sys.platform == "darwin":
|
elif sys.platform == "darwin":
|
||||||
if hasattr(sys, "_MEIPASS"):
|
if hasattr(sys, "_MEIPASS"):
|
||||||
files = glob.glob(os.path.join(getattr(sys, "_MEIPASS"), '**/*libcodec2*'), recursive=True)
|
files = glob.glob(os.path.join(getattr(sys, "_MEIPASS"), '**/*libcodec2*'), recursive=True)
|
||||||
|
@ -100,6 +100,8 @@ elif sys.platform in ["win32", "win64"]:
|
||||||
else:
|
else:
|
||||||
files = []
|
files = []
|
||||||
api = None
|
api = None
|
||||||
|
|
||||||
|
print(files)
|
||||||
for file in files:
|
for file in files:
|
||||||
try:
|
try:
|
||||||
api = ctypes.CDLL(file)
|
api = ctypes.CDLL(file)
|
||||||
|
|
|
@ -1,10 +1,13 @@
|
||||||
import time
|
import sys
|
||||||
|
import os
|
||||||
|
script_directory = os.path.dirname(os.path.abspath(__file__))
|
||||||
|
sys.path.append(script_directory)
|
||||||
|
|
||||||
|
|
||||||
|
import time
|
||||||
from flask import Flask, request, jsonify, make_response, abort, Response
|
from flask import Flask, request, jsonify, make_response, abort, Response
|
||||||
from flask_sock import Sock
|
from flask_sock import Sock
|
||||||
from flask_cors import CORS
|
from flask_cors import CORS
|
||||||
import os
|
|
||||||
import sys
|
|
||||||
import serial_ports
|
import serial_ports
|
||||||
from config import CONFIG
|
from config import CONFIG
|
||||||
import audio
|
import audio
|
||||||
|
@ -33,7 +36,7 @@ from schedule_manager import ScheduleManager
|
||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
CORS(app, resources={r"/*": {"origins": "*"}})
|
CORS(app, resources={r"/*": {"origins": "*"}})
|
||||||
sock = Sock(app)
|
sock = Sock(app)
|
||||||
MODEM_VERSION = "0.15.2-alpha"
|
MODEM_VERSION = "0.15.3-alpha"
|
||||||
|
|
||||||
# set config file to use
|
# set config file to use
|
||||||
def set_config():
|
def set_config():
|
||||||
|
@ -343,7 +346,7 @@ def stop_server():
|
||||||
print('Server shutdown...')
|
print('Server shutdown...')
|
||||||
print("------------------------------------------")
|
print("------------------------------------------")
|
||||||
|
|
||||||
if __name__ == "__main__":
|
def main():
|
||||||
app.config['SOCK_SERVER_OPTIONS'] = {'ping_interval': 10}
|
app.config['SOCK_SERVER_OPTIONS'] = {'ping_interval': 10}
|
||||||
# define global MODEM_VERSION
|
# define global MODEM_VERSION
|
||||||
app.MODEM_VERSION = MODEM_VERSION
|
app.MODEM_VERSION = MODEM_VERSION
|
||||||
|
@ -382,3 +385,5 @@ if __name__ == "__main__":
|
||||||
|
|
||||||
app.run(modemaddress, modemport)
|
app.run(modemaddress, modemport)
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
29
setup.py
Normal file
29
setup.py
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
from setuptools import setup, find_packages
|
||||||
|
|
||||||
|
# Reading requirements.txt for dependencies
|
||||||
|
with open('requirements.txt') as f:
|
||||||
|
required = f.read().splitlines()
|
||||||
|
|
||||||
|
setup(
|
||||||
|
name='freedata-server',
|
||||||
|
version='0.15.3',
|
||||||
|
packages=find_packages(where='.'),
|
||||||
|
package_dir={'': '.'},
|
||||||
|
install_requires=required,
|
||||||
|
python_requires='>=3.9',
|
||||||
|
author='DJ2LS',
|
||||||
|
author_email='dj2ls@proton.me',
|
||||||
|
description='A free, open-source, multi-platform application for sending files and messages, using the codec2 HF modems.',
|
||||||
|
url='https://freedata.app',
|
||||||
|
license='GPL3.0',
|
||||||
|
entry_points={
|
||||||
|
'console_scripts': [
|
||||||
|
'freedata-server=modem.server:main', # Points to the main() function in server.py
|
||||||
|
],
|
||||||
|
},
|
||||||
|
include_package_data=True, # Ensure non-python files are included if specified
|
||||||
|
package_data={
|
||||||
|
# Include all files under any directory within the 'modem' package
|
||||||
|
'modem': ['lib/**/*'], # Recursive include for all files in 'lib' and its subdirectories
|
||||||
|
},
|
||||||
|
)
|
|
@ -1,3 +1,3 @@
|
||||||
#autopep8 --in-place --select W291,W293,W391,E231 --ignore E501 ../modem.py ../deprecated_data_handler.py ../deprecated_main.py ../deprecated_sock.py ../deprecated_static.py ../helpers.py
|
#autopep8 --in-place --select W291,W293,W391,E231 --ignore E501 ../encoder_decoder.py ../deprecated_data_handler.py ../deprecated_main.py ../deprecated_sock.py ../deprecated_static.py ../helpers.py
|
||||||
autopep8 --in-place --ignore E501 ../modem.py ../data_handler.py ../main.py ../sock.py ../static.py ../helpers.py
|
autopep8 --in-place --ignore E501 ../modem.py ../data_handler.py ../main.py ../sock.py ../static.py ../helpers.py
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue