From 6a245b9864b528e5381007f4dd41fc57f411d351 Mon Sep 17 00:00:00 2001 From: Thomas Boyer-Chammard <49786685+thomas-bc@users.noreply.github.com> Date: Wed, 13 Dec 2023 15:14:44 -0800 Subject: [PATCH] Add pyproject.toml (#153) * Add pyproject.toml * Restrict workflow runs * spelling * Add notes for legacy configs * Add Python3.12 classifier --- .github/actions/spelling/excludes.txt | 2 + .github/workflows/codeql-security-scan.yml | 4 +- .github/workflows/fprime-gds-tests.yml | 7 +- .github/workflows/gds-cli-tests.yml | 7 +- .github/workflows/publish.yml | 42 ++++--- pyproject.toml | 87 ++++++++++++++ setup.py | 127 +-------------------- 7 files changed, 131 insertions(+), 145 deletions(-) create mode 100644 pyproject.toml diff --git a/.github/actions/spelling/excludes.txt b/.github/actions/spelling/excludes.txt index 48b683d1..90231acf 100644 --- a/.github/actions/spelling/excludes.txt +++ b/.github/actions/spelling/excludes.txt @@ -43,3 +43,5 @@ ignore$ \.xlsx$ \.xsd$ \.ico$ +pyproject.toml +setup.py diff --git a/.github/workflows/codeql-security-scan.yml b/.github/workflows/codeql-security-scan.yml index b0e33bdc..e40e85b5 100644 --- a/.github/workflows/codeql-security-scan.yml +++ b/.github/workflows/codeql-security-scan.yml @@ -4,10 +4,10 @@ name: "CodeQL Security Scan" on: push: - branches: [ master, devel ] + branches: [ devel ] pull_request: # The branches below must be a subset of the branches above - branches: [ master, devel ] + branches: [ devel ] jobs: analyze: diff --git a/.github/workflows/fprime-gds-tests.yml b/.github/workflows/fprime-gds-tests.yml index f3592e0f..9a17cbfc 100644 --- a/.github/workflows/fprime-gds-tests.yml +++ b/.github/workflows/fprime-gds-tests.yml @@ -1,6 +1,11 @@ name: fprime-gds tests -on: [pull_request, push] +on: + push: + branches: [ devel ] + pull_request: + # The branches below must be a subset of the branches above + branches: [ devel ] jobs: Unit-tests: diff --git a/.github/workflows/gds-cli-tests.yml b/.github/workflows/gds-cli-tests.yml index e8a8b302..c2a3e8c9 100644 --- a/.github/workflows/gds-cli-tests.yml +++ b/.github/workflows/gds-cli-tests.yml @@ -1,6 +1,11 @@ name: GDS CLI Tests -on: [pull_request, push] +on: + push: + branches: [ devel ] + pull_request: + # The branches below must be a subset of the branches above + branches: [ devel ] env: DICTIONARY: ./.github/resources/RefTopologyAppDictionary.xml diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index f1386299..fb5c7b19 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -1,25 +1,29 @@ -name: Build Package +name: Build and Publish Package + on: release: types: [published] + jobs: - Build-PyPI-Package: + Release-PyPI-Package: runs-on: ubuntu-latest + permissions: + # this permission is mandatory for trusted publishing + id-token: write steps: - - name: "Checkout Repository" - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - name: Test PyPI - uses: fprime-community/publish-pypi@main - env: - TWINE_PASSWORD: ${{ secrets.TESTPYPI_CREDENTIAL }} - with: - package: "fprime-gds" - - name: PyPI - uses: fprime-community/publish-pypi@main - env: - TWINE_PASSWORD: ${{ secrets.PYPI_CREDENTIAL }} - with: - repo: "pypi" - package: "fprime-gds" + - name: "Checkout Repository" + uses: actions/checkout@v3 + with: + fetch-depth: 0 + - name: Setup Python + run: pip install -U build twine + - name: Build distributions + run: python -m build + - name: Check distributions + run: twine check dist/* + - name: Publish distributions to TestPyPI + uses: pypa/gh-action-pypi-publish@release/v1 + with: + repository-url: https://test.pypi.org/legacy/ + - name: Publish distributions to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 00000000..98b6afd1 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,87 @@ +[build-system] +requires = ["setuptools", "setuptools_scm[toml]>=6.2", "wheel"] +build-backend = "setuptools.build_meta" + +[project] +name = "fprime-gds" +dynamic = ["version"] +description = "F Prime Flight Software Ground Data System layer" +readme = "README.md" +requires-python = ">=3.8" +license = {file = "LICENSE.txt"} +keywords = ["fprime", "embedded", "nasa", "flight", "software"] +authors = [ + {name = "Michael Starch", email = "Michael.D.Starch@jpl.nasa.gov"}, + {name = "Thomas Boyer-Chammard", email = "Thomas.Boyer.Chammard@jpl.nasa.gov"}, +] +classifiers = [ + "Development Status :: 5 - Production/Stable", + "Intended Audience :: Developers", + "Operating System :: Unix", + "Operating System :: POSIX", + "Programming Language :: Python", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: Implementation :: CPython", + "Programming Language :: Python :: Implementation :: PyPy", + "License :: OSI Approved :: Apache Software License", +] +dependencies = [ + "flask>=3.0.0", + "flask_compress>=1.11", + "pyzmq>=24.0.1", + "pexpect>=4.8.0", + "pytest>=6.2.4", + "flask_restful>=0.3.8", + "fprime-tools>=3.1.2a1", + "argcomplete>=1.12.3", + "Jinja2>=2.11.3", + "openpyxl>=3.0.10", + "pyserial>=3.5", +] + +[project.urls] +Homepage = "https://fprime.jpl.nasa.gov" +Documentation = "https://nasa.github.io/fprime/" +Repository = "https://github.com/fprime-community/fprime-gds" + +#### +# Entry Points: +# +# Defines the list of entry-level (scripts) that are defined by this package. This allows +# standard use of utilities that ship as part of F prime. +#### +[project.scripts] +fprime-cli = "fprime_gds.executables.fprime_cli:main" +fprime-seqgen = "fprime_gds.common.tools.seqgen:main" + +[project.gui-scripts] +fprime-gds = "fprime_gds.executables.run_deployment:main" + +# For Pytest fixtures +[project.entry-points."pytest11"] +fprime_test_api = "fprime_gds.common.testing_fw.pytest_integration" + +#### +# setuptools_scm dynamically generates version number from git, as well as automatically +# include all data files tracked by git (e.g. flash/static/** files). +# See https://setuptools.pypa.io/en/latest/userguide/datafiles.html +#### +[tool.setuptools_scm] + + +#### +# Additional notes +# +# With regards to the configuration of the older versions of setup.py: +# - package_data: included by default, and setuptools_scm will automatically include all files tracked by git +# - package discovery (src/): setuptools will automatically discover all packages as we use the src-layout +# +# Reference: +# - https://setuptools.pypa.io/en/latest/userguide/pyproject_config.html +# - https://setuptools.pypa.io/en/latest/userguide/package_discovery.html#src-layout +#### diff --git a/setup.py b/setup.py index e42a5ae0..158a9c28 100644 --- a/setup.py +++ b/setup.py @@ -1,123 +1,6 @@ -#!/usr/bin/env python -#### -# fprime_gds Python Package: -# -# The F prime GDS layer provides a basic GDS intended to enable the user to test F prime -# distributions. In addition it provides an integration and test layer to allow for automated -# testing of F prime distributions. -# -# Endpoints: -# - fprime-gds: run the F prime GDS -# -# Optional Features: -# - Test API XLS Output: Provides XLS output with the Test API. test-api-xls -# - TK GUI: if installed with Python 2, the TK GUI will be installed -# -# User Install / Upgrade: -# ``` -# pip install --upgrade fprime-gds -# ``` -# -# Developer and Dynamic Installation: -# ``` -# pip install -e ./Gds -# ``` -### +# setup.py is kept to support legacy builds +# https://setuptools.pypa.io/en/latest/userguide/pyproject_config.html +from setuptools import setup -from setuptools import find_packages, setup - -#### -# GDS Packages: -# -# The GDS package 'tkgui' is only allowed as part of a Python 2 distribution. This code -# excludes the 'fprime_gds.tkgui' package. -#### -gds_packages = find_packages("src", exclude=["*tkgui*"]) -# Setup a python package using setup-tools. This is a newer (and more recommended) technology -# than distutils. -setup( - #### - # Package Description: - # - # Basic package information. Describes the package and the data contained inside. This - # information should match the F prime description information. - #### - name="fprime_gds", - use_scm_version={"root": ".", "relative_to": __file__}, - license="Apache 2.0 License", - description="F Prime Flight Software Ground Data System layer.", - long_description=""" -This package contains the Python files used to run the F prime Ground Data System and Test API. -It is intended to supply the user with the ability to test F prime flight software in an -integrated configuration with ground in-the-loop. - """, - url="https://github.com/nasa/fprime", - keywords=["fprime", "gds", "embedded", "nasa"], - project_urls={"Issue Tracker": "https://github.com/nasa/fprime/issues"}, - # Package author, not F prime author - author="Michael Starch", - author_email="Michael.D.Starch@jpl.nasa.gov", - #### - # Included Packages: - # - # Will search for and included all python packages under the "src" directory. The root package - # is set to 'src' to avoid package names of the form src.fprime_gds. This will also ensure that - # files included in MANIFEST.in are included in their respective packages. - #### - packages=gds_packages, # See above for how GDS packages are found - package_dir={"": "src"}, - package_data={ - "fprime_gds": ["flask/static/*", "flask/static/*/*", "flask/static/*/*/*"] - }, - include_package_data=True, - zip_safe=False, # HTML templates require normal FIO access. - #### - # Entry Points: - # - # Defines the list of entry-level (scripts) that are defined by this package. This allows - # standard use of utilities that ship as part of F prime. - #### - entry_points={ - "gui_scripts": ["fprime-gds = fprime_gds.executables.run_deployment:main"], - "console_scripts": [ - "fprime-cli = fprime_gds.executables.fprime_cli:main", - "fprime-seqgen = fprime_gds.common.tools.seqgen:main", - ], - "pytest11": ["fprime_test_api = fprime_gds.common.testing_fw.pytest_integration"] - }, - #### - # Classifiers: - # - # Standard Python classifiers used to describe this package. - #### - classifiers=[ - # complete classifier list: http://pypi.python.org/pypi?%3Aaction=list_classifiers - "Development Status :: 5 - Production/Stable", - "Intended Audience :: Developers", - "Operating System :: Unix", - "Operating System :: POSIX", - "Programming Language :: Python", - "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.7", - "Programming Language :: Python :: 3.8", - "Programming Language :: Python :: 3.9", - "Programming Language :: Python :: 3.10", - "Programming Language :: Python :: Implementation :: CPython", - "Programming Language :: Python :: Implementation :: PyPy", - ], - python_requires=">=3.7", - setup_requires=["setuptools_scm"], - install_requires=[ - "flask>=3.0.0", - "flask_compress>=1.11", - "pyzmq>=24.0.1", - "pexpect>=4.8.0", - "pytest>=6.2.4", - "flask_restful>=0.3.8", - "fprime-tools>=3.1.2a1", - "argcomplete>=1.12.3", - "Jinja2>=2.11.3", - "openpyxl>=3.0.10", - "pyserial>=3.5", - ], -) +# Configuration is in pyproject.toml +setup()