Skip to content

Commit

Permalink
remove post_install.py, use only meson.build and .in files; use versi…
Browse files Browse the repository at this point in the history
…on.py instead of COMMIT and VERSION files; rename Utils.get_ignis_commit_hash() to Utils.get_ignis_commit()
  • Loading branch information
linkfrg committed Aug 3, 2024
1 parent 1d82ad3 commit ec8c5bd
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 61 deletions.
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,3 @@ docs/_build
generated
.vscode
build
ignis/VERSION
ignis/COMMIT
1 change: 0 additions & 1 deletion VERSION

This file was deleted.

6 changes: 2 additions & 4 deletions ignis/__init__.py → ignis/__init__.py.in
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,5 @@

from gi.repository import GIRepository # noqa: E402

GIRepository.Repository.prepend_library_path("/usr/lib/ignis")
GIRepository.Repository.prepend_search_path("/usr/lib/ignis")
GIRepository.Repository.prepend_library_path("/usr/lib/x86_64-linux-gnu/ignis")
GIRepository.Repository.prepend_search_path("/usr/lib/x86_64-linux-gnu/ignis")
GIRepository.Repository.prepend_library_path("@LIBDIR@")
GIRepository.Repository.prepend_search_path("@LIBDIR@")
20 changes: 4 additions & 16 deletions ignis/utils/get_ignis_version.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
import os

IGNIS_INSTALL_DIR = f"{os.path.dirname(os.path.abspath(__file__))}/.."

VERSION_FILE = f"{IGNIS_INSTALL_DIR}/VERSION"
COMMIT = f"{IGNIS_INSTALL_DIR}/COMMIT"

from ignis.version import __version__, __commit__

def get_ignis_version() -> str:
"""
Expand All @@ -13,20 +7,14 @@ def get_ignis_version() -> str:
Returns:
``str``: The Ignis version.
"""
with open(VERSION_FILE) as file:
version = file.read()
return __version__

return version


def get_ignis_commit_hash() -> str:
def get_ignis_commit() -> str:
"""
Get the current Ignis commit hash.
Returns:
``str``: The Ignis commit hash.
"""
with open(COMMIT) as file:
commit_hash = file.read()

return commit_hash
return __commit__
2 changes: 2 additions & 0 deletions ignis/version.py.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
__version__ = "@VERSION@"
__commit__ = "@COMMIT@"
25 changes: 22 additions & 3 deletions meson.build
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
project(
'ignis',
version: run_command('cat', 'VERSION').stdout().strip(),
version: '0.1',
license: 'GPL-3.0-only',
default_options: ['warning_level=2', 'werror=false']
)
Expand All @@ -13,12 +13,14 @@ python = import('python').find_installation()
prefix = get_option('prefix')
datadir = join_paths(prefix, get_option('datadir'))
libdir = join_paths(prefix, get_option('libdir'))

bindir = get_option('bindir')

pylibdir = python.get_install_dir()

pkgdatadir = join_paths(datadir, meson.project_name())

pkginstalldir = join_paths(pylibdir, meson.project_name())

# Dependencies
dependency('glib-2.0')
dependency('gobject-introspection-1.0')
Expand Down Expand Up @@ -51,4 +53,21 @@ install_subdir(
install_dir: pylibdir,
)

meson.add_install_script('post_install.py', join_paths(pylibdir, meson.project_name()))
config = configuration_data()
config.set('LIBDIR', libdir)
config.set('VERSION', meson.project_version())
config.set('COMMIT', run_command('git', 'rev-parse', 'HEAD').stdout().strip())

configure_file(
input: 'ignis/__init__.py.in',
output: '__init__.py',
configuration: config,
install_dir: pkginstalldir
)

configure_file(
input: 'ignis/version.py.in',
output: 'version.py',
configuration: config,
install_dir: pkginstalldir
)
35 changes: 0 additions & 35 deletions post_install.py

This file was deleted.

0 comments on commit ec8c5bd

Please sign in to comment.