Skip to content

Commit 0679dba

Browse files
committed
- updating build_install_pyradio so that it detects pipx even if it is
not provided as a module (executable only) - updating pyproject.toml - renaming setup.py to seyup.py.legacy so that it does not interfere with the modern build chain but keeping a legacy way to build the package if needed
1 parent 36599f5 commit 0679dba

File tree

5 files changed

+150
-82
lines changed

5 files changed

+150
-82
lines changed

MANIFEST.in

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,7 @@
11
recursive-include pyradio *
2+
prune pyradio/__pycache__
3+
prune pyradio/.ruff_cache
4+
prune devel
5+
prune .git
6+
prune .github
27
exclude *.pyc *.orig

devel/build_install_pyradio

Lines changed: 62 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,48 @@ Checking python availability:"
2222
echo
2323
}
2424

25+
function check_pipx() {
26+
# Δοκιμή 1: python -m pipx
27+
local pipx_test=$(python"${TO_PYTHON}" -m pipx --version 2>/dev/null)
28+
if [ -n "$pipx_test" ]; then
29+
echo "python${TO_PYTHON} -m pipx"
30+
return 0
31+
fi
32+
33+
# Δοκιμή 2: standalone pipx
34+
pipx_test=$(pipx --version 2>/dev/null)
35+
if [ -n "$pipx_test" ]; then
36+
echo "pipx"
37+
return 0
38+
fi
39+
40+
# Δοκιμή 3: απόλυτο path (συνήθης θέση σε macOS)
41+
pipx_test=$(/usr/local/bin/pipx --version 2>/dev/null)
42+
if [ -n "$pipx_test" ]; then
43+
echo "/usr/local/bin/pipx"
44+
return 0
45+
fi
46+
47+
# Δοκιμή 4: άλλα πιθανά paths
48+
local potential_paths=(
49+
"/opt/homebrew/bin/pipx"
50+
"/usr/bin/pipx"
51+
"$HOME/.local/bin/pipx"
52+
)
53+
54+
for path in "${potential_paths[@]}"; do
55+
if [ -x "$path" ]; then
56+
pipx_test=$("$path" --version 2>/dev/null)
57+
if [ -n "$pipx_test" ]; then
58+
echo "$path"
59+
return 0
60+
fi
61+
fi
62+
done
63+
64+
return 1
65+
}
66+
2567
function pipx_error(){
2668
cat <<END
2769
The installation has failed!!!
@@ -76,18 +118,21 @@ function uninstall(){
76118
echo 'Uninstalling PyRadio'
77119
echo -n ' ** Removing python files ... '
78120
echo -n "Looking for pipx ... "
79-
PIPX_VERSION=$(python"${TO_PYTHON}" -m pipx --version)
80-
[ -z "$PIPX_VERSION" ] || PIPX=1
81-
[ -z "$PIPX_VERSION" ] && {
82-
echo "Command used: python"${TO_PYTHON}" -m pipx --version 2>/dev/null"
83-
} || echo "$PIPX_VERSION"
121+
PIPX_CMD=$(check_pipx)
122+
if [ -n "$PIPX_CMD" ]; then
123+
PIPX=1
124+
PIPX_VERSION=$($PIPX_CMD --version 2>/dev/null)
125+
echo "$PIPX_VERSION (found via: $PIPX_CMD)"
126+
else
127+
echo "not found"
128+
fi
84129
if [ -z "${PIPX}" ]
85130
then
86131
python -m pip uninstall -y pyradio 2>/dev/null 1>&2
87132
python2 -m pip uninstall -y pyradio 2>/dev/null 1>&2
88133
python3 -m pip uninstall -y pyradio 2>/dev/null 1>&2
89134
else
90-
python"${TO_PYTHON}" -m pipx uninstall pyradio 2>/dev/null 1>&2
135+
$PIPX_CMD uninstall pyradio 2>/dev/null 1>&2
91136
fi
92137
echo 'done'
93138
echo -n ' ** Removing help files ... '
@@ -345,27 +390,7 @@ do
345390
done
346391
set -- "${POSITIONAL[@]}" # restore positional parameters
347392

348-
# if [ -z "$NO_DEV" ]
349-
# then
350-
# cd pyradio
351-
# DEVEL=$(python -c 'from install import get_github_long_description_for_script; get_github_long_description_for_script()')
352-
# # DEVEL=$(python -c 'from install import get_devel_version; print(get_devel_version())')
353-
# echo "Devel version: $DEVEL"
354-
# cd ..
355-
# fi
356-
357-
358-
## check dependencies :)
359-
#for prog in git sed ;do
360-
# ${prog} --version 2>/dev/null 1>&2 || {
361-
# echo "Error: ${prog} not found."
362-
# echo " Please install it and try again."
363-
# exit 1
364-
# }
365-
#done
366-
367393
# check dependencies :)
368-
# for prog in git sed ;do
369394
for prog in sed ;do
370395
${prog} --version 2>/dev/null 1>&2 || {
371396
if [ "${prog}" = "sed" ]
@@ -383,24 +408,19 @@ for prog in sed ;do
383408
}
384409
done
385410

386-
# uninstall previous versions
387-
# uninstall 1
388-
389-
# # delete any files that were left from previous attempt
390-
# sudo find . -iname "*.pyc" -delete 2>/dev/null
391-
# sudo find . -iname "*.egg" -delete 2>/dev/null
392-
393-
# echo "***** installing for user..."
394411
do_dev
395412

396413
#
397414
# Use pipx by default, if installed
398415
echo -n "Looking for pipx ... "
399-
PIPX_VERSION=$(python"${TO_PYTHON}" -m pipx --version)
400-
[ -z "$PIPX_VERSION" ] || PIPX=1
401-
[ -z "$PIPX_VERSION" ] && {
402-
echo "Command used: python"${TO_PYTHON}" -m pipx --version 2>/dev/null"
403-
} || echo "$PIPX_VERSION"
416+
PIPX_CMD=$(check_pipx)
417+
if [ -n "$PIPX_CMD" ]; then
418+
PIPX=1
419+
PIPX_VERSION=$($PIPX_CMD --version 2>/dev/null)
420+
echo "$PIPX_VERSION (found via: $PIPX_CMD)"
421+
else
422+
echo "not found"
423+
fi
404424

405425
if [ $(uname -s) = "Darwin" ] || [ $(uname -s) = "darwin" ]
406426
then
@@ -468,12 +488,12 @@ else
468488
fi
469489
if [ -z "$PIPX_ISOLATE" ]
470490
then
471-
python3 -m pipx install $PIPX_EDITABLE --system-site-packages --force . || pipx_error
491+
$PIPX_CMD install $PIPX_EDITABLE --system-site-packages --force . || pipx_error
472492
inst_type=1
473493
else
474-
python3 -m pipx install $PIPX_EDITABLE --force . || pipx_error
494+
$PIPX_CMD install $PIPX_EDITABLE --force . || pipx_error
475495
[ -z "$PIPX_EDITABLE" ] && \
476-
cat requirements_pipx.txt | sed -e 's/#.*//' | xargs python3 -m pipx inject pyradio
496+
cat requirements_pipx.txt | sed -e 's/#.*//' | xargs $PIPX_CMD inject pyradio
477497
inst_type=2
478498
fi
479499
fi

pyproject.toml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,21 @@ pyradio-client = "pyradio.main:run_client"
3030
"Homepage" = "https://github.com/coderholic/pyradio"
3131
"Bug Tracker" = "https://github.com/coderholic/pyradio/issues"
3232

33+
[tool.setuptools.packages.find]
34+
include = [
35+
"pyradio",
36+
"pyradio.icons",
37+
"pyradio.keyboard",
38+
"pyradio.scripts",
39+
"pyradio.themes"
40+
]
41+
exclude = [
42+
"pyradio.__pycache__",
43+
"pyradio.*.__pycache__",
44+
"pyradio.*.tests",
45+
"pyradio..ruff_cache"
46+
]
47+
3348
[build-system]
3449
# Minimum requirements for the build system to execute.
3550
requires = ["setuptools", "wheel"] # PEP 508 specifications.

setup.py

Lines changed: 0 additions & 40 deletions
This file was deleted.

setup.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
setup.py.legacy

setup.py.legacy

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
#!/usr/bin/env python
2+
#
3+
# This file is kept ONLY for legacy build systems which do not support PEP 517/518.
4+
# The official and supported way to build pyradio is via `pyproject.toml`:
5+
#
6+
# pip install .
7+
# python -m build
8+
#
9+
# If you *really* need to use the old build system, rename this file back to
10+
# `setup.py` and run:
11+
#
12+
# python setup.py install
13+
#
14+
# NOTE: This will be removed in the future.
15+
#
16+
from os import path as op
17+
from setuptools import setup, find_namespace_packages
18+
19+
from pyradio import version, __project__, __license__
20+
21+
22+
def read(filename):
23+
ret = ''
24+
if op.exists(filename):
25+
with open(op.join(op.dirname(__file__), filename), encoding='utf-8') as f:
26+
ret = f.read()
27+
return ret
28+
29+
30+
meta = dict(
31+
name=__project__,
32+
version=version,
33+
license=__license__,
34+
description=read('DESCRIPTION').rstrip(),
35+
platforms=('Any'),
36+
author='Ben Dowling',
37+
author_email='ben.m.dowling@gmail.com',
38+
url='http://github.com/coderholic/pyradio',
39+
include_package_data=True,
40+
packages=find_namespace_packages(
41+
include=[
42+
'pyradio',
43+
'pyradio.icons',
44+
'pyradio.keyboard',
45+
'pyradio.scripts',
46+
'pyradio.themes'
47+
],
48+
exclude=[
49+
'pyradio.__pycache__',
50+
'pyradio.*.__pycache__',
51+
'pyradio..ruff_cache',
52+
'devel',
53+
'favicon'
54+
]
55+
),
56+
entry_points={
57+
'console_scripts': [
58+
'pyradio = pyradio.main:shell',
59+
'pyradio-client = pyradio.main:run_client'
60+
]
61+
},
62+
install_requires=[],
63+
)
64+
65+
66+
if __name__ == "__main__":
67+
setup(**meta)

0 commit comments

Comments
 (0)