Skip to content

Commit

Permalink
update to get autoconf to work
Browse files Browse the repository at this point in the history
- moved the configure.ac to the root
- re-removed the PKGBUILD that was added to get the build passing
- updated the readme/installs to have the right commands and fix a
  couple typo's
- updated the templates used for autoconf to use the correct paths/vars
- added cleanup/build script to use for cutting new release
- updated pyproject.toml to include the service file once it's
  generated
- fixed some default values and updated the .gitignore
  • Loading branch information
mcgillij committed Jul 7, 2024

Verified

This commit was signed with the committer’s verified signature.
timofurrer Timo Furrer
1 parent 1347791 commit 529fd3d
Showing 11 changed files with 41 additions and 49 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -3,6 +3,10 @@ __pycache__/
*.py[cod]
*$py.class

# PKGBUILD in the root that I use to build the package and the tarball/package
PKGBUILD
*.gz
*.zst
# C extensions
*.so

12 changes: 6 additions & 6 deletions INSTALL.md
Original file line number Diff line number Diff line change
@@ -6,14 +6,14 @@ At runtime: `python`, `numpy`, `click`, `rich` and `pyyaml`
Our standard builds use pyproject, mainly with poetry.

# Preparing the sources
The dist files are template files, which means you must first `autoconf` them. You could also just `sed` all the `.in` files if you don't want to use autotools.
The dist files are template files, which means you must first `autoconf` them. You could also just `sed` all the `.in` files if you don't want to use `autotools`.

``` sh
git clone https://github.com/mcgillij/amdfan.git
cd amdfan

autoconf
./configure --prefix=/usr --libdir=/usr/lib
./configure --prefix=/usr --libdir=/usr/lib --bindir=/usr/bin
```

# Service files
@@ -23,19 +23,19 @@ There are two ways to obtain the systemd service file. One is available during r
amdfan print-default --service | sudo tee /usr/lib/systemd/system/amdfan.service
```

If you ran `./configure` succesfully, you'll also find the service files for OpenRC and systemd under `dist/${init}/`.
If you ran `./configure` successfully, you'll also find the service files for OpenRC and systemd under `dist/${init}/`.


# Configuration files
Similiar to above, you can obtain the sources from the runtime. This is not necessary, as this file is generated automatically after the daemon runs for the first time.
Similarly as above, you can obtain the sources from the runtime. This is not necessary, as this file is generated automatically after the daemon runs for the first time.

``` bash
amdfan print-default --configuration | sudo tee /etc/amdfan.yml
```


# Executable files
The executable files are contained within amdfan. This directory is a python module, and can either be loaded as `python -m amdgpu`. If you want to import the module, you may be interested in checking out `amdfan.commands`, which contains most of the subcommands.
The executable files are contained within amdfan. This directory is a python module, and can either be loaded as `python -m amdfan`. If you want to import the module, you may be interested in checking out `amdfan.commands`, which contains most of the subcommands.

Otherwise, just use python-exec with something like

@@ -50,7 +50,7 @@ if __name__ == '__main__':


# Installing from PyPi
You can also install amdfan from pypi using something like poetry.
You can also install amdfan from PyPi using something like poetry.

``` bash
poetry init
27 changes: 0 additions & 27 deletions PKGBUILD

This file was deleted.

4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -56,7 +56,7 @@ There are two ways to control your fans with Amdfan. Note that in order to contr

The recommended way is through a system service started at boot. This will control the fans based on the detected temperature at a given interval.

In case you don't want to use a service, you may also control the fans manually. While this is only adviced to do when first setting up your configuration, keep in mind you can also use it to temporarily take control away from the daemon until you revert the fan speed back to `auto`.
In case you don't want to use a service, you may also control the fans manually. While this is only advised to do when first setting up your configuration, keep in mind you can also use it to temporarily take control away from the daemon until you revert the fan speed back to `auto`.

![screenshot](https://raw.githubusercontent.com/mcgillij/amdfan/main/images/manual.png)

@@ -98,7 +98,7 @@ If a configuration file is not found, a default one will be generated. If you wa
- `frequency` (default `5`): how often (in seconds) we wait between updates
- `cards` (required): a list of card names (from `/sys/class/drm`) which we want to control.

Note! You can send a SIGHUP signal to the daemon to request a reload of the config without restarting the whole service.
Note! You can send a **SIGHUP** signal to the daemon to request a reload of the config without restarting the whole service.

# Install

3 changes: 1 addition & 2 deletions amdfan/commands.py
Original file line number Diff line number Diff line change
@@ -54,7 +54,6 @@ def cli(
help="Run the controller",
)
@click.option("--notification-fd", type=int)
# @click.option("--background", is_flag=True, default=True)
def run_daemon(notification_fd):
FanController.start_daemon(
notification_fd=notification_fd, pidfile=os.path.join(PIDFILE_DIR, "amdfan.pid")
@@ -77,7 +76,7 @@ def show_table(cards: Dict) -> Table:
def monitor_cards(fps, single_run) -> None:
scanner = Scanner()
if not single_run:
c.print("AMD Fan Control - ctrl-c to quit")
c.print("AMD Fan Control - Ctrl-c to quit")

with Live(refresh_per_second=fps) as live:
while 1:
3 changes: 2 additions & 1 deletion amdfan/defaults.py
Original file line number Diff line number Diff line change
@@ -39,7 +39,8 @@
Description=amdfan controller
[Service]
ExecStart=/usr/bin/amdfan --daemon
ExecStart=/usr/bin/amdfan daemon
ExecReload=kill -HUP $MAINPID
Restart=always
[Install]
15 changes: 15 additions & 0 deletions clean_build
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#####!/bin/bash
echo "cleaning up previous run"
rm -rf dist/*.whl dist/*.gz configure config.status autom4te.cache config.log *.gz *.zst *.log
echo "autoconf"
autoconf
echo "./configure"
./configure --prefix=/usr --libdir=/usr/lib --bindir=/usr/bin
echo "Copy the PKGBUILD to the root dir for running makepkg"
cp dist/pacman/PKGBUILD .
echo "running poetry build"
poetry build
echo "getting the md5sum of the tarball"
md5sum dist/*.gz
echo "Copying the tarball to the root dir"
cp dist/*.gz .
2 changes: 1 addition & 1 deletion dist/configure.ac → configure.ac
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

AC_INIT([amdfan], [0.1.28])
AC_INIT([amdfan], [0.2.1])
AC_CONFIG_FILES([dist/pacman/PKGBUILD])
AC_CONFIG_FILES([dist/openrc/amdfan dist/systemd/amdfan.service])
AC_OUTPUT
14 changes: 7 additions & 7 deletions dist/pacman/PKGBUILD.in
Original file line number Diff line number Diff line change
@@ -3,16 +3,16 @@

pkgname=amdfan
pkgdesc="Python daemon for controlling the fans on amdgpu cards"
pkgver=0.1.28
pkgver=0.2.1
pkgrel=1
arch=('any')
license=('GPL2')
depends=('python' 'python-yaml' 'python-numpy' 'python-rich' 'python-click')
makedepends=('python-setuptools' 'python-poetry' 'python-build' 'python-installer')
makedepends=('python-poetry' 'python-build' 'python-installer')
url="https://github.com/mcgillij/amdfan"
source=("https://github.com/mcgillij/amdfan/releases/download/$pkgver/amdfan-$pkgver.tar.gz")
#source=("amdfan-$pkgver.tar.gz")
md5sums=('7fe30661ba0d5117f32e4bab1db76888')
#source=("https://github.com/mcgillij/amdfan/releases/download/$pkgver/amdfan-$pkgver.tar.gz")
source=("dist/amdfan-$pkgver.tar.gz")
md5sums=('6e4418082f1cf765d10552117c0895fe')

build() {
cd "$srcdir/$pkgname-$pkgver"
@@ -22,6 +22,6 @@ build() {
package() {
cd "$srcdir/$pkgname-$pkgver"
python -m installer --destdir="$pkgdir" dist/*.whl
mkdir -p "$pkgdir/@libdir@/systemd/system"
install -Dm644 amdfan/packaging/pacman/amdfan.service "$pkgdir/@libdir@/systemd/system/"
mkdir -p "$pkgdir@libdir@/systemd/system"
install -Dm644 dist/systemd/amdfan.service "$pkgdir@libdir@/systemd/system/"
}
2 changes: 1 addition & 1 deletion dist/systemd/amdfan.service.in
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@ After=multi-user.target
Requires=multi-user.target

[Service]
ExecStart=@bindir@/amdfan --daemon
ExecStart=@bindir@/amdfan daemon
ExecReload=kill -HUP $MAINPID
Restart=always

4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "amdfan"
version = "0.2.0"
version = "0.2.1"
description = "Fan monitor and controller for AMD gpus in Linux"
authors = ["mcgillij <mcgillivray.jason@gmail.com>"]
license = "GPL-2.0-only"
@@ -9,6 +9,7 @@ homepage = "https://mcgillij.dev/pages/amdfan.html"
repository = "https://github.com/mcgillij/amdfan"
documentation = "https://mcgillij.dev/pages/amdfan.html"
keywords = ["fan", "gpu", "temp", "monitor", "amd"]
include = ["dist/systemd/amdfan.service"]

This comment has been minimized.

Copy link
@mazunki

mazunki Jul 26, 2024

Contributor

hm, including these non-python files into the wheel is causing QA warning on my end. deleting this line from the ebuild is "trivial", but i'm wondering if there's a cleaner way to generate these for the prepared tarballs. keeping them as-is generates /usr/lib/python-$version/site-packages/dist/systemd/amdfan.service, which isn't meaningful

This comment has been minimized.

Copy link
@mcgillij

mcgillij Jul 26, 2024

Author Owner

I'm not 100% sure what todo with it, since if it's not in the tarball somewhere when I generate the arch package it won't have the service file. I can maybe take a look at some other python packages that would include a service file and see what they are doing.

This comment has been minimized.

Copy link
@mazunki

mazunki Jul 27, 2024

Contributor

i'm not sure what good practices are either. i think i would've generated the versioned tarball from ./clean_build, separating wheel/ (generated from poetry) and dist/ (generated from autotools), but i'm not sure. i'd love to know

for now i've just yeeted the include with sed in my ebuild, but eh

classifiers = [
"Environment :: Console",
"Environment :: GPU",
@@ -29,7 +30,6 @@ pyyaml = "^6.0"
click = "^8.1.3"
rich = "^13.0.0"


[tool.poetry.group.dev.dependencies]
pylint = "*"
flake8 = "*"

0 comments on commit 529fd3d

Please sign in to comment.