diff --git a/.github/workflows/pip_package.yml b/.github/workflows/pip_package.yml index 78d5a76e..76211ee3 100644 --- a/.github/workflows/pip_package.yml +++ b/.github/workflows/pip_package.yml @@ -25,7 +25,7 @@ jobs: run: | python -m pip install --upgrade pip pip install -r requirements.txt - pip install wheel + pip install wheel build - name: Build GUI working-directory: freedata_gui @@ -35,7 +35,7 @@ jobs: - name: Build package run: | - python setup.py sdist bdist_wheel + python -m build - name: Publish to PyPI uses: pypa/gh-action-pypi-publish@v1.13.0 diff --git a/.gitignore b/.gitignore index 7e63f6f0..787687e9 100644 --- a/.gitignore +++ b/.gitignore @@ -35,3 +35,7 @@ venv_3.11/ venv/ test_venv/ freedata_server/lib/codec2/codec2/ + +# `python -m build` artifacts +/dist/ +/*.egg-info/ diff --git a/freedata_server/server.py b/freedata_server/server.py index 38738509..329ac368 100644 --- a/freedata_server/server.py +++ b/freedata_server/server.py @@ -132,7 +132,7 @@ def open_browser_after_delay(url, delay=2): webbrowser.open(url, new=0, autoraise=True) -if __name__ == "__main__": +def main(): host = ctx.config_manager.config.get('NETWORK', {}).get('modemaddress') or '0.0.0.0' port = int(ctx.config_manager.config.get('NETWORK', {}).get('modemport', 5000)) @@ -150,3 +150,6 @@ if __name__ == "__main__": threading.Thread(target=open_browser_after_delay, args=(url, 2), daemon=True).start() uvicorn.run(app, host=host, port=port, log_config=None, log_level="info") + +if __name__ == "__main__": + sys.exit(main()) diff --git a/pyproject.toml b/pyproject.toml index f03eac86..4957f5be 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -42,8 +42,7 @@ dependencies = [ "chardet", "colorama", "ordered-set", - "nuitka<=2.8.4", - "pyinstaller", + "sqlalchemy", "websocket-client", "fastapi[standard]", "uvicorn[standard]", @@ -64,7 +63,6 @@ test = [ "pytest-cov", "pytest-rerunfailures", "pick", - "sqlalchemy", ] dev = [ "autopep8", @@ -72,6 +70,23 @@ dev = [ "isort", "pycodestyle", ] +build = [ + "nuitka<=2.8.4", + "pyinstaller", +] + +[tool.setuptools.packages.find] +where = [ "." ] +exclude = [ + "tools*", +] + +[tool.setuptools.package-data] +freedata_server = [ "lib/**/*" ] +freedata_gui = [ "dist/**/*" ] + +[tool.setuptools.dynamic] +version = { attr = "freedata_server.constants.MODEM_VERSION"} [tool.pytest.ini_options] testpaths = [ "tests" ] diff --git a/requirements.txt b/requirements.txt index 9edb0d90..4530c2e4 100644 --- a/requirements.txt +++ b/requirements.txt @@ -11,6 +11,7 @@ ordered-set nuitka<=2.8.4 pyinstaller websocket-client +sqlalchemy fastapi[standard] uvicorn[standard] @@ -23,4 +24,3 @@ pytest pytest-cov pytest-rerunfailures pick -sqlalchemy diff --git a/setup.py b/setup.py deleted file mode 100644 index 8b8f5e3b..00000000 --- a/setup.py +++ /dev/null @@ -1,36 +0,0 @@ -from setuptools import setup, find_packages -import freedata_server.constants as constants -# Reading requirements.txt for dependencies -with open('requirements.txt') as f: - required = f.read().splitlines() - -with open("README.md", "r", encoding="utf-8") as fh: - long_description = fh.read() - -setup( - name='freedata', - version=constants.MODEM_VERSION, - packages=find_packages(where='.'), - package_dir={'': '.'}, - install_requires=required, - python_requires='>=3.10', - author='DJ2LS', - author_email='dj2ls@proton.me', - description='INFO: THIS PACKAGE IS NOT YET WORKING - PLEASE USE THE OFFICIAL SCRIPT BASED SETUP', - long_description=long_description, - long_description_content_type="text/markdown", - url='https://github.com/DJ2LS/FreeDATA', - license='GPL3.0', - entry_points={ - 'console_scripts': [ - 'freedata=freedata_server.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 'freedata_server' package - 'freedata_server': ['lib/**/*'], # Recursive include for all files in 'lib' and its subdirectories - 'freedata_gui': ['dist/**/*'], # gui folder - - }, -)