setup.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 # -*- coding: utf-8 -*-
3 """ QiCore Setup """
4 from __future__ import absolute_import
5 from __future__ import print_function
6 
7 import os
8 import sys
9 import shutil
10 import datetime
11 import setuptools
12 
13 SETUP_PROJECT = "qicore"
14 SETUP_DESCRIPTION = "QiCore Python Module"
15 SETUP_FILES = {
16  "manylinux1-x86_64": {
17  "libqicore.so": "linux/lib/libqicore.so",
18  "qicore.mod": "linux/share/qi/module/qicore.mod",
19  },
20  "macosx-10.12-intel": {
21  "libqicore.dylib": "mac/lib/libqicore.dylib",
22  "qicore.mod": "mac/share/qi/module/qicore.mod",
23  },
24  "win-amd64": {
25  "qicore.dll": "win/lib/qicore.dll",
26  "qicore.mod": "win/share/qi/module/qicore.mod",
27  },
28 }
29 PATH_HERE = os.path.abspath(os.path.dirname(__file__))
30 
31 
32 def find_file(filename):
33  """ Search a file by name in previous folder and return its path """
34  search_folder = os.environ.get("QIPYTHON_BUILD_FOLDER")
35  if not search_folder or not os.path.isdir(search_folder):
36  search_folder = os.path.join(PATH_HERE, "..")
37  for directory, _folders, content in os.walk(search_folder):
38  if filename not in content:
39  continue
40  return os.path.join(directory, filename)
41  return None
42 
43 
44 DEFAULT_VERSION = datetime.datetime.now().strftime("%y.%m.%d")
45 SETUP_VERSION = os.environ.get("QIPYTHON_BUILD_VERSION", DEFAULT_VERSION)
46 SETUP_CONFIG = """\
47 [metadata]\nlicense_file = LICENSE.txt\n
48 [bdist_wheel]\npython-tag = cp27\nplat-name = %s\nplat-tag = %s
49 """
50 SETUP_PLATFORM = "manylinux1-x86_64"
51 SETUP_SYSTEM = "Operating System :: POSIX :: Linux"
52 if "darwin" in sys.platform:
53  SETUP_PLATFORM = "macosx-10.12-intel"
54  SETUP_SYSTEM = "Operating System :: MacOS :: MacOS X"
55 elif "win" in sys.platform:
56  SETUP_PLATFORM = "win-amd64"
57  SETUP_SYSTEM = "Operating System :: Microsoft :: Windows"
58 # Write the Configuration File
59 with open(os.path.join(PATH_HERE, "setup.cfg"), "w") as file_config:
60  file_config.write(SETUP_CONFIG % (SETUP_PLATFORM, SETUP_PLATFORM))
61 file_config.close()
62 # Read the Description
63 LONG_DESCRIPTION = ""
64 try:
65  with open(os.path.join(PATH_HERE, "README.md")) as file_desc:
66  LONG_DESCRIPTION = file_desc.read()
67  file_desc.close()
68 except Exception:
69  pass
70 # Search and copy the Files to Include
71 PLATFORM_FILES = SETUP_FILES.get(SETUP_PLATFORM)
72 for filename in PLATFORM_FILES:
73  source_path = find_file(filename)
74  if source_path:
75  dest_path = os.path.join(PATH_HERE, SETUP_PROJECT, PLATFORM_FILES.get(filename))
76  if not os.path.isdir(os.path.dirname(dest_path)):
77  os.makedirs(os.path.dirname(dest_path))
78  shutil.copy(source_path, dest_path)
79  print(" + File %s added to the Package." % filename)
80  else:
81  print(" ! File %s is missing !" % filename)
82 # Create the Wheel Package
83 setuptools.setup(
84  name=SETUP_PROJECT,
85  version=SETUP_VERSION,
86  description=SETUP_DESCRIPTION,
87  long_description=LONG_DESCRIPTION,
88  keywords="naoqi softbank nao pepper romeo robot",
89  url="http://doc.aldebaran.com",
90  author="SoftBank Robotics",
91  author_email="release@softbankrobotics.com",
92  platforms=SETUP_PLATFORM,
93  python_requires=">=2.6, <3",
94  packages=[SETUP_PROJECT],
95  package_dir={SETUP_PROJECT: SETUP_PROJECT},
96  package_data={
97  SETUP_PROJECT: [PLATFORM_FILES.get(filename) for filename in PLATFORM_FILES]
98  },
99  include_package_data=True,
100  install_requires=["qi"],
101  classifiers=[
102  "Development Status :: 5 - Production/Stable",
103  "Intended Audience :: Developers",
104  "Topic :: Software Development :: Embedded Systems",
105  "Framework :: Robot Framework :: Tool",
106  "Programming Language :: Python :: 2",
107  SETUP_SYSTEM,
108  ],
109 )
110 # Remove the Setup File
111 os.remove(os.path.join(PATH_HERE, "setup.cfg"))
112 # Clean Project Folder
113 for name in os.listdir(os.path.join(PATH_HERE, SETUP_PROJECT)):
114  path = os.path.join(PATH_HERE, SETUP_PROJECT, name)
115  if os.path.isdir(path):
116  shutil.rmtree(path, ignore_errors=True)
setup.find_file
def find_file(filename)
Definition: setup.py:32


naoqi_libqicore
Author(s): Aldebaran
autogenerated on Wed Sep 14 2022 02:22:41