Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Installation on macOS #33

Closed
ArtPoon opened this issue Aug 28, 2018 · 4 comments
Closed

Installation on macOS #33

ArtPoon opened this issue Aug 28, 2018 · 4 comments

Comments

@ArtPoon
Copy link
Contributor

ArtPoon commented Aug 28, 2018

Running sudo python3 setup.py install for macOS (Darwin 16.7) yields the following:

/opt/local/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/distutils/dist.py:261: UserWarning: Unknown distribution option: 'include_package_data'
  warnings.warn(msg)
running install
running build
running build_py
running build_scripts
running install_lib
running install_scripts
changing mode of /opt/local/Library/Frameworks/Python.framework/Versions/3.5/bin/sierralocal to 755
running install_egg_info
Removing /opt/local/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/sierralocal-0.0.1-py3.5.egg-info
Writing /opt/local/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/sierralocal-0.0.1-py3.5.egg-info

Hence the sierralocal binary is installed to the /opt directory where Python 3.5 lives, and not /usr/local/bin. Since /opt/local/.. is not in PATH, the user can't run the binary without specifying a path.

@ArtPoon
Copy link
Contributor Author

ArtPoon commented Aug 28, 2018

When calling sierralocal by absolute path, I run into the following issue:

is2882:sierra-local art$ /opt/local/Library/Frameworks/Python.framework/Versions/3.5/bin/sierralocal 
3.5.5 (default, Feb  5 2018, 07:16:39) 
[GCC 4.2.1 Compatible Apple LLVM 8.1.0 (clang-802.0.42)]
Traceback (most recent call last):
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.5/bin/sierralocal", line 12, in <module>
    sys.exit(main())
TypeError: 'module' object is not callable

I encountered the same problem when building sierra-local from source in Ubuntu 18.04.1.
The problem is that main is being imported as a module, so the correct call would be main.main().
Since the sierralocal script is generated by setup.py, we have to modify the latter somehow.

ArtPoon added a commit that referenced this issue Aug 28, 2018
- working on issue #33 by modifying setup.py
- implemented check for Python 3 in setup.py
- added my own data retrieval script
- `nucaminohook.py` now exits if nucamino binary not found
@ArtPoon
Copy link
Contributor Author

ArtPoon commented Aug 28, 2018

Apparently the weird /opt path is expected behaviour from distutils, so we'll have to ignore that problem and require users to modify their PATH variable.

Changing main() to main.main() as above fixes the problem for macOS, but now we get this problem in Linux:

art@orolo:~/git/sierra-local$ sierralocal
3.6.5 (default, Apr  1 2018, 05:46:30) 
[GCC 7.3.0]
Traceback (most recent call last):
  File "/usr/local/bin/sierralocal", line 12, in <module>
    sys.exit(main.main())
AttributeError: 'function' object has no attribute 'main'
art@orolo:~/git/sierra-local$ cat /usr/local/bin/sierralocal 
#!/usr/bin/python3

# -*- coding: utf-8 -*-
import re
import sys

from sierralocal import main

if __name__ == '__main__':
    print(sys.version)
    sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0])
    sys.exit(main.main())

@ArtPoon
Copy link
Contributor Author

ArtPoon commented Aug 28, 2018

This is weird:

art@orolo:~/git/sierra-local$ bin/sierralocal 
3.6.5 (default, Apr  1 2018, 05:46:30) 
[GCC 7.3.0]
<function main at 0x7fb8867ead90>  # output of print(main)
Traceback (most recent call last):
  File "bin/sierralocal", line 13, in <module>
    sys.exit(main.main())
AttributeError: 'function' object has no attribute 'main'

art@orolo:~/git/sierra-local$ python3
Python 3.6.5 (default, Apr  1 2018, 05:46:30) 
[GCC 7.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from sierralocal import main
>>> main
<module 'sierralocal.main' from '/home/art/git/sierra-local/sierralocal/main.py'>

So sierralocal called via CLI loads the function and not the module, and calling it within a Python interpreter loads the module and not the function.

@ArtPoon
Copy link
Contributor Author

ArtPoon commented Aug 29, 2018

Turns out this weirdness was being caused by an older installation of sierralocal in ~/.local, which would have resulted from calling setup.py without sudo privileges. I nuked this instance and things seem back to normal. Will remove gross try..except hack from bin/sierralocal if things stay normal.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant