From ecd797d91e56a3444e79a9e67d552c602fffa772 Mon Sep 17 00:00:00 2001 From: "Walter A. Boring IV" Date: Wed, 21 Nov 2018 13:38:45 -0800 Subject: [PATCH] First stab at migrating this to a pytpi repo This patch does some refactoring of the code and the directory structure to conform to the needs of a pypi project. The python code now lives in the aprsd directory so it acts like a real python package that can be installed/included/used. The aprsd.py is now aprds/main.py This patch also adds support for using pbr, which enables a consistent bin install that you can then call as 'aprsd' from the command line. To use this as a developer you should create a virtualenv virtualenv .venv source .venv/bin/activate pip install -e . now you can edit the aprds/main.py and then test it by immediately running aprsd from the command line. The -e option for pip allows you to install the package as an editable package in the .venv, so you can hack on it and not need to re-install every time you make a change. --- .gitignore | 56 +++++++++++++++++++++++++++- MANIFEST.in | 6 +++ aprsd/__init__.py | 19 ++++++++++ fuzzyclock.py => aprsd/fuzzyclock.py | 0 aprsd.py => aprsd/main.py | 0 utils.py => aprsd/utils.py | 0 requirements.txt | 2 + setup.cfg | 31 +++++++++++++++ setup.py | 29 ++++++++++++++ 9 files changed, 142 insertions(+), 1 deletion(-) create mode 100644 MANIFEST.in create mode 100644 aprsd/__init__.py rename fuzzyclock.py => aprsd/fuzzyclock.py (100%) rename aprsd.py => aprsd/main.py (100%) rename utils.py => aprsd/utils.py (100%) create mode 100644 requirements.txt create mode 100644 setup.cfg create mode 100644 setup.py diff --git a/.gitignore b/.gitignore index 0d20b64..7707d82 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,55 @@ -*.pyc +*.py[cod] + +# C extensions +*.so + +# Packages +*.egg +*.egg-info +dist +build +.eggs +eggs +parts +bin +var +sdist +develop-eggs +.installed.cfg +lib +lib64 + +# Installer logs +pip-log.txt + +# Unit test / coverage reports +.coverage +.tox +nosetests.xml +.testrepository +.venv + +# Translations +*.mo + +# Mr Developer +.mr.developer.cfg +.project +.pydevproject + +# Complexity +output/*.html +output/*/index.html + +# Sphinx +doc/build + +# pbr generates these +AUTHORS +ChangeLog + +# Editors +*~ +.*.swp +.*sw? +.ropeproject diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 0000000..c978a52 --- /dev/null +++ b/MANIFEST.in @@ -0,0 +1,6 @@ +include AUTHORS +include ChangeLog +exclude .gitignore +exclude .gitreview + +global-exclude *.pyc diff --git a/aprsd/__init__.py b/aprsd/__init__.py new file mode 100644 index 0000000..ecc74b1 --- /dev/null +++ b/aprsd/__init__.py @@ -0,0 +1,19 @@ +# -*- coding: utf-8 -*- + +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +import pbr.version + + +__version__ = pbr.version.VersionInfo( + 'aprsd').version_string() diff --git a/fuzzyclock.py b/aprsd/fuzzyclock.py similarity index 100% rename from fuzzyclock.py rename to aprsd/fuzzyclock.py diff --git a/aprsd.py b/aprsd/main.py similarity index 100% rename from aprsd.py rename to aprsd/main.py diff --git a/utils.py b/aprsd/utils.py similarity index 100% rename from utils.py rename to aprsd/utils.py diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..bd92dae --- /dev/null +++ b/requirements.txt @@ -0,0 +1,2 @@ +pbr +imapclient diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 0000000..aa29c81 --- /dev/null +++ b/setup.cfg @@ -0,0 +1,31 @@ +[metadata] +name = aprsd +summary = Amateur radio APRS daemon which listens for messages and responds +description-file = + README.md +author = Craig Lamparter +author-email = something@somewhere.com +classifier = + Topic :: Communications :: Ham Radio + Operating System :: POSIX :: Linux + Programming Language :: Python + +[global] +setup-hooks = + pbr.hooks.setup_hook + +[files] +packages = + aprsd + +[entry_points] +console_scripts = + aprsd = aprsd.main:main + +[build_sphinx] +source-dir = doc/source +build-dir = doc/build +all_files = 1 + +[upload_sphinx] +upload-dir = doc/build/html diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..056c16c --- /dev/null +++ b/setup.py @@ -0,0 +1,29 @@ +# Copyright (c) 2013 Hewlett-Packard Development Company, L.P. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# THIS FILE IS MANAGED BY THE GLOBAL REQUIREMENTS REPO - DO NOT EDIT +import setuptools + +# In python < 2.7.4, a lazy loading of package `pbr` will break +# setuptools if some other modules registered functions in `atexit`. +# solution from: http://bugs.python.org/issue15881#msg170215 +try: + import multiprocessing # noqa +except ImportError: + pass + +setuptools.setup( + setup_requires=['pbr'], + pbr=True)