Support for pyproject.toml (#576)
* feat: support for pyproject.toml * Nix: Fix package to work with pyproject.toml --------- Co-authored-by: shadeyg56 <shadeyg56@gmail.com>
This commit is contained in:
parent
c3e2f83d7b
commit
37e12a4266
|
@ -60,7 +60,7 @@ function setup_venv {
|
|||
|
||||
# tool install
|
||||
function install {
|
||||
python3 setup.py install --record files.txt
|
||||
pip3 install .
|
||||
mkdir -p /usr/local/share/auto-cpufreq/
|
||||
cp -r scripts/ /usr/local/share/auto-cpufreq/
|
||||
cp -r images/ /usr/local/share/auto-cpufreq/
|
||||
|
|
|
@ -10,7 +10,7 @@ import time
|
|||
from click import UsageError
|
||||
from subprocess import call, run
|
||||
|
||||
sys.path.append("../")
|
||||
# sys.path.append("../")
|
||||
from auto_cpufreq.core import *
|
||||
from auto_cpufreq.power_helper import *
|
||||
|
|
@ -10,9 +10,12 @@ gi.require_version("Gtk", "3.0")
|
|||
from gi.repository import Gtk, GLib
|
||||
from auto_cpufreq.gui.app import ToolWindow
|
||||
|
||||
if __name__ == "__main__":
|
||||
def main():
|
||||
win = ToolWindow()
|
||||
win.connect("destroy", Gtk.main_quit)
|
||||
win.show_all()
|
||||
GLib.set_prgname("auto-cpufreq")
|
||||
Gtk.main()
|
||||
Gtk.main()
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
|
@ -13,7 +13,8 @@ import click
|
|||
import pickle
|
||||
import warnings
|
||||
import configparser
|
||||
import pkg_resources
|
||||
# import pkg_resources
|
||||
import importlib.metadata
|
||||
from math import isclose
|
||||
from pathlib import Path
|
||||
from shutil import which
|
||||
|
@ -204,9 +205,26 @@ def new_update(custom_dir):
|
|||
print(f"package cloned to directory {custom_dir}")
|
||||
run(['./auto-cpufreq-installer'], input='i\n', encoding='utf-8')
|
||||
|
||||
def get_literal_version(package_name):
|
||||
try:
|
||||
package_metadata = importlib.metadata.metadata(package_name)
|
||||
|
||||
package_name = package_metadata['Name']
|
||||
metadata_version = package_metadata['Version']
|
||||
|
||||
numbered_version, _, git_version = metadata_version.partition("+")
|
||||
|
||||
# Construct the literal version string
|
||||
literal_version = f"{numbered_version}+{git_version}"
|
||||
|
||||
return literal_version
|
||||
|
||||
except importlib.metadata.PackageNotFoundError:
|
||||
return f"Package '{package_name}' not found"
|
||||
|
||||
# return formatted version for a better readability
|
||||
def get_formatted_version():
|
||||
literal_version = pkg_resources.require("auto-cpufreq")[0].version
|
||||
literal_version = get_literal_version("auto-cpufreq")
|
||||
splitted_version = literal_version.split("+")
|
||||
formatted_version = splitted_version[0]
|
||||
|
||||
|
|
|
@ -1,16 +1,19 @@
|
|||
{ lib, python310Packages, fetchFromGitHub, callPackage, pkgs, version ? "git"}:
|
||||
{ lib, python310Packages, fetchFromGitHub, callPackage, pkgs}:
|
||||
|
||||
python310Packages.buildPythonPackage rec {
|
||||
pname = "auto-cpufreq";
|
||||
inherit version;
|
||||
# use pyproject.toml instead of setup.py
|
||||
format = "pyproject";
|
||||
|
||||
pname = "auto-cpufreq";
|
||||
version = "2.0.0dev";
|
||||
src = ../.;
|
||||
|
||||
|
||||
nativeBuildInputs = with pkgs; [ wrapGAppsHook gobject-introspection ];
|
||||
|
||||
buildInputs = with pkgs; [ gtk3 ];
|
||||
buildInputs = with pkgs; [ gtk3 python310Packages.poetry-core ];
|
||||
|
||||
propagatedBuildInputs = with python310Packages; [ requests pygobject3 click distro psutil setuptools setuptools-git-versioning ];
|
||||
propagatedBuildInputs = with python310Packages; [ requests pygobject3 click distro psutil setuptools poetry-dynamic-versioning ];
|
||||
|
||||
doCheck = false;
|
||||
pythonImportsCheck = [ "auto_cpufreq" ];
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,49 @@
|
|||
[tool.poetry]
|
||||
name = "auto-cpufreq"
|
||||
version = "2.0.0"
|
||||
description = "Automatic CPU speed & power optimizer for Linux"
|
||||
authors = ["Adnan Hodzic <adnan@hodzic.org>"]
|
||||
license = "GPL-3.0-or-later"
|
||||
readme = "README.md"
|
||||
classifiers=[
|
||||
"Development Status :: 5 - Production/Stable",
|
||||
"Intended Audience :: Developers",
|
||||
"Operating System :: POSIX :: Linux",
|
||||
"Environment :: Console",
|
||||
"Natural Language :: English"
|
||||
]
|
||||
keywords=["linux", "cpu", "speed", "power", "frequency", "turbo", "optimzier", "auto", "cpufreq"]
|
||||
repository = "https://github.com/AdnanHodzic/auto-cpufreq"
|
||||
documentation = "https://github.com/AdnanHodzic/auto-cpufreq#readme"
|
||||
packages = [
|
||||
{ include = "./auto_cpufreq" },
|
||||
{ include = "./auto_cpufreq/gui" },
|
||||
]
|
||||
|
||||
[tool.poetry.dependencies]
|
||||
python = "^3.8"
|
||||
psutil = "^5.9.5"
|
||||
click = "^8.1.0"
|
||||
distro = "^1.8.0"
|
||||
requests = "^2.31.0"
|
||||
PyGObject = "^3.46.0"
|
||||
|
||||
[tool.poetry.group.dev.dependencies]
|
||||
poetry = "^1.6.1"
|
||||
|
||||
[build-system]
|
||||
requires = ["poetry-core>=1.0.0", "poetry-dynamic-versioning>=1.0.0,<2.0.0"]
|
||||
build-backend = "poetry_dynamic_versioning.backend"
|
||||
|
||||
[tool.poetry.scripts]
|
||||
auto-cpufreq = "auto_cpufreq.bin.auto_cpufreq:main"
|
||||
auto-cpufreq-gtk = "auto_cpufreq.bin.auto_cpufreq_gtk:main"
|
||||
|
||||
# https://github.com/mtkennerly/poetry-dynamic-versioning
|
||||
[tool.poetry-dynamic-versioning]
|
||||
enable = true
|
||||
vcs = "git"
|
||||
format = "v{base}+{commit}"
|
||||
|
||||
# SideNote
|
||||
# Regarding zip_safe = https://setuptools.pypa.io/en/latest/deprecated/zip_safe.html
|
|
@ -3,7 +3,7 @@
|
|||
# load python virtual environment
|
||||
venv_dir=/opt/auto-cpufreq/venv
|
||||
. "${venv_dir}/bin/activate"
|
||||
python_command="${venv_dir}/bin/python ${venv_dir}/bin/auto-cpufreq-gtk"
|
||||
python_command="${venv_dir}/bin/auto-cpufreq-gtk"
|
||||
|
||||
# if [ "$XDG_SESSION_TYPE" = "wayland" ] ; then
|
||||
# # necessary for running on wayland
|
||||
|
|
Loading…
Reference in New Issue