LogarithmPlotter/setup.py

121 lines
4.5 KiB
Python
Raw Normal View History

2021-06-21 22:27:40 +00:00
"""
* LogarithmPlotter - Create graphs with logarithm scales.
* Copyright (C) 2021 Ad5001
*
* 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
current_dir = os.path.realpath(os.path.dirname(os.path.realpath(__file__)))
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:
os.environ["PREFIX"] = os.environ["home"] + "/local/share"
2021-06-21 22:27:40 +00:00
from LogarithmPlotter import __VERSION__ as pkg_version
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 :: 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]
return pkg_data
data_files = []
if sys.platform == 'linux':
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 and sys.argv[1] == "install":
from shutil import copyfile
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)
copyfile(current_dir + '/linux/logarithmplotter.desktop', os.environ["PREFIX"] + '/applications/logarithmplotter.desktop')
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')
2021-06-21 22:27:40 +00:00
setuptools.setup(
install_requires=["PySide2"],
python_requires='>=3.8',
name='logarithmplotter',
version=pkg_version,
description='Browse and use online services, free of account',
long_description=read_file("README.md"),
keywords='logarithm plotter graph creator bode diagram',
author='Ad5001',
author_email='mail@ad5001.eu',
license=('GPLv3'),
url='https://apps.ad5001.eu/logarithmplotter',
classifiers=CLASSIFIERS,
zip_safe=False,
packages=["LogarithmPlotter"],
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
],
}
)