| 1 |
#!/usr/bin/env python3 |
| 2 |
|
| 3 |
# Copyright 2014-2024 Facundo Batista, Nicolás Demarchi |
| 4 |
# |
| 5 |
# This program is free software: you can redistribute it and/or modify it |
| 6 |
# under the terms of the GNU General Public License version 3, as published |
| 7 |
# by the Free Software Foundation. |
| 8 |
# |
| 9 |
# This program is distributed in the hope that it will be useful, but |
| 10 |
# WITHOUT ANY WARRANTY; without even the implied warranties of |
| 11 |
# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR |
| 12 |
# PURPOSE. See the GNU General Public License for more details. |
| 13 |
# |
| 14 |
# You should have received a copy of the GNU General Public License along |
| 15 |
# with this program. If not, see <http://www.gnu.org/licenses/>. |
| 16 |
# |
| 17 |
# For further info, check https://github.com/PyAr/fades |
| 18 |
|
| 19 |
"""Build tar.gz for fades. |
| 20 |
|
| 21 |
Needed packages to run (using Debian/Ubuntu package names): |
| 22 |
|
| 23 |
python3 |
| 24 |
python3-xdg (optional) |
| 25 |
""" |
| 26 |
|
| 27 |
import os |
| 28 |
import re |
| 29 |
import shutil |
| 30 |
import sys |
| 31 |
|
| 32 |
from distutils.core import setup |
| 33 |
from setuptools.command.install import install |
| 34 |
|
| 35 |
|
| 36 |
def get_version(): |
| 37 |
"""Retrieves package version from the file.""" |
| 38 |
with open('fades/_version.py') as fh: |
| 39 |
m = re.search(r"\(([^']*)\)", fh.read()) |
| 40 |
if m is None: |
| 41 |
raise ValueError("Unrecognized version in 'fades/_version.py'") |
| 42 |
return m.groups()[0].replace(', ', '.') |
| 43 |
|
| 44 |
|
| 45 |
# the different scripts according to the platform |
| 46 |
SCRIPT_WIN = 'bin/fades.cmd' |
| 47 |
SCRIPT_REST = 'bin/fades' |
| 48 |
|
| 49 |
|
| 50 |
class CustomInstall(install): |
| 51 |
"""Custom installation to fix script info and install man.""" |
| 52 |
|
| 53 |
def initialize_options(self): |
| 54 |
"""Run parent initialization and then fix the scripts var.""" |
| 55 |
install.initialize_options(self) |
| 56 |
|
| 57 |
# leave the proper script according to the platform |
| 58 |
script = SCRIPT_WIN if sys.platform == "win32" else SCRIPT_REST |
| 59 |
self.distribution.scripts = [script] |
| 60 |
|
| 61 |
def run(self): |
| 62 |
"""Run parent install, and then save the man file.""" |
| 63 |
install.run(self) |
| 64 |
|
| 65 |
# man directory |
| 66 |
if self._custom_man_dir is not None: |
| 67 |
if not os.path.exists(self._custom_man_dir): |
| 68 |
os.makedirs(self._custom_man_dir) |
| 69 |
shutil.copy("man/fades.1", self._custom_man_dir) |
| 70 |
|
| 71 |
def finalize_options(self): |
| 72 |
"""Alter the installation path.""" |
| 73 |
install.finalize_options(self) |
| 74 |
if self.prefix is None: |
| 75 |
# no place for man page (like in a 'snap') |
| 76 |
man_dir = None |
| 77 |
else: |
| 78 |
man_dir = os.path.join(self.prefix, "share", "man", "man1") |
| 79 |
|
| 80 |
# if we have 'root', put the building path also under it (used normally |
| 81 |
# by pbuilder) |
| 82 |
if self.root is not None: |
| 83 |
man_dir = os.path.join(self.root, man_dir[1:]) |
| 84 |
self._custom_man_dir = man_dir |
| 85 |
|
| 86 |
|
| 87 |
setup( |
| 88 |
name='fades', |
| 89 |
version=get_version(), |
| 90 |
license='GPL-3', |
| 91 |
author='Facundo Batista, Nicolás Demarchi', |
| 92 |
author_email='[email protected], [email protected]', |
| 93 |
description=( |
| 94 |
'A system that automatically handles the virtualenvs in the cases ' |
| 95 |
'normally found when writing scripts and simple programs, and ' |
| 96 |
'even helps to administer big projects.'), |
| 97 |
long_description=open('README.rst').read(), |
| 98 |
url='https://github.com/PyAr/fades', |
| 99 |
download_url="https://github.com/PyAr/fades/releases", # Release download URL. |
| 100 |
packages=["fades"], |
| 101 |
scripts=[SCRIPT_WIN, SCRIPT_REST], |
| 102 |
keywords="virtualenv utils utility scripts", # to get found easily on PyPI results, etc. |
| 103 |
cmdclass={ |
| 104 |
'install': CustomInstall, |
| 105 |
}, |
| 106 |
install_requires=['setuptools'], |
| 107 |
tests_require=['logassert', 'pyxdg', 'pyuca', 'pytest', 'flake8', |
| 108 |
'pep257', 'rst2html5'], # what unittests require |
| 109 |
python_requires='>=3.10', # Minimum Python version supported. |
| 110 |
extras_require={ |
| 111 |
'pyxdg': 'pyxdg', |
| 112 |
'packaging': 'packaging', |
| 113 |
}, |
| 114 |
|
| 115 |
# https://pypi.python.org/pypi?%3Aaction=list_classifiers |
| 116 |
classifiers=[ |
| 117 |
'Development Status :: 5 - Production/Stable', |
| 118 |
# 'Development Status :: 6 - Mature', |
| 119 |
# 'Development Status :: 7 - Inactive', |
| 120 |
|
| 121 |
'Environment :: Console', |
| 122 |
|
| 123 |
'Intended Audience :: Developers', |
| 124 |
'Intended Audience :: System Administrators', |
| 125 |
|
| 126 |
'License :: OSI Approved :: GNU General Public License (GPL)', |
| 127 |
'License :: OSI Approved :: GNU General Public License v3 (GPLv3)', |
| 128 |
'License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)', |
| 129 |
|
| 130 |
'Natural Language :: English', |
| 131 |
'Natural Language :: Spanish', |
| 132 |
|
| 133 |
'Operating System :: MacOS', |
| 134 |
'Operating System :: MacOS :: MacOS X', |
| 135 |
'Operating System :: Microsoft', |
| 136 |
'Operating System :: Microsoft :: Windows', |
| 137 |
'Operating System :: POSIX', |
| 138 |
'Operating System :: POSIX :: Linux', |
| 139 |
|
| 140 |
'Programming Language :: Python', |
| 141 |
'Programming Language :: Python :: 3', |
| 142 |
'Programming Language :: Python :: 3 :: Only', |
| 143 |
'Programming Language :: Python :: 3.10', |
| 144 |
'Programming Language :: Python :: 3.11', |
| 145 |
'Programming Language :: Python :: 3.12', |
| 146 |
'Programming Language :: Python :: 3.13', |
| 147 |
'Programming Language :: Python :: Implementation', |
| 148 |
'Programming Language :: Python :: Implementation :: CPython', |
| 149 |
|
| 150 |
'Topic :: Software Development', |
| 151 |
'Topic :: Utilities', |
| 152 |
], |
| 153 |
) |