setup.py
Go to the documentation of this file.
1 # -*- coding: utf-8 -*-
2 """
3 Setup.py for grepros.
4 
5 ------------------------------------------------------------------------------
6 This file is part of grepros - grep for ROS bag files and live topics.
7 Released under the BSD License.
8 
9 @author Erki Suurjaak
10 @created 23.10.2021
11 @modified 22.07.2023
12 ------------------------------------------------------------------------------
13 """
14 from __future__ import print_function
15 
16 import os
17 import re
18 import setuptools
19 try: from catkin_pkg.python_setup import generate_distutils_setup
20 except ImportError: generate_distutils_setup = None
21 
22 
23 PACKAGE = "grepros"
24 
25 
26 def readfile(path):
27  """Returns contents of path, relative to current file."""
28  root = os.path.dirname(os.path.abspath(__file__))
29  with open(os.path.join(root, path)) as f: return f.read()
30 
32  """Returns package description from README."""
33  LINK_RGX = r"\[([^\]]+)\]\(([^\)]+)\)" # 1: content in [], 2: content in ()
34  KEEP = ("ftp://", "http://", "https://", "www.")
35  # Unwrap local links like [Page link](#page-link) and [DETAIL.md](doc/DETAIL.md)
36  repl = lambda m: m.group(0 if any(map(m.group(2).startswith, KEEP)) else
37  1 if m.group(2).startswith("#") else 2)
38  return re.sub(LINK_RGX, repl, readfile("README.md"))
39 
41  """Returns package current version number from source code."""
42  VERSION_RGX = r'__version__\s*\=\s*\"*([^\n\"]+)'
43  content = readfile(os.path.join("src", PACKAGE, "__init__.py"))
44  match = re.search(VERSION_RGX, content)
45  return match.group(1).strip() if match else None
46 
47 
48 common_args = dict(
49  install_requires = ["pyyaml", "six"],
50  package_dir = {"": "src"},
51  packages = setuptools.find_packages("src"),
52  package_data = {"": ["plugins/auto/*.tpl"]},
53 )
54 version_args = dict(
55  data_files = [
56  (os.path.join("share", "ament_index", "resource_index", "packages"),
57  [os.path.join("resource", PACKAGE)]),
58  (os.path.join("share", PACKAGE), ["package.xml"]),
59  ],
60  tests_require = ["pytest"],
61 ) if "2" == os.getenv("ROS_VERSION") else {}
62 
63 
64 setup_args = generate_distutils_setup( # fetch values from package.xml
65  scripts = [os.path.join("scripts", PACKAGE)],
66 ) if generate_distutils_setup and "1" == os.getenv("ROS_VERSION") else dict( # Normal pip setup
67  name = PACKAGE,
68  version = get_version(),
69  entry_points = {"console_scripts": ["{0} = {0}.main:run".format(PACKAGE)]},
70 
71  description = "grep for ROS bag files and live topics: read, filter, export",
72  url = "https://github.com/suurjaak/" + PACKAGE,
73  author = "Erki Suurjaak",
74  author_email = "erki@lap.ee",
75  license = "BSD",
76  platforms = ["any"],
77  keywords = "ROS ROS1 ROS2 rosbag grep",
78  python_requires = ">=2.7",
79 
80  include_package_data = True, # Use MANIFEST.in for data files
81  classifiers = [
82  "Development Status :: 5 - Production/Stable",
83  "Environment :: Console",
84  "Environment :: Console :: Curses",
85  "License :: OSI Approved :: BSD License",
86  "Intended Audience :: Developers",
87  "Operating System :: POSIX",
88  "Topic :: Scientific/Engineering",
89  "Topic :: Utilities",
90  "Programming Language :: Python :: 2",
91  "Programming Language :: Python :: 2.7",
92  "Programming Language :: Python :: 3",
93  ],
94 
95  long_description_content_type = "text/markdown",
96  long_description = get_description(),
97 )
98 setuptools.setup(**dict(common_args, **dict(setup_args, **version_args)))
setup.get_version
def get_version()
Definition: setup.py:40
setup.generate_distutils_setup
generate_distutils_setup
Definition: setup.py:20
setup.get_description
def get_description()
Definition: setup.py:31
setup.readfile
def readfile(path)
Definition: setup.py:26


grepros
Author(s): Erki Suurjaak
autogenerated on Sat Jan 6 2024 03:11:29