Skip to content

Commit

Permalink
Migrate to PEP517 meson-python build
Browse files Browse the repository at this point in the history
Bug: https://bugs.gentoo.org/909888
Signed-off-by: Zac Medico <[email protected]>
Closes: #36
Signed-off-by: Sam James <[email protected]>
  • Loading branch information
zmedico authored and thesamesam committed Oct 12, 2023
1 parent a12d24f commit 78c8fbe
Show file tree
Hide file tree
Showing 32 changed files with 454 additions and 203 deletions.
17 changes: 15 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,14 @@ jobs:
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
set -xe
python -VV
python -m site
python -m pip install --upgrade pip
# setuptools needed for 3.12+ because of https://github.com/mesonbuild/meson/issues/7702.
python -m pip install meson ninja setuptools
- name: Install portage
run: |
mkdir portage
Expand All @@ -38,8 +46,13 @@ jobs:
sudo wget "https://www.gentoo.org/dtd/metadata.dtd" -O /var/cache/distfiles/metadata.dtd
sudo wget "https://gitweb.gentoo.org/proj/portage.git/plain/cnf/repos.conf" -O /etc/portage/repos.conf
sudo ln -s /var/db/repos/gentoo/profiles/default/linux/amd64/17.1/systemd /etc/portage/make.profile
- name: Run tests
- name: Test meson install --destdir /tmp/install-root
run: |
echo -e "[binaries]\npython = '$(command -v python)'" > /tmp/native.ini
meson setup --native-file /tmp/native.ini /tmp/build .
meson install -C /tmp/build --destdir /tmp/install-root
- name: Run tests for ${{ matrix.python-version }}
run: |
export PYTHONPATH="${PWD}/portage/lib"${PYTHONPATH:+:}${PYTHONPATH}
export PATH="${PWD}/portage/bin":${PATH}
python setup.py test
meson test -C /tmp/build --verbose
13 changes: 0 additions & 13 deletions MANIFEST.in

This file was deleted.

2 changes: 1 addition & 1 deletion bin/ebump
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ __description__="Ebuild version bumping tool"
# a given ebuild and auxiliary files in the Portage tree. It is only
# useful for Gentoo developers with CVS commit access.

VERSION="git"
VERSION="@VERSION@"

die() {
echo $1 >&2
Expand Down
2 changes: 1 addition & 1 deletion bin/euse
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ set -f
# Licensed under the GPL v2

PROGRAM_NAME=euse
VERSION="git"
VERSION="@VERSION@"

EPREFIX=${EPREFIX:-$(portageq envvar EPREFIX)}
ETC="${EPREFIX}/etc"
Expand Down
55 changes: 55 additions & 0 deletions bin/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
py_bins = [
'eclean',
'eclean-dist',
'eclean-pkg',
'ekeyword',
'enalyze',
'epkginfo',
'equery',
'eread',
'eshowkw',
'imlate',
'merge-driver-ekeyword',
'revdep-rebuild',
]

ebump = configure_file(
input : 'ebump',
output : 'ebump',
configuration : conf_data
)

euse = configure_file(
input : 'euse',
output : 'euse',
configuration : conf_data
)

revdep_rebuild_sh = configure_file(
input : 'revdep-rebuild.sh',
output : 'revdep-rebuild.sh',
configuration : conf_data
)

other_bins = [
ebump,
euse,
revdep_rebuild_sh,
]

# It might seem sensible to use py.install_sources() to install the Python
# scripts, but it's really just a wrapper around install_data that forces the
# install_dir. Meson 1.2.0 and later also optimize to bytecode, but Gentoo does
# this in the ebuild.

install_data(
py_bins,
install_dir : get_option('bindir'),
install_mode : 'rwxr-xr-x',
)

install_data(
other_bins,
install_dir : get_option('bindir'),
install_mode : 'rwxr-xr-x',
)
2 changes: 1 addition & 1 deletion bin/revdep-rebuild.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ unset GREP_OPTIONS

# Readonly variables:
declare -r APP_NAME="revdep-rebuild" # # The name of this application
declare -r VERSION="git"
declare -r VERSION="@VERSION@"
declare -r OIFS="$IFS" # Save the IFS
declare -r ENV_FILE=0_env.rr # Contains environment variables
declare -r FILES_FILE=1_files.rr # Contains a list of files to search
Expand Down
20 changes: 20 additions & 0 deletions data/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
install_data(
[
'99gentoolkit-env',
],
install_dir : sysconfdir / 'env.d'
)

install_data(
[
'eclean/packages.exclude',
'eclean/distfiles.exclude',
'revdep-rebuild/99revdep-rebuild',
],
install_dir: sysconfdir,
preserve_path: true
)

if not system_wide
subdir_done()
endif
23 changes: 23 additions & 0 deletions man/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
man_pages_out = []
man_pages_in = [
'ebump.1',
'eclean.1',
'enalyze.1',
'epkginfo.1',
'equery.1',
'eread.1',
'eshowkw.1',
'euse.1',
'imlate.1',
'revdep-rebuild.1',
]

foreach man_page : man_pages_in
man_pages_out += configure_file(
input : man_page,
output : man_page,
configuration : conf_data
)
endforeach

install_man(man_pages_out)
68 changes: 68 additions & 0 deletions meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
project(
'gentoolkit',
'c',
version : '0.6.2',
license : 'GPL-2.0-or-later',
meson_version : '>=0.64.0'
)

py_mod = import('python')
py = py_mod.find_installation(pure : true)

sed = find_program('sed', required : true)

system_wide = get_option('system-wide')

eprefix = get_option('eprefix')
prefixdir = get_option('prefix')
datadir = get_option('datadir')
docdir = get_option('docdir')

sysconfdir = system_wide ? get_option('sysconfdir') \
: datadir / 'etc'

if docdir == ''
docdir = system_wide ? datadir / 'doc' / 'gentoolkit' \
: datadir / 'share' / 'gentoolkit' / 'doc'
endif

conf_data = configuration_data({
'VERSION' : meson.project_version()
})

if system_wide
conf_data.set('INSTALL_TYPE', 'SYSTEM')
conf_data.set('EPREFIX', eprefix)
else
conf_data.set('INSTALL_TYPE', 'MODULE')
conf_data.set('EPREFIX', '')
endif

subdir('bin')
subdir('pym')

test(
'python-unittest',
py,
args : ['-m', 'unittest', 'discover', meson.current_source_dir() / 'pym'],
timeout : 0
)

if get_option('code-only')
subdir_done()
endif

subdir('data')

install_data(
[
'NEWS',
],
install_dir : docdir
)

if not system_wide
subdir_done()
endif

subdir('man')
15 changes: 15 additions & 0 deletions meson_options.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
option('system-wide', type : 'boolean', value : true,
description : 'Install system-wide rather than isolated inside a Python environment'
)

option('code-only', type : 'boolean', value : false,
description : 'Do not install additional files such as configuration or documentation'
)

option('eprefix', type : 'string',
description : 'Prefix directory for gentoolkit to operate under'
)

option('docdir', type : 'string',
description : 'Documentation directory'
)
2 changes: 1 addition & 1 deletion pym/gentoolkit/eclean/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
+ "modular re-write by: Brian Dolbec (dol-sen)"
)
__email__ = "[email protected], " + "[email protected]"
__version__ = "git"
__version__ = "@VERSION@"
__productname__ = "eclean"
__description__ = "A cleaning tool for Gentoo distfiles and binaries."

Expand Down
18 changes: 18 additions & 0 deletions pym/gentoolkit/eclean/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@

cli_py = configure_file(
input : 'cli.py',
output : 'cli.py',
configuration : conf_data
)

py.install_sources(
[
'__init__.py',
'clean.py',
cli_py,
'exclude.py',
'output.py',
'search.py',
],
subdir : 'gentoolkit/eclean'
)
2 changes: 1 addition & 1 deletion pym/gentoolkit/ekeyword/ekeyword.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
from portage.output import colorize, nocolor


__version__ = "git"
__version__ = "@VERSION@"

# Operation object that describes how to perform a change.
# Args:
Expand Down
26 changes: 26 additions & 0 deletions pym/gentoolkit/ekeyword/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@

ekeyword_py = configure_file(
input : 'ekeyword.py',
output : 'ekeyword.py',
configuration : conf_data
)

py.install_sources(
[
'__init__.py',
ekeyword_py,
'test_ekeyword.py',
],
subdir : 'gentoolkit/ekeyword'
)

install_data(
[
'Makefile',
'README',
'pytest.ini',
],
install_dir : py.get_install_dir() / 'gentoolkit' / 'ekeyword'
)

subdir('tests')
12 changes: 12 additions & 0 deletions pym/gentoolkit/ekeyword/tests/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
install_data(
[
'process-1.ebuild',
'profiles/arches-desc/profiles/arch.list',
'profiles/arches-desc/profiles/arches.desc',
'profiles/arches-desc/profiles/profiles.desc',
'profiles/both/profiles/arch.list',
'profiles/both/profiles/profiles.desc',
],
preserve_path: true,
install_dir : py.get_install_dir() / 'gentoolkit' / 'ekeyword' / 'tests'
)
4 changes: 2 additions & 2 deletions pym/gentoolkit/enalyze/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@


__docformat__ = "epytext"
# version is dynamically set by distutils sdist
__version__ = "git"
# version is dynamically set by meson dist
__version__ = "@VERSION@"
__productname__ = "enalyze"
__authors__ = "Brian Dolbec, <[email protected]>"

Expand Down
17 changes: 17 additions & 0 deletions pym/gentoolkit/enalyze/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@

__init__py = configure_file(
input : '__init__.py',
output : '__init__.py',
configuration : conf_data
)

py.install_sources(
[
__init__py,
'analyze.py',
'lib.py',
'output.py',
'rebuild.py',
],
subdir : 'gentoolkit/enalyze'
)
4 changes: 2 additions & 2 deletions pym/gentoolkit/equery/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

__all__ = ("format_options", "format_package_names", "mod_usage")
__docformat__ = "epytext"
# version is dynamically set by distutils sdist
__version__ = "git"
# version is dynamically set by meson dist
__version__ = "@VERSION@"

# =======
# Imports
Expand Down
Loading

0 comments on commit 78c8fbe

Please sign in to comment.