squeaky-pl / japronto

Screaming-fast Python 3.5+ HTTP toolkit integrated with pipelining HTTP server based on uvloop and picohttpparser.
MIT License
8.61k stars 581 forks source link

Installing fails on OSX #1

Closed r0fls closed 7 years ago

r0fls commented 7 years ago

There is no requirements.txt and installation fails:

$ python3 setup.py install
Traceback (most recent call last):
  File "setup.py", line 10, in <module>
    import build
  File "/Users/r0fls/Documents/code/foss/japronto/build.py", line 11, in <module>
    import pytoml
ImportError: No module named 'pytoml'

Installing this way should install the dependencies.

squeaky-pl commented 7 years ago

Yes. I shamelessly skipped all the setup.py corectness for now and just built manylinux wheels and Docker image. The build system needs a lot of love but you can try just commenting out relevant imports, it should work.

I dont know if it will even work with clang on OSX.

squeaky-pl commented 7 years ago

I pushed a dirty fix on master. The whole build system needs serious refactoring though.

You can now try compiling with clang, I don't know much about clang and OSX but if it complains about C99 you need to invoke it like CFLAGS="-std=c99" python setup.py bdist_wheel at least under older GCC. Let me know how it goes.

solie commented 7 years ago

macOS 10.11.6 here, using clang-8.0.0 and python3.6 from homebrew I have to comment out and modify some lines below to successfully run setup.py:

r0fls commented 7 years ago

The dirty fix appears to have helped but I still get this when trying to install:

$ CFLAGS="-std=c99" python3 setup.py bdist_wheel
+ gcc -c picohttpparser.c -O3 -fpic -msse4.2
+ gcc -shared -o libpicohttpparser.so picohttpparser.o
+ strip libpicohttpparser.so
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/strip: symbols referenced by indirect symbol table entries that can't be stripped in: /Users/r0fls/Documents/code/foss/japronto/src/picohttpparser/libpicohttpparser.so
___assert_rtn
_memmove
dyld_stub_binder
Traceback (most recent call last):
  File "setup.py", line 55, in <module>
    ext_modules=build.get_platform()
  File "/Users/r0fls/Documents/code/foss/japronto/build.py", line 234, in get_platform
    ext_modules = system.discover_extensions()
  File "/Users/r0fls/Documents/code/foss/japronto/build.py", line 69, in discover_extensions
    self.extensions = [self.get_extension_by_path(f) for f in ext_files]
  File "/Users/r0fls/Documents/code/foss/japronto/build.py", line 69, in <listcomp>
    self.extensions = [self.get_extension_by_path(f) for f in ext_files]
  File "/Users/r0fls/Documents/code/foss/japronto/build.py", line 31, in get_extension_by_path
    extension = result['get_extension']()
  File "src/japronto/parser/cparser_ext.py", line 10, in get_extension
    subprocess.check_call('cd src/picohttpparser && ./build', shell=True)
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/subprocess.py", line 271, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command 'cd src/picohttpparser && ./build' returned non-zero exit status 1

I am also on a Mac. Not sure if you figured that out telepathically, or just switched the title since @solie was having trouble with Mac :) I could go get my Linux computer or startup a VM but I'm lazy... sorry

squeaky-pl commented 7 years ago

@r0fls can you try commenting out strip line since it shouldn't be too important really, like @solie did. I am gonna fix this mess today.

solie commented 7 years ago

I guess I just have messed up some python env before, so I fixed my env and rerun the python3 setup.py bdist_wheel, found out that just commenting out the strip line is enough, so no need to change the build.py and setup.py. I don't even need to use CFLAGS.

r0fls commented 7 years ago

While the installation succeeds when I add the -x flag or comment out that line, this still happens when trying to run the hello world example:

$ python3 hello.py 
Traceback (most recent call last):
  File "hello.py", line 1, in <module>
    from japronto import Application
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/japronto-0.1-py3.5-macosx-10.6-intel.egg/japronto/__init__.py", line 1, in <module>
    from .app import Application  # noqa
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/japronto-0.1-py3.5-macosx-10.6-intel.egg/japronto/app/__init__.py", line 12, in <module>
    from japronto.protocol.cprotocol import Protocol
ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/japronto-0.1-py3.5-macosx-10.6-intel.egg/japronto/protocol/cprotocol.cpython-35m-darwin.so, 2): Library not loaded: libpicohttpparser.so
  Referenced from: /Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/japronto-0.1-py3.5-macosx-10.6-intel.egg/japronto/protocol/cprotocol.cpython-35m-darwin.so
  Reason: image not found

Any ideas? This happens whether or not I use CFLAGS.

solie commented 7 years ago

@r0fls, you need to copy src/picohttpparser/libpicohttpparser.so to /usr/local/lib

r0fls commented 7 years ago

@solie awesome, that worked -- shouldn't that be happening in the installation though?

squeaky-pl commented 7 years ago

I hate python packaging with passion. I am gonna change that to statically link picohttpparser with cextensions.

ojss commented 7 years ago

@squeaky-pl isn't copying the shared lib possible through setup.py?

henry0312 commented 7 years ago
$ cd path/to/site-packages/japronto-0.1-py3.5-macosx-10.11-x86_64.egg/japronto/protocol
$ install_name_tool \
-change libpicohttpparser.so @loader_path/../../picohttpparser/libpicohttpparser.so \
cprotocol.cpython-35m-darwin.so

works fine. However, I don't know how to run the fix in setup.py.

kokujin commented 7 years ago

I have this problem with piton too ─$ piton install japronto --save

Traceback (most recent call last):
  File "/usr/local/bin/piton", line 11, in <module>
    sys.exit(main())
  File "/usr/local/lib/python2.7/site-packages/piton/main.py", line 43, in main
    command.run(args)
  File "/usr/local/lib/python2.7/site-packages/piton/commands/install.py", line 18, in run
    cls.install_by_name(args.programs, save=args.save)
  File "/usr/local/lib/python2.7/site-packages/piton/commands/install.py", line 33, in install_by_name
    cls.install(install_queue)
  File "/usr/local/lib/python2.7/site-packages/piton/commands/install.py", line 41, in install
    cls.install_single(package)
  File "/usr/local/lib/python2.7/site-packages/piton/commands/install.py", line 45, in install_single
    package.get_wanted_version()
  File "/usr/local/lib/python2.7/site-packages/piton/package.py", line 48, in get_wanted_version
    self.avaliable_versions = list(map(lambda version: version["version"], versions_metadata))
TypeError: argument 2 to map() must support iteration
squeaky-pl commented 7 years ago

@kokujin this is not related to this issue. Please open new issue next time. You need to install Python 3.5 at least to get Japronto running.

squeaky-pl commented 7 years ago

Hi OSX users, I made a branch where I try to address build problems. Can somebody with a Mac check it out?

git clone https://github.com/squeaky-pl/japronto
cd japronto
git checkout build-uplist
python setup.py bdist_wheel

The related PR is here: https://github.com/squeaky-pl/japronto/pull/37/files

Thanks

squeaky-pl commented 7 years ago

@r0fls @solie @henry0312 Can you try when you have a moment?

ojss commented 7 years ago

Confirmed its working for me!

On 7 Feb 2017, 4:35 PM +0530, Paweł Piotr Przeradowski notifications@github.com, wrote:

@r0fls @solie @henry0312 Can you try when you have a moment? — You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.

solie commented 7 years ago

Ok, just tried it and my only issue is clang: error: unknown argument: '-frecord-gcc-switches', so I've to remove this option from build.py. Now, I don't need to manually copy the libpicohttpserver.so to the lib folder and running the examples is just works

squeaky-pl commented 7 years ago

@solie cool!, gonna remove that on clang

can you try this snippet for me on the python you tried and paste output so I can now how to detect clang:

python -c 'from distutils.ccompiler import new_compiler; from distutils.sysconfig import customize_compiler; c = new_compiler(); customize_compiler(c); print(c.compiler_so)'
solie commented 7 years ago

Here it is:

python3 -c 'from distutils.ccompiler import new_compiler; from distutils.sysconfig import customize_compiler; c = new_compiler(); customize_compiler(c); print(c.compiler_so)' ['clang', '-Wno-unused-result', '-Wsign-compare', '-Wunreachable-code', '-fno-common', '-dynamic', '-DNDEBUG', '-g', '-fwrapv', '-O3', '-Wall', '-Wstrict-prototypes']

squeaky-pl commented 7 years ago

@solie can you pull again and retry to confirm it doesnt fail with clang

solie commented 7 years ago

Yup, all is good now!

squeaky-pl commented 7 years ago

OK, so 0.1.1 release is coming and I'm gonna setup wheel building for OSX on Travis soon.

aphillipo commented 7 years ago

Shall I test this too then? Or the 0.1.1 release?

squeaky-pl commented 7 years ago

Please wait for 0.1.1 wheels. When I'm done with wheels I am gonna ping you back to test if the wheels are installable and work and then let's do the 0.1.1 release.

aphillipo commented 7 years ago

Okay so;

pip3 install git+git://github.com/squeaky-pl/japronto.git@master

Works flawlessly for me! Thanks!

squeaky-pl commented 7 years ago

waiting

After getting more familiar with clang, waiting for osx workers on Travis, different ways to install Python on OSX and building wheels on OSX I think I finally got it:

https://pypi.python.org/pypi?:action=display&name=japronto&version=0.1.1a0

@aphillipo @r0fls @solie @ojss can you try pip3 install japronto==0.1.1a0 and running a hello world app. If it works we shall proceed to release 0.1.1.

aphillipo commented 7 years ago

Works! Well played :-D

solie commented 7 years ago

Yup, working good!

ojss commented 7 years ago

Works perfectly.

On 8 Feb 2017, 5:27 PM +0530, maz_solie notifications@github.com, wrote:

Yup, working good!

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub (https://github.com/squeaky-pl/japronto/issues/1#issuecomment-278308670), or mute the thread (https://github.com/notifications/unsubscribe-auth/AKL6ARYK4ET7qzrDQCke4-FVDgAJ9qmAks5raa2XgaJpZM4LzBo0).

squeaky-pl commented 7 years ago

0.1.1 is out, closing this.

cnp96 commented 5 years ago

Hi OSX users, I made a branch where I try to address build problems. Can somebody with a Mac check it out?

git clone https://github.com/squeaky-pl/japronto
cd japronto
git checkout build-uplist
python setup.py bdist_wheel

The related PR is here: https://github.com/squeaky-pl/japronto/pull/37/files

Thanks

This works in OSX :)