setup script

This commit is contained in:
multiSnow 2022-11-24 13:02:06 +08:00
parent 58e0617c5b
commit 43963d4987
Signed by: multiSnow
GPG Key ID: 18EDAC29CAA2DBCE
3 changed files with 155 additions and 0 deletions

69
mkpyz.sh Normal file
View File

@ -0,0 +1,69 @@
#!/bin/sh
# This file is part of ssiv.
#
# ssiv is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# ssiv is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with ssiv. If not, see <https://www.gnu.org/licenses/>.
set -e
ROOT=src
NAME=ssiv
if ! test -d ${ROOT}/sdl2; then
if ! test -d py-sdl2/sdl2; then
git clone --depth=1 https://github.com/py-sdl/py-sdl2.git
fi
# only the 'core' files of PySDL2 is needed
# only the 'core' library of SDL2 is needed
mkdir -p ${ROOT}/sdl2
for path in py-sdl2/sdl2/*.py; do
case `basename ${path}` in
sdl*.py) ;;
*.py) cp ${path} ${ROOT}/sdl2 ;;
esac
done
fi
if ! test -d ${ROOT}/wand; then
if ! test -d wand/wand; then
git clone --depth=1 https://github.com/emcconville/wand.git
fi
cp -r wand/wand ${ROOT}
fi
# prefer 7z for higher compression ratio
for prog in 7za 7z; do
if which ${prog}; then
PROG=${prog}
break
fi
done
if test x${PROG} != x; then
cd ${ROOT}
${PROG} a -tzip -mm=Deflate -mx9 -mfb258 -mpass=15 ../${NAME}.pyz
exit $?
fi
for prog in python3 python; do
if which ${prog}; then
PROG=${prog}
break
fi
done
if test x${PROG} != x; then
${PROG} -m zipapp ${ROOT} --output=${NAME}.pyz --compress
fi

39
setup.cfg.in Normal file
View File

@ -0,0 +1,39 @@
# This file is part of ssiv.
#
# ssiv is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# ssiv is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with ssiv. If not, see <https://www.gnu.org/licenses/>.
[metadata]
name={name}
version={version}
description=Simple SDL Image Viewer
long_description=file:README.rst,LICENSE
author=multiSnow
author_email=multiSnow@disroot.org
url=https://git.disroot.org/multiSnow/ssiv
license=GNU Affero General Public License v3 or later (AGPLv3+)
classifiers =
Development Status :: 2 - Pre-Alpha
License :: OSI Approved :: GNU Affero General Public License v3 or later (AGPLv3+)
Operating System :: OS Independent
Programming Language :: Python :: 3.11
Programming Language :: Python :: Implementation :: CPython
Topic :: Multimedia :: Graphics :: Viewers
[options]
package_dir=
=src
packages={name},{name}.config,{name}.widget
install_requires=
sdl2>={pysdl2ver}
wand>={wandver}

47
setup.py Normal file
View File

@ -0,0 +1,47 @@
# This file is part of ssiv.
#
# ssiv is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# ssiv is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with ssiv. If not, see <https://www.gnu.org/licenses/>.
import os
import sys
curdir=os.path.dirname(__file__)
sys.path.insert(0,os.path.join(curdir,'src'))
from ssiv.constants import *
with open(os.path.join(curdir,'setup.cfg.in'),mode='rt') as fi,\
open(os.path.join(curdir,'setup.cfg'),mode='wt') as fo:
fo.write(fi.read().format(
name=progname.lower(),
version='{}.{}.{}'.format(*version_info),
pysdl2ver='{}.{}.{}'.format(*required_pysdl2ver),
wandver='{}.{}.{}'.format(*required_wandver),
))
if not sys.argv[1:]:
print('generate setup.cfg only.')
print(f'see {sys.argv[0]} --help for setuptoools command')
exit()
from setuptools import setup
setup()
# Local Variables:
# coding: utf-8
# mode: python
# python-indent-offset: 4
# indent-tabs-mode: nil
# End: