LogarithmPlotter/runtime-pyside6/setup.py

157 lines
6.5 KiB
Python
Raw Permalink Normal View History

2021-06-21 22:27:40 +00:00
"""
* LogarithmPlotter - 2D plotter software to make BODE plots, sequences and distribution functions.
2024-01-10 23:11:09 +00:00
* Copyright (C) 2021-2024 Ad5001
2021-06-21 22:27:40 +00:00
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
"""
import setuptools
import os
import sys
from shutil import copyfile
2021-06-21 22:27:40 +00:00
2021-10-01 14:36:58 +00:00
print(sys.argv)
2021-06-21 22:27:40 +00:00
current_dir = os.path.realpath(os.path.dirname(os.path.realpath(__file__)))
# Check where to install by default
# if "PREFIX" not in os.environ and sys.platform == 'linux':
# from getopt import getopt
# optlist, args = getopt(sys.argv, '', ['prefix=', 'root='])
# for arg,value in optlist:
# if arg == "prefix" or arg == "root":
# os.environ["PREFIX"] = value
# if "PREFIX" not in os.environ and sys.platform == 'linux':
# if "XDG_DATA_HOME" in os.environ:
# os.environ["PREFIX"] = os.environ["XDG_DATA_HOME"]
# else:
# try:
# # Checking if we have permission to write to root.
# from os import makedirs, rmdir
# makedirs("/usr/share/applications/test")
# rmdir("/usr/share/applications/test")
# os.environ["PREFIX"] = "/usr/share"
# except:
# if ".pybuild" in os.environ["HOME"]: # Launchpad building.
# os.environ["PREFIX"] = "share"
# else:
# os.environ["PREFIX"] = os.environ["HOME"] + "/.local/share"
2021-06-21 22:27:40 +00:00
from LogarithmPlotter import __VERSION__ as pkg_version
2021-10-01 14:36:58 +00:00
if "--remove-git-version" in sys.argv:
pkg_version = pkg_version.split(".dev0")[0]
sys.argv.remove("--remove-git-version")
2021-06-21 22:27:40 +00:00
CLASSIFIERS = """
Environment :: Graphic
Environment :: X11 Applications :: Qt
License :: OSI Approved :: GNU General Public License v3 (GPLv3)
Natural Language :: English
Development Status :: 3 - Alpha
2021-06-21 22:27:40 +00:00
Operating System :: MacOS :: MacOS X
Operating System :: Microsoft :: Windows
Operating System :: POSIX
Operating System :: POSIX :: BSD
Operating System :: POSIX :: Linux
Programming Language :: Python :: 3.8
Programming Language :: Python :: 3.9
Programming Language :: Python :: 3.10
Programming Language :: Python :: 3.11
Programming Language :: Python :: 3.12
2021-06-21 22:27:40 +00:00
Programming Language :: Python :: Implementation :: CPython
Topic :: Utilities
Topic :: Scientific/Engineering
""".strip().splitlines()
def read_file(file_name):
f = open(file_name, 'r', -1)
data = f.read()
f.close()
return data
def package_data():
pkg_data = ["logarithmplotter.svg"]
2021-06-21 22:27:40 +00:00
for d,folders,files in os.walk("LogarithmPlotter/qml"):
d = d[17:]
pkg_data += [os.path.join(d, f) for f in files]
2022-01-24 18:27:02 +00:00
for d,folders,files in os.walk("LogarithmPlotter/i18n"):
d = d[17:]
pkg_data += [os.path.join(d, f) for f in files]
if "FLATPAK_INSTALL" in os.environ:
pkg_data += ["CHANGELOG.md"]
2021-06-21 22:27:40 +00:00
return pkg_data
data_files = []
if sys.platform == 'linux':
2024-09-29 22:54:30 +00:00
data_files.append(('share/applications/', ['assets/native/linux/logarithmplotter.desktop']))
data_files.append(('share/mime/packages/', ['assets/native/linux/x-logarithm-plot.xml']))
data_files.append(('share/icons/hicolor/scalable/mimetypes/', ['assets/native/linux/application-x-logarithm-plot.svg']))
data_files.append(('share/icons/hicolor/scalable/apps/', ['assets/logarithmplotter.svg']))
# data_files.append((os.environ["PREFIX"] + '/applications/', ['linux/logarithmplotter.desktop']))
# data_files.append((os.environ["PREFIX"] + '/mime/packages/', ['linux/x-logarithm-plot.xml']))
# data_files.append((os.environ["PREFIX"] + '/icons/hicolor/scalable/mimetypes/', ['linux/application-x-logarithm-plot.svg']))
# data_files.append((os.environ["PREFIX"] + '/icons/hicolor/scalable/apps/', ['logplotter.svg']))
# if len(sys.argv) > 1:
# if sys.argv[1] == "install":
# os.makedirs(os.environ["PREFIX"] + '/applications/', exist_ok=True)
# os.makedirs(os.environ["PREFIX"] + '/mime/packages/', exist_ok=True)
# os.makedirs(os.environ["PREFIX"] + '/icons/hicolor/scalable/mimetypes/', exist_ok=True)
# os.makedirs(os.environ["PREFIX"] + '/icons/hicolor/scalable/apps/', exist_ok=True)
# os.makedirs(os.environ["PREFIX"] + '/metainfo/', exist_ok=True)
# copyfile(current_dir + '/linux/x-logarithm-plot.xml', os.environ["PREFIX"] + '/mime/packages/x-logarithm-plot.xml')
# copyfile(current_dir + '/linux/application-x-logarithm-plot.svg',
# os.environ["PREFIX"] + '/icons/hicolor/scalable/mimetypes/application-x-logarithm-plot.svg')
# copyfile(current_dir + '/logplotter.svg', os.environ["PREFIX"] + '/icons/hicolor/scalable/apps/logplotter.svg')
# elif sys.argv[1] == "uninstall":
# os.remove(os.environ["PREFIX"] + '/applications/logarithmplotter.desktop')
# os.remove(os.environ["PREFIX"] + '/mime/packages/x-logarithm-plot.xml')
# os.remove(os.environ["PREFIX"] + '/icons/hicolor/scalable/mimetypes/application-x-logarithm-plot.svg')
# os.remove(os.environ["PREFIX"] + '/icons/hicolor/scalable/apps/logplotter.svg')
2021-06-21 22:27:40 +00:00
setuptools.setup(
install_requires=([] if "FLATPAK_INSTALL" in os.environ else ["PySide6-Essentials"]),
python_requires='>=3.9',
2021-06-21 22:27:40 +00:00
name='logarithmplotter',
version=pkg_version,
description='Create and edit Bode plots.',
2021-06-21 22:27:40 +00:00
long_description=read_file("README.md"),
keywords='logarithm plotter graph creator bode diagram',
author='Ad5001',
author_email='mail@ad5001.eu',
license=('GPLv3'),
2021-10-01 14:36:58 +00:00
url='https://apps.ad5001.eu/logarithmplotter/',
2021-06-21 22:27:40 +00:00
classifiers=CLASSIFIERS,
zip_safe=False,
packages=["LogarithmPlotter", "LogarithmPlotter.util"],
2021-06-21 22:27:40 +00:00
package_data={
'LogarithmPlotter':package_data(),
},
include_package_data=True,
data_files = data_files,
entry_points={
'console_scripts': [
'logarithmplotter = LogarithmPlotter.logarithmplotter:run',
2021-06-21 22:27:40 +00:00
],
}
)