Skip to content

Commit

Permalink
IMPROVEMENT: simplify and speedup pypi publishing
Browse files Browse the repository at this point in the history
  • Loading branch information
amilcarlucas committed Jan 14, 2025
1 parent 6fa0cfe commit 2f7c993
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 14 deletions.
16 changes: 12 additions & 4 deletions .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,30 @@ jobs:
permissions:
id-token: write

env:
UV_SYSTEM_PYTHON: 1

steps:
- name: Checkout
uses: actions/checkout@v4

# https://docs.astral.sh/uv/guides/integration/github/
- name: Install uv and set the python version
uses: astral-sh/setup-uv@v4
with:
python-version: '3.12'

- name: Set up Python 3.12
uses: actions/setup-python@v5
with:
python-version: '3.12'

- name: Install dependencies
run: |
python -m pip install -U pip wheel pymavlink build
pip install -U .
uv pip install build packaging pip setuptools wheel
- name: Build package
run: python -m build --wheel
run: python -m build

- name: Publish package distribuitions to PyPI
- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
6 changes: 3 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,9 @@ changelog = "https://github.com/ArduPilot/MethodicConfigurator/releases"

[tool.setuptools]
packages = ["ardupilot_methodic_configurator"]
package-data = {ardupilot_methodic_configurator = ["*.param", "*.jpg", "*.json", "*.xml", "*.mo", "*.png"]}
exclude-package-data = {ardupilot_methodic_configurator = ["test.xml"]}
include-package-data = true

[tool.setuptools.package-data]
ardupilot_methodic_configurator = ["*.param", "*.jpg", "*.json", "*.xml", "*.mo", "*.png"]

[tool.setuptools.dynamic]
version = {attr = "ardupilot_methodic_configurator.__version__"}
Expand Down
38 changes: 38 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/usr/bin/env python3

"""
Creates the ardupilot_methodic_configurator pip python package.
This file is part of Ardupilot methodic configurator. https://github.com/ArduPilot/MethodicConfigurator
SPDX-FileCopyrightText: 2024 Amilcar do Carmo Lucas <[email protected]>
SPDX-License-Identifier: GPL-3.0-or-later
"""

import fnmatch
import os

from setuptools import setup


# recursively find all files that match the globs and return tuples with their directory and a list of relative paths
def find_data_files(globs: list[str]) -> list[tuple[str, list[str]]]:
data_files_path_base = "ardupilot_methodic_configurator"
ret = []
for dirpath, _dirnames, filenames in os.walk(data_files_path_base):
data_files = []
for glob in globs:
for filename in fnmatch.filter(filenames, glob):
relative_path = os.path.join(dirpath, filename)
data_files.append(relative_path)
if data_files:
ret.append((os.path.relpath(dirpath, data_files_path_base), data_files))
return ret


setup(
packages=["ardupilot_methodic_configurator"],
# this is used by bdist
data_files=[*find_data_files(["*.param", "*.jpg", "*.json", "*.xml", "*.mo"])],
)
25 changes: 18 additions & 7 deletions test_pip_package.sh
Original file line number Diff line number Diff line change
@@ -1,25 +1,36 @@
#!/bin/bash

sudo pip uninstall -y MethodicConfigurator
pip uninstall -y MethodicConfigurator
sudo rm -Rf /usr/local/MethodicConfigurator/

sudo pip uninstall -y ardupilot_methodic_configurator
pip uninstall -y ardupilot_methodic_configurator
sudo rm -Rf /usr/local/ardupilot_methodic_configurator/

sudo rm -Rf /usr/local/vehicle_templates/
sudo rm -Rf /usr/local/locale/
rm -Rf ~/.local/locale
rm -Rf ~/.local/vehicle_templates

rm -Rf ~/.local/MethodicConfigurator
rm -Rf ~/.local/bin/MethodicConfigurator
rm -Rf build dist/ MethodicConfigurator.egg-info/

rm -Rf ~/.local/ardupilot_methodic_configurator
rm -Rf ~/.local/bin/ardupilot_methodic_configurator
rm -Rf build dist/ ardupilot_methodic_configurator.egg-info/
python -m build --wheel .

# Use either this
sudo pip install -U dist/ardupilot_methodic_configurator-0.9.16-py3-none-any.whl
uv venv --python 3.12
source .venv/bin/activate
uv pip install -U build packaging pip setuptools wheel

# Or this
#pip install -U dist/ardupilot_methodic_configurator-0.9.16-py3-none-any.whl
python -m build

uv pip install -U dist/ardupilot_methodic_configurator-1.0.8-py3-none-any.whl

cd ..
ardupilot_methodic_configurator --language=pt
~/.local/bin/ardupilot_methodic_configurator --language=pt

ardupilot_methodic_configurator --language=pt --loglevel=DEBUG
ls -larct /usr/local

0 comments on commit 2f7c993

Please sign in to comment.