Add initial python setup script

This commit is contained in:
Rico Tiongson 2019-03-02 09:36:55 +08:00
parent 89b79bc9bc
commit da101a092a
3 changed files with 183 additions and 0 deletions

119
.gitignore vendored
View File

@ -4,3 +4,122 @@
# IDE-specific # IDE-specific
.idea .idea
.vscode .vscode
# PYTHON
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
# C extensions
*.so
# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
pip-wheel-metadata/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST
# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec
# Installer logs
pip-log.txt
pip-delete-this-directory.txt
# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
.hypothesis/
.pytest_cache/
# Translations
*.mo
*.pot
# Django stuff:
*.log
local_settings.py
db.sqlite3
# Flask stuff:
instance/
.webassets-cache
# Scrapy stuff:
.scrapy
# Sphinx documentation
docs/_build/
# PyBuilder
target/
# Jupyter Notebook
.ipynb_checkpoints
# IPython
profile_default/
ipython_config.py
# pyenv
.python-version
# celery beat schedule file
celerybeat-schedule
# SageMath parsed files
*.sage.py
# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/
# Spyder project settings
.spyderproject
.spyproject
# Rope project settings
.ropeproject
# mkdocs documentation
/site
# mypy
.mypy_cache/
.dmypy.json
dmypy.json
# Pyre type checker
.pyre/

View File

@ -28,6 +28,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define __COMFORTABLE_SWIPE__CONFIG__ "/usr/local/share/comfortable-swipe/comfortable-swipe.conf" #define __COMFORTABLE_SWIPE__CONFIG__ "/usr/local/share/comfortable-swipe/comfortable-swipe.conf"
#endif /* __COMFORTABLE_SWIPE__CONFIG__ */ #endif /* __COMFORTABLE_SWIPE__CONFIG__ */
#ifndef __COMFORTABLE_SWIPE__VERSION__
#error __COMFORTABLE_SWIPE__VERSION__ must be defined.
#endif /* __COMFORTABLE_SWIPE__VERSION__ */
#include <map> // std::map #include <map> // std::map
#include <string> // std::string #include <string> // std::string

60
setup.py Normal file
View File

@ -0,0 +1,60 @@
import os
from setuptools import setup
from setuptools.extension import Extension
__CWD__ = os.getcwd()
__DIR__ = os.path.abspath(os.path.dirname(__file__))
__URL__ = 'https://github.com/Hikari9/comfortable-swipe-ubuntu'
NAME = 'comfortable-swipe'
VERSION = '1.1.0'
PROGRAM = os.path.join('/usr/local/bin', NAME)
CONFIG = os.path.join(PROGRAM, 'comfortable-swipe.conf')
try:
# make sure working directory is here
os.chdir(__DIR__)
# save README as long_description
with open('README.md', 'r') as README_file:
README = README_file.read()
# save LICENSE as license
with open('LICENSE', 'r') as LICENSE_file:
LICENSE = LICENSE_file.read()
# have a dictionary of macros
macros = dict(
__COMFORTABLE_SWIPE__PROGRAM__=f'"{PROGRAM}"',
__COMFORTABLE_SWIPE__VERSION__=f'"{VERSION}"',
__COMFORTABLE_SWIPE__CONFIG__=f'"{CONFIG}"'
)
# read C++ library for comfortable swipe
comfortable_swipe = Extension(
name='comfortable_swipe',
define_macros=list(macros.items()),
libraries=['xdo'],
include_dirs=['/usr/local/lib'],
sources=['comfortable-swipe.cpp'],
extra_compile_args=['-O2', '-Wno-unused-result']
)
# setup python script
setup(
name=NAME,
version=VERSION,
description='Comfortable 3-finger and 4-finger swipe gestures',
long_description=README,
license=LICENSE,
author='Rico Tiongson',
author_email='thericotiongson@gmail.com',
url=__URL__,
# import external modules (aka. C++)
ext_modules=[comfortable_swipe],
)
finally:
# move working directory back to where it was before
os.chdir(__DIR__)