|
21 | 21 | from codecs import open |
22 | 22 | import os |
23 | 23 | import sys |
| 24 | +import re |
24 | 25 |
|
25 | 26 | # Always prefer setuptools over distutils |
26 | 27 | from setuptools import setup, find_packages |
|
38 | 39 | # Versions should comply with PEP440. For a discussion on single-sourcing |
39 | 40 | # the version across setup.py and the project code, see |
40 | 41 | # https://packaging.python.org/en/latest/single_source_version.html |
41 | | - 'version': '0.1.11', |
| 42 | + 'version': '0.1.17', |
42 | 43 |
|
43 | 44 | 'description': 'A library for providing inter-language foreign function interface calls', |
44 | 45 | 'long_description': long_description, |
|
117 | 118 | # Detect if metacall port is already installed |
118 | 119 | port_installed = False |
119 | 120 |
|
120 | | -sys.path.append(os.environ.get('PORT_LIBRARY_PATH', '/usr/local/lib')); |
| 121 | +# Append environment variable or default install path when building manually (TODO: Cross-platform paths) |
| 122 | +sys.path.append(os.environ.get('PORT_LIBRARY_PATH', os.path.join(os.path.sep, 'usr', 'local', 'lib'))); |
| 123 | + |
| 124 | +# Find is MetaCall is installed as a distributable tarball (TODO: Cross-platform paths) |
| 125 | +rootdir = os.path.join(os.path.sep, 'gnu', 'store') |
| 126 | +regex = re.compile('.*-metacall-.*') |
| 127 | + |
| 128 | +for root, dirs, _ in os.walk(rootdir): |
| 129 | + for folder in dirs: |
| 130 | + if regex.match(folder) and not folder.endswith('R'): |
| 131 | + sys.path.append(os.path.join(rootdir, folder, 'lib')) |
121 | 132 |
|
122 | 133 | # Find if module is installed |
123 | 134 | if sys.version_info[0] < 3: |
|
149 | 160 | py_port = importlib.util.find_spec("_py_portd") |
150 | 161 | port_installed = py_port is not None |
151 | 162 |
|
152 | | -if port_installed == True: |
153 | | - # Exclude helper package if port is already installed |
154 | | - exclude_packages.append('helper') |
155 | | -else: |
156 | | - # List run-time dependencies here. These will be installed by pip when |
157 | | - # your project is installed. For an analysis of "install_requires" vs pip's |
158 | | - # requirements files see: |
159 | | - # https://packaging.python.org/en/latest/requirements.html |
160 | | - options['install_requires'] = ['peppercorn', 'requests'] |
161 | | - |
162 | | - # Define install hooks |
163 | | - # TODO |
164 | | - |
165 | | - # To provide executable scripts, use entry points in preference to the |
166 | | - # "scripts" keyword. Entry points provide cross-platform support and allow |
167 | | - # pip to create the appropriate form of executable for the target platform. |
168 | | - options['entry_points'] = { |
169 | | - 'console_scripts': [ |
170 | | - 'metacall-install=helper:install', |
171 | | - 'metacall-uninstall=helper:uninstall_prompt', |
172 | | - 'metacall-update=helper:update' |
173 | | - ], |
174 | | - } |
| 163 | +# TODO: This code is very interesting for providing commands to the end user. |
| 164 | +# pip cannot execute arbitrary code as pre/post install hook when the package is being installed. |
| 165 | +# So it is impossible to install the binaries unless we add extra commands after install. |
| 166 | +# At this moment there is a common solution for installing binaries depending on Bash/PowerShell |
| 167 | +# that is OS dependant and not language dependant. By the moment we will use the new way of install |
| 168 | +# instead of the old one, but we keep the ./helper folder in order to provide future support for |
| 169 | +# extra commands, although the main idea is to keep the OS dependant install, this can be useful |
| 170 | +# for updating or doing Python related things. Meanwhile, it will be avoided. |
| 171 | +exclude_packages.append('helper') |
| 172 | + |
| 173 | +# if port_installed == True: |
| 174 | +# # Exclude helper package if port is already installed |
| 175 | +# exclude_packages.append('helper') |
| 176 | +# else: |
| 177 | +# # List run-time dependencies here. These will be installed by pip when |
| 178 | +# # your project is installed. For an analysis of "install_requires" vs pip's |
| 179 | +# # requirements files see: |
| 180 | +# # https://packaging.python.org/en/latest/requirements.html |
| 181 | +# options['install_requires'] = ['peppercorn', 'requests'] |
| 182 | + |
| 183 | +# # To provide executable scripts, use entry points in preference to the |
| 184 | +# # "scripts" keyword. Entry points provide cross-platform support and allow |
| 185 | +# # pip to create the appropriate form of executable for the target platform. |
| 186 | +# options['entry_points'] = { |
| 187 | +# 'console_scripts': [ |
| 188 | +# 'metacall-install=helper:install', |
| 189 | +# 'metacall-uninstall=helper:uninstall_prompt', |
| 190 | +# 'metacall-update=helper:update' |
| 191 | +# ], |
| 192 | +# } |
175 | 193 |
|
176 | 194 | # Define required packages |
177 | 195 | options['packages'] = find_packages(exclude=exclude_packages) |
|
0 commit comments