Closed tetherit closed 11 years ago
@selwin Any ideas?
Does it work if you install it using virtualenv
? I suspect this is due to your distro tampering with Python's installation layout, similar to https://github.com/tobie/ua-parser/pull/160 .
@hackeron what Linux distro are you installing ua-parser on? We'll need more information on where regexes.yaml
gets copied to during installation.
I am on ubuntu 12.10, clean install (dev box), I'm doing:
# pip install pyyaml ua-parser
Downloading/unpacking pyyaml
Downloading PyYAML-3.10.zip (364Kb): 364Kb downloaded
Running setup.py egg_info for package pyyaml
Downloading/unpacking ua-parser
Downloading ua-parser-0.3.2.tar.gz
Running setup.py egg_info for package ua-parser
Installing collected packages: pyyaml, ua-parser
Running setup.py install for pyyaml
checking if libyaml is compilable
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/include/python2.7 -c build/temp.linux-x86_64-2.7/check_libyaml.c -o build/temp.linux-x86_64-2.7/check_libyaml.o
build/temp.linux-x86_64-2.7/check_libyaml.c:2:18: fatal error: yaml.h: No such file or directory
compilation terminated.
libyaml is not found or a compiler error: forcing --without-libyaml
(if libyaml is installed correctly, you may need to
specify the option --include-dirs or uncomment and
modify the parameter include_dirs in setup.cfg)
Running setup.py install for ua-parser
Converting regexes.yaml to json...
Successfully installed pyyaml ua-parser
Cleaning up...
Then when I try to do from ua_parser import user_agent_parser I see the above error.
It seems like pyyaml failed to install. See this line here:
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/include/python2.7 -c build/temp.linux-x86_64-2.7/check_libyaml.c -o build/temp.linux-x86_64-2.7/check_libyaml.o
build/temp.linux-x86_64-2.7/check_libyaml.c:2:18: fatal error: yaml.h: No such file or directory
compilation terminated.
As a workaround this works:
ln -s /usr/local/lib/python2.7/dist-packages/ua_parser-0.3.2-py2.7.egg/data/regexes.yaml /usr/local/lib/python2.7/dist-packages/ua_parser-0.3.2-py2.7.egg/ua_parser/regexes.yaml
I just posted a pull request as part of #213, sorry I forgot to check the existing issues first.
I'm seeing the same issue in a virtualenv on a fedora 18 box, python 2.7.3, with both pyyaml (3.10) and ua-parser (0.3.2) installed via pip. The regexes.yaml gets installed to $VIRTUALENV/lib/python2.7/site-packages/ua_parser-0.3.2-py2.7.egg/data/regexes.yaml. The existing ROOT_DIR/regexes.yaml lookup, as well as the resource_string('ua_parser', 'regexes.yaml') call recommended in #160, both fail.
I just tried installing ua_parser
on my Mac and it seems to be working fine, my Ubuntu development and production boxes (12.04) at work was also able to successfully install this package via pip
, with virtualenv
.
I'm worried that we will break installation on some other distros/setup if we merge https://github.com/tobie/ua-parser/pull/213 in. I think the best solution would be to try and locate regexes.yaml
at both ROOT_DIR
and DATA_DIR
.
What do you think @elsigh ?
Just tested on a Mac as well, and you're right, works like a charm. Wonder if it's just fedora, or if if rhel/centos do the same thing.
Sorry, I'm out of touch for the rest of the week, but sounds like you all have this figured out.
On Tue, Mar 12, 2013 at 11:14 AM, David Bonner notifications@github.comwrote:
Just tested on a Mac as well, and you're right, works like a charm. Wonder if it's just fedora, or if if rhel/centos do the same thing.
— Reply to this email directly or view it on GitHubhttps://github.com/tobie/ua-parser/issues/209#issuecomment-14793067 .
If some of you need repo access to fix this, please LMK.
I'll try to work on a patch and open a pull request tonight.
I'm working on a patch to fix python version on Fedora, but found that the current master has test failures. My plan is to now create a branch from the current release on PyPI. Mind creating a python-stable
branch based on commit c4541daee8db4aac97723512983cb0fa09cf13d4 so I can open a pull request to that branch?
Or alternatively, if you don't mind please give me push access to this repo so I can more easily keep the PyPI version in sync (I'm the current maintainer of the ua-parser's PyPI package).
I have uploaded the fix to my ua-parser repo https://github.com/selwin/ua-parser
@rascalking can you try installing it with pip install -e git+git://github.com/selwin/ua-parser.git#egg=ua-parser
and check if it now works on Fedora?
Hitting some issues with the install (the install command is trying to pass "--no-deps" to setup.py, which doesn't accept it), presumably because I've got distribute installed on my machine instead of setuptools.
However, I noticed that when I uninstalled the one from pypi, it removed a copy of regexes.yaml from the root of my virtualenv. Upon further investigation, I'm seeing the following: a) After install, there are two copies of regexes.yaml, $VIRTUAL_ENV/data/regexes.yaml, and $VIRTUAL_ENV/lib/python2.7/ua_parser/regexes.yaml. b) After install, there's one copy of regexes.json, at $VIRTUAL_ENV/lib/python2.7/ua_parser/regexes.json. c) After uninstall, $VIRTUAL_ENV/data/regexes.yaml is gone, but both versions (.yaml and .json) in $VIRTUAL_ENV/lib/python2.7/ua_parser are still there.
I'm new to this library...is there a reason we're telling setuptools/distribute to package regexes.yaml as a system-wide data file (by putting it under data_files instead of package_data), then manually copying it into the package data directory? Wouldn't it be easier to simply specify it under package_data? Then pkg_resources.resource_filename should theoretically always work.
Let me test a patch of my own on fedora and osx, and get back to you...I think that may work better.
On Thu, Mar 14, 2013 at 9:32 AM, Selwin Ong notifications@github.comwrote:
I have uploaded the fix to my ua-parser repo https://github.com/selwin/ua-parser
@rascalking https://github.com/rascalking can you try installing it with pip install -e git+git:// github.com/selwin/ua-parser.git#egg=ua-parser and check if it now works on Fedora?
— Reply to this email directly or view it on GitHubhttps://github.com/tobie/ua-parser/issues/209#issuecomment-14902027 .
david bonner // dbonner@gmail.com
@rascalking no reason other than ignorance :). Alright, let me know how it goes. Thanks!
Ah, apparently one reason is because it's an incredible pain in the ass to find a way to get distutils to include files outside your package directory (ua-parser/py) as package data. I noticed the haskell port symlinks regexes.yaml in, and the perl port has its own copy, both presumably to work around a similar packaging issue.
Is there any objection to doing something similar for the python port? If not, I can try to copy it down before the install happens, but it'd be easier, and the setup.py would be cleaner, if we could just symlink it.
On Fri, Mar 15, 2013 at 9:46 AM, Selwin Ong notifications@github.comwrote:
@rascalking https://github.com/rascalking no reason other than ignorance :). Alright, let me know how it goes. Thanks!
— Reply to this email directly or view it on GitHubhttps://github.com/tobie/ua-parser/issues/209#issuecomment-14961227 .
david bonner // dbonner@gmail.com
Managed to avoid needing a symlink, and I think I've got a fix. Can somebody with an ubuntu vm try to install my patch via "pip install git+git://github.com/rascalking/ua-parser.git@py-install-refactor#egg=ua-parser", and let me know if that works there?
@rascalking Installed just fine on Ubuntu 10.04 with Python 2.6 :+1:
Happy to merge. Where's the PR?
@rascalking should open a PR.
As for PyPI relase, @rascalking's commits are made on top of the current master branch with failing tests. My plan is to pull in @rascalking's installation related commits on top of my stable python branch and upload it to pypi as a bug fix release. Is that acceptable to you @tobie and @elsigh ?
@elsigh please way in, here. As I have no clue what these fine gentlemen are talking about. :)
PR is #217.
I'm hitting this bug with regexex.yaml, if I use the PyYAML installed by install_requires = ['PyYAML']
when I do python setup.py develop
.
I'm trying this on a Mac with Python 2.7.3 installed by Homebrew. I'm also using virtualenv and virtualenvwrapper
When I run @rascalking's patch, I get the following errors
georger@mac-georger:~/src/account_cob$ (master) mkvirtualenv account_cob
New python executable in account_cob/bin/python
Installing setuptools.............done.
Installing pip...............done.
(account_cob)georger@mac-georger:~/src/account_cob$ (master) pip install git+git://github.com/rascalking/ua-parser.git@py-install-refactor#egg=ua-parser
Downloading/unpacking ua-parser from git+git://github.com/rascalking/ua-parser.git@py-install-refactor#egg=ua-parser
Running setup.py egg_info for package ua-parser
Downloading/unpacking pyyaml (from ua-parser)
Running setup.py egg_info for package pyyaml
Installing collected packages: ua-parser, pyyaml
Running setup.py install for ua-parser
Converting regexes.yaml to json...
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/Users/georger/pyenvs/account_cob/build/ua-parser/setup.py", line 54, in <module>
'Topic :: Software Development :: Libraries :: Python Modules',
File "/usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/core.py", line 152, in setup
dist.run_commands()
File "/usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py", line 953, in run_commands
self.run_command(cmd)
File "/usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py", line 972, in run_command
cmd_obj.run()
File "/Users/georger/pyenvs/account_cob/build/ua-parser/setup.py", line 24, in run
import yaml
ImportError: No module named yaml
Complete output from command /Users/georger/pyenvs/account_cob/bin/python -c "import setuptools;__file__='/Users/georger/pyenvs/account_cob/build/ua-parser/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /var/folders/j3/cblrmq691pd07lf4148ftplm0000gp/T/pip-CGT0q9-record/install-record.txt --single-version-externally-managed --install-headers /Users/georger/pyenvs/account_cob/bin/../include/site/python2.7:
running install
Copying regexes.yaml to package directory...
Converting regexes.yaml to json...
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/Users/georger/pyenvs/account_cob/build/ua-parser/setup.py", line 54, in <module>
'Topic :: Software Development :: Libraries :: Python Modules',
File "/usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/core.py", line 152, in setup
dist.run_commands()
File "/usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py", line 953, in run_commands
self.run_command(cmd)
File "/usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py", line 972, in run_command
cmd_obj.run()
File "/Users/georger/pyenvs/account_cob/build/ua-parser/setup.py", line 24, in run
import yaml
ImportError: No module named yaml
----------------------------------------
Command /Users/georger/pyenvs/account_cob/bin/python -c "import setuptools;__file__='/Users/georger/pyenvs/account_cob/build/ua-parser/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /var/folders/j3/cblrmq691pd07lf4148ftplm0000gp/T/pip-CGT0q9-record/install-record.txt --single-version-externally-managed --install-headers /Users/georger/pyenvs/account_cob/bin/../include/site/python2.7 failed with error code 1 in /Users/georger/pyenvs/account_cob/build/ua-parser
Storing complete log in /Users/georger/.pip/pip.log
@georgevreilly try installing pyyaml
first. It chocked on this line:
File "/Users/georger/pyenvs/account_cob/build/ua-parser/setup.py", line 24, in run
import yaml
ImportError: No module named yaml
@selwin, you're right, of course. It works fine if I pip install PyYAML
before installing @rascalking's patch, and I no longer get the error about the missing regexes.yaml at runtime.
When I install @rascalking's patched version of ua-parser via setup.py develop
, I get the dreaded No such file regexes.yaml error. When I install via pip
, it works.
Note: I uploaded a custom package to our internal PyPI server, thus:
(ua-parser)georger@mac-georger:~/src/ua-parser$ (py-install-refactor) python setup.py --verbose sdist upload -r internal
<...>
Creating tar archive
removing 'ua-parser-0.3.3' (and everything under it)
running upload
Using PyPI login from /Users/georger/.pypirc
Submitting dist/ua-parser-0.3.3.tar.gz to http://pypi.build.cozi.com/
Server response (200): OK
Then I tried to use it in a different package, which depends only on PyYAML and ua-parser:
georger@mac-georger:~/src/todo_cob$ (master) cat setup.py
from setuptools import setup, find_packages
setup(
name='TodoCob',
version='0.1dev',
install_requires=[
'PyYAML',
'ua-parser',
]
)
I created a fresh virtualenv:
georger@mac-georger:~/src/todo_cob$ (master) mkvirtualenv todo_cob
New python executable in todo_cob/bin/python
Installing setuptools............done.
Installing pip...............done.
virtualenvwrapper.user_scripts creating /Users/georger/pyenvs/todo_cob/bin/predeactivate
<...>
Running setup.py develop
against the private PyPI server:
(todo_cob)georger@mac-georger:~/src/todo_cob$ (master) python setup.py -v develop -i http://pypi.build.cozi.com/simple
running develop
running egg_info
writing requirements to TodoCob.egg-info/requires.txt
writing TodoCob.egg-info/PKG-INFO
writing top-level names to TodoCob.egg-info/top_level.txt
writing dependency_links to TodoCob.egg-info/dependency_links.txt
reading manifest file 'TodoCob.egg-info/SOURCES.txt'
writing manifest file 'TodoCob.egg-info/SOURCES.txt'
running build_ext
Creating /Users/georger/pyenvs/todo_cob/lib/python2.7/site-packages/TodoCob.egg-link (link to .)
Adding TodoCob 0.1dev to easy-install.pth file
Saving /Users/georger/pyenvs/todo_cob/lib/python2.7/site-packages/easy-install.pth
Installed /Users/georger/src/todo_cob
Processing dependencies for TodoCob==0.1dev
Searching for ua-parser
Reading http://pypi.build.cozi.com/simple/ua-parser/
Found link: http://pypi.build.cozi.com/packages/ua-parser-0.3.3.tar.gz
Best match: ua-parser 0.3.3
Downloading http://pypi.build.cozi.com/packages/ua-parser-0.3.3.tar.gz
Processing ua-parser-0.3.3.tar.gz
Unpacking ua-parser-0.3.3 to /var/folders/j3/cblrmq691pd07lf4148ftplm0000gp/T/easy_install-4TWQkf/ua-parser-0.3.3
Unpacking ua-parser-0.3.3/MANIFEST.in to /var/folders/j3/cblrmq691pd07lf4148ftplm0000gp/T/easy_install-4TWQkf/ua-parser-0.3.3/MANIFEST.in
Unpacking ua-parser-0.3.3/PKG-INFO to /var/folders/j3/cblrmq691pd07lf4148ftplm0000gp/T/easy_install-4TWQkf/ua-parser-0.3.3/PKG-INFO
Unpacking ua-parser-0.3.3/py to /var/folders/j3/cblrmq691pd07lf4148ftplm0000gp/T/easy_install-4TWQkf/ua-parser-0.3.3/py
Unpacking ua-parser-0.3.3/py/ua_parser to /var/folders/j3/cblrmq691pd07lf4148ftplm0000gp/T/easy_install-4TWQkf/ua-parser-0.3.3/py/ua_parser
Unpacking ua-parser-0.3.3/py/ua_parser/__init__.py to /var/folders/j3/cblrmq691pd07lf4148ftplm0000gp/T/easy_install-4TWQkf/ua-parser-0.3.3/py/ua_parser/__init__.py
Unpacking ua-parser-0.3.3/py/ua_parser/user_agent_parser.py to /var/folders/j3/cblrmq691pd07lf4148ftplm0000gp/T/easy_install-4TWQkf/ua-parser-0.3.3/py/ua_parser/user_agent_parser.py
Unpacking ua-parser-0.3.3/py/ua_parser/user_agent_parser_test.py to /var/folders/j3/cblrmq691pd07lf4148ftplm0000gp/T/easy_install-4TWQkf/ua-parser-0.3.3/py/ua_parser/user_agent_parser_test.py
Unpacking ua-parser-0.3.3/py/ua_parser.egg-info to /var/folders/j3/cblrmq691pd07lf4148ftplm0000gp/T/easy_install-4TWQkf/ua-parser-0.3.3/py/ua_parser.egg-info
Unpacking ua-parser-0.3.3/py/ua_parser.egg-info/dependency_links.txt to /var/folders/j3/cblrmq691pd07lf4148ftplm0000gp/T/easy_install-4TWQkf/ua-parser-0.3.3/py/ua_parser.egg-info/dependency_links.txt
Unpacking ua-parser-0.3.3/py/ua_parser.egg-info/not-zip-safe to /var/folders/j3/cblrmq691pd07lf4148ftplm0000gp/T/easy_install-4TWQkf/ua-parser-0.3.3/py/ua_parser.egg-info/not-zip-safe
Unpacking ua-parser-0.3.3/py/ua_parser.egg-info/PKG-INFO to /var/folders/j3/cblrmq691pd07lf4148ftplm0000gp/T/easy_install-4TWQkf/ua-parser-0.3.3/py/ua_parser.egg-info/PKG-INFO
Unpacking ua-parser-0.3.3/py/ua_parser.egg-info/requires.txt to /var/folders/j3/cblrmq691pd07lf4148ftplm0000gp/T/easy_install-4TWQkf/ua-parser-0.3.3/py/ua_parser.egg-info/requires.txt
Unpacking ua-parser-0.3.3/py/ua_parser.egg-info/SOURCES.txt to /var/folders/j3/cblrmq691pd07lf4148ftplm0000gp/T/easy_install-4TWQkf/ua-parser-0.3.3/py/ua_parser.egg-info/SOURCES.txt
Unpacking ua-parser-0.3.3/py/ua_parser.egg-info/top_level.txt to /var/folders/j3/cblrmq691pd07lf4148ftplm0000gp/T/easy_install-4TWQkf/ua-parser-0.3.3/py/ua_parser.egg-info/top_level.txt
Unpacking ua-parser-0.3.3/regexes.yaml to /var/folders/j3/cblrmq691pd07lf4148ftplm0000gp/T/easy_install-4TWQkf/ua-parser-0.3.3/regexes.yaml
Unpacking ua-parser-0.3.3/setup.cfg to /var/folders/j3/cblrmq691pd07lf4148ftplm0000gp/T/easy_install-4TWQkf/ua-parser-0.3.3/setup.cfg
Unpacking ua-parser-0.3.3/setup.py to /var/folders/j3/cblrmq691pd07lf4148ftplm0000gp/T/easy_install-4TWQkf/ua-parser-0.3.3/setup.py
Running ua-parser-0.3.3/setup.py bdist_egg --dist-dir /var/folders/j3/cblrmq691pd07lf4148ftplm0000gp/T/easy_install-4TWQkf/ua-parser-0.3.3/egg-dist-tmp-WZgZuM
running bdist_egg
running egg_info
writing requirements to py/ua_parser.egg-info/requires.txt
writing py/ua_parser.egg-info/PKG-INFO
writing top-level names to py/ua_parser.egg-info/top_level.txt
writing dependency_links to py/ua_parser.egg-info/dependency_links.txt
reading manifest file 'py/ua_parser.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
writing manifest file 'py/ua_parser.egg-info/SOURCES.txt'
installing library code to build/bdist.macosx-10.7-x86_64/egg
running install_lib
running build_py
creating build
creating build/lib
creating build/lib/ua_parser
copying py/ua_parser/__init__.py -> build/lib/ua_parser
copying py/ua_parser/user_agent_parser.py -> build/lib/ua_parser
copying py/ua_parser/user_agent_parser_test.py -> build/lib/ua_parser
creating build/bdist.macosx-10.7-x86_64
creating build/bdist.macosx-10.7-x86_64/egg
creating build/bdist.macosx-10.7-x86_64/egg/ua_parser
copying build/lib/ua_parser/__init__.py -> build/bdist.macosx-10.7-x86_64/egg/ua_parser
copying build/lib/ua_parser/user_agent_parser.py -> build/bdist.macosx-10.7-x86_64/egg/ua_parser
copying build/lib/ua_parser/user_agent_parser_test.py -> build/bdist.macosx-10.7-x86_64/egg/ua_parser
byte-compiling build/bdist.macosx-10.7-x86_64/egg/ua_parser/__init__.py to __init__.pyc
byte-compiling build/bdist.macosx-10.7-x86_64/egg/ua_parser/user_agent_parser.py to user_agent_parser.pyc
byte-compiling build/bdist.macosx-10.7-x86_64/egg/ua_parser/user_agent_parser_test.py to user_agent_parser_test.pyc
creating build/bdist.macosx-10.7-x86_64/egg/EGG-INFO
copying py/ua_parser.egg-info/PKG-INFO -> build/bdist.macosx-10.7-x86_64/egg/EGG-INFO
copying py/ua_parser.egg-info/SOURCES.txt -> build/bdist.macosx-10.7-x86_64/egg/EGG-INFO
copying py/ua_parser.egg-info/dependency_links.txt -> build/bdist.macosx-10.7-x86_64/egg/EGG-INFO
copying py/ua_parser.egg-info/not-zip-safe -> build/bdist.macosx-10.7-x86_64/egg/EGG-INFO
copying py/ua_parser.egg-info/requires.txt -> build/bdist.macosx-10.7-x86_64/egg/EGG-INFO
copying py/ua_parser.egg-info/top_level.txt -> build/bdist.macosx-10.7-x86_64/egg/EGG-INFO
creating '/var/folders/j3/cblrmq691pd07lf4148ftplm0000gp/T/easy_install-4TWQkf/ua-parser-0.3.3/egg-dist-tmp-WZgZuM/ua_parser-0.3.3-py2.7.egg' and adding 'build/bdist.macosx-10.7-x86_64/egg' to it
removing 'build/bdist.macosx-10.7-x86_64/egg' (and everything under it)
creating /Users/georger/pyenvs/todo_cob/lib/python2.7/site-packages/ua_parser-0.3.3-py2.7.egg
Extracting ua_parser-0.3.3-py2.7.egg to /Users/georger/pyenvs/todo_cob/lib/python2.7/site-packages
byte-compiling /Users/georger/pyenvs/todo_cob/lib/python2.7/site-packages/ua_parser-0.3.3-py2.7.egg/ua_parser/__init__.py to __init__.pyc
byte-compiling /Users/georger/pyenvs/todo_cob/lib/python2.7/site-packages/ua_parser-0.3.3-py2.7.egg/ua_parser/user_agent_parser.py to user_agent_parser.pyc
byte-compiling /Users/georger/pyenvs/todo_cob/lib/python2.7/site-packages/ua_parser-0.3.3-py2.7.egg/ua_parser/user_agent_parser_test.py to user_agent_parser_test.pyc
Adding ua-parser 0.3.3 to easy-install.pth file
Saving /Users/georger/pyenvs/todo_cob/lib/python2.7/site-packages/easy-install.pth
Installed /Users/georger/pyenvs/todo_cob/lib/python2.7/site-packages/ua_parser-0.3.3-py2.7.egg
Now setup.py develop
is installing PyYAML (mostly elided):
Searching for PyYAML
Reading http://pypi.build.cozi.com/simple/PyYAML/
Found link: http://pypi.build.cozi.com/packages/PyYAML-3.10.tar.gz
Best match: PyYAML 3.10
Downloading http://pypi.build.cozi.com/packages/PyYAML-3.10.tar.gz
Processing PyYAML-3.10.tar.gz
<snip>
Installed /Users/georger/pyenvs/todo_cob/lib/python2.7/site-packages/PyYAML-3.10-py2.7-macosx-10.7-x86_64.egg
Finished processing dependencies for TodoCob==0.1dev
What does pip think we have?
(todo_cob)georger@mac-georger:~/src/todo_cob$ (master) pip freeze
PyYAML==3.10
-e git+https://github.com/cozi/todo_cob.git@30718a8778a713e4a27d646b62fc3aaf7e022a84#egg=TodoCob-dev
ua-parser==0.3.3
wsgiref==0.1.2
Let's try it out:
(todo_cob)georger@mac-georger:~/src/todo_cob$ (master) python
Python 2.7.3 (default, Jan 25 2013, 18:53:54)
[GCC 4.2.1 Compatible Apple Clang 4.1 ((tags/Apple/clang-421.11.66))] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from ua_parser import user_agent_parser
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/georger/pyenvs/todo_cob/lib/python2.7/site-packages/ua_parser-0.3.3-py2.7.egg/ua_parser/user_agent_parser.py", line 396, in <module>
yamlFile = open(yamlPath)
IOError: [Errno 2] No such file or directory: '/Users/georger/pyenvs/todo_cob/lib/python2.7/site-packages/ua_parser-0.3.3-py2.7.egg/ua_parser/regexes.yaml'
Uninstall.
(todo_cob)georger@mac-georger:~/src/todo_cob$ (master) pip uninstall ua-parser
Uninstalling ua-parser:
/Users/georger/pyenvs/todo_cob/lib/python2.7/site-packages/ua_parser-0.3.3-py2.7.egg
Proceed (y/n)? y
Successfully uninstalled ua-parser
Install with pip from the same private PyPI server.
(todo_cob)georger@mac-georger:~/src/todo_cob$ (master) pip install -v -i http://pypi.build.cozi.com/simple ua-parser
Downloading/unpacking ua-parser
Downloading ua-parser-0.3.3.tar.gz
Running setup.py egg_info for package ua-parser
running egg_info
creating pip-egg-info/ua_parser.egg-info
writing requirements to pip-egg-info/ua_parser.egg-info/requires.txt
writing pip-egg-info/ua_parser.egg-info/PKG-INFO
writing top-level names to pip-egg-info/ua_parser.egg-info/top_level.txt
writing dependency_links to pip-egg-info/ua_parser.egg-info/dependency_links.txt
writing manifest file 'pip-egg-info/ua_parser.egg-info/SOURCES.txt'
warning: manifest_maker: standard file '-c' not found
reading manifest file 'pip-egg-info/ua_parser.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
writing manifest file 'pip-egg-info/ua_parser.egg-info/SOURCES.txt'
Requirement already satisfied (use --upgrade to upgrade): pyyaml in /Users/georger/pyenvs/todo_cob/lib/python2.7/site-packages/PyYAML-3.10-py2.7-macosx-10.7-x86_64.egg (from ua-parser)
Installing collected packages: ua-parser
Running setup.py install for ua-parser
running install
Copying regexes.yaml to package directory...
Converting regexes.yaml to json...
running build
running build_py
creating build
creating build/lib
creating build/lib/ua_parser
copying py/ua_parser/__init__.py -> build/lib/ua_parser
copying py/ua_parser/user_agent_parser.py -> build/lib/ua_parser
copying py/ua_parser/user_agent_parser_test.py -> build/lib/ua_parser
running egg_info
writing requirements to py/ua_parser.egg-info/requires.txt
writing py/ua_parser.egg-info/PKG-INFO
writing top-level names to py/ua_parser.egg-info/top_level.txt
writing dependency_links to py/ua_parser.egg-info/dependency_links.txt
warning: manifest_maker: standard file '-c' not found
reading manifest file 'py/ua_parser.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
writing manifest file 'py/ua_parser.egg-info/SOURCES.txt'
copying py/ua_parser/regexes.yaml -> build/lib/ua_parser
copying py/ua_parser/regexes.json -> build/lib/ua_parser
running install_lib
creating /Users/georger/pyenvs/todo_cob/lib/python2.7/site-packages/ua_parser
copying build/lib/ua_parser/__init__.py -> /Users/georger/pyenvs/todo_cob/lib/python2.7/site-packages/ua_parser
copying build/lib/ua_parser/regexes.json -> /Users/georger/pyenvs/todo_cob/lib/python2.7/site-packages/ua_parser
copying build/lib/ua_parser/regexes.yaml -> /Users/georger/pyenvs/todo_cob/lib/python2.7/site-packages/ua_parser
copying build/lib/ua_parser/user_agent_parser.py -> /Users/georger/pyenvs/todo_cob/lib/python2.7/site-packages/ua_parser
copying build/lib/ua_parser/user_agent_parser_test.py -> /Users/georger/pyenvs/todo_cob/lib/python2.7/site-packages/ua_parser
byte-compiling /Users/georger/pyenvs/todo_cob/lib/python2.7/site-packages/ua_parser/__init__.py to __init__.pyc
byte-compiling /Users/georger/pyenvs/todo_cob/lib/python2.7/site-packages/ua_parser/user_agent_parser.py to user_agent_parser.pyc
byte-compiling /Users/georger/pyenvs/todo_cob/lib/python2.7/site-packages/ua_parser/user_agent_parser_test.py to user_agent_parser_test.pyc
running install_egg_info
Copying py/ua_parser.egg-info to /Users/georger/pyenvs/todo_cob/lib/python2.7/site-packages/ua_parser-0.3.3-py2.7.egg-info
running install_scripts
writing list of installed files to '/var/folders/j3/cblrmq691pd07lf4148ftplm0000gp/T/pip-MWZJyN-record/install-record.txt'
Successfully installed ua-parser
Cleaning up...
Removing temporary dir /Users/georger/pyenvs/todo_cob/build...
Now it works!
(todo_cob)georger@mac-georger:~/src/todo_cob$ (master) pythonPython 2.7.3 (default, Jan 25 2013, 18:53:54)
[GCC 4.2.1 Compatible Apple Clang 4.1 ((tags/Apple/clang-421.11.66))] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from ua_parser import user_agent_parser
>>> dir(user_agent_parser)
['DEVICE_PARSERS', 'DeviceParser', 'GetFilters', 'OSParser', 'OS_PARSERS', 'Parse', 'ParseDevice', 'ParseOS', 'ParseUserAgent', 'ParseWithJSOverrides', 'Pretty', 'PrettyOS', 'PrettyUserAgent', 'UA_PARSER_YAML', 'USER_AGENT_PARSERS', 'UserAgentParser', '__author__', '__builtins__', '__doc__', '__file__', '__name__', '__package__', '_device_parser', '_device_replacement', '_family_replacement', '_os_parser', '_os_replacement', '_regex', '_ua_parser', '_v1_replacement', 'json', 'json_file', 'json_path', 'os', 're', 'regexes', 'resource_filename', 'yaml', 'yamlPath']
Hell. I'm guessing that when installing this way, ua-parser's setup.py is being run from outside its directory. If that's the case, a fix I just pushed on a branch should solve the issue. I've verified that it continues to work for me with the test cases I can run (manyal setup.py, pip install .).
@georgevreilly, any chance you can try out https://github.com/rascalking/ua-parser/tree/py-setup-fix-again on your private pypi server to see if it fixes the issue for you?
Hey, I hit the yaml missing message too. Shouldn't the PyYAML package be a dependency of this package?
@malicustommade, it is a dependency...the issue we're trying to solve here is that due to different ways to install the package, it's tricky to get the data file we need (the regexes.yaml file).
Sorry about the delay. I'm afraid that it doesn't work.
I created a package of ua-parser with python setup.py sdist
. Note: I bumped the version number to 0.3.4, to be sure that I was getting the right one.
I confirmed that the updates to setup.py were present:
(todo_deploy)georger@mac-georger:~/src/ua-parser$ (py-setup-fix-again) tar -ztvf dist/ua-parser-0.3.4.tar.gz
drwxr-xr-x 0 georger staff 0 May 23 17:12 ua-parser-0.3.4/
-rw-r--r-- 0 georger staff 20 Jan 11 18:19 ua-parser-0.3.4/MANIFEST.in
-rw-r--r-- 0 georger staff 657 May 23 17:12 ua-parser-0.3.4/PKG-INFO
drwxr-xr-x 0 georger staff 0 May 23 17:12 ua-parser-0.3.4/py/
drwxr-xr-x 0 georger staff 0 May 23 17:12 ua-parser-0.3.4/py/ua_parser/
-rw-r--r-- 0 georger staff 20 Jan 11 18:19 ua-parser-0.3.4/py/ua_parser/__init__.py
-rw-r--r-- 0 georger staff 14722 May 23 15:54 ua-parser-0.3.4/py/ua_parser/user_agent_parser.py
-rw-r--r-- 0 georger staff 9353 Jan 11 18:19 ua-parser-0.3.4/py/ua_parser/user_agent_parser_test.py
drwxr-xr-x 0 georger staff 0 May 23 17:12 ua-parser-0.3.4/py/ua_parser.egg-info/
-rw-r--r-- 0 georger staff 1 May 23 17:12 ua-parser-0.3.4/py/ua_parser.egg-info/dependency_links.txt
-rw-r--r-- 0 georger staff 1 Feb 13 11:52 ua-parser-0.3.4/py/ua_parser.egg-info/not-zip-safe
-rw-r--r-- 0 georger staff 657 May 23 17:12 ua-parser-0.3.4/py/ua_parser.egg-info/PKG-INFO
-rw-r--r-- 0 georger staff 6 May 23 17:12 ua-parser-0.3.4/py/ua_parser.egg-info/requires.txt
-rw-r--r-- 0 georger staff 345 May 23 17:12 ua-parser-0.3.4/py/ua_parser.egg-info/SOURCES.txt
-rw-r--r-- 0 georger staff 10 May 23 17:12 ua-parser-0.3.4/py/ua_parser.egg-info/top_level.txt
-rw-r--r-- 0 georger staff 32009 May 23 16:46 ua-parser-0.3.4/regexes.yaml
-rw-r--r-- 0 georger staff 59 May 23 17:12 ua-parser-0.3.4/setup.cfg
-rw-r--r-- 0 georger staff 2001 May 23 17:12 ua-parser-0.3.4/setup.py
(todo_deploy)georger@mac-georger:~/src/ua-parser$ (py-setup-fix-again) cd dist/
(todo_deploy)georger@mac-georger:~/src/ua-parser/dist$ (py-setup-fix-again) tar -zxvf ua-parser-0.3.4.tar.gz ua-parser-0.3.4/setup.py
x ua-parser-0.3.4/setup.py
(todo_deploy)georger@mac-georger:~/src/ua-parser/dist$ (py-setup-fix-again) grep os.path ua-parser-0.3.4/setup.py
cwd = os.path.abspath(os.path.dirname(__file__))
yaml_src = os.path.join(cwd, 'regexes.yaml')
if not os.path.exists(yaml_src):
yaml_dest = os.path.join(cwd, 'py', 'ua_parser', 'regexes.yaml')
Here's the setup.cfg
for the package that's using ua-parser:
[easy_install]
index_url = http://pypi.corp.cozi.com/simple
Here's the relevant output from python setup.py -v install
:
(todo_deploy)georger@mac-georger:~/src/slingr$ (master) python setup.py -v install
running install
running bdist_egg
running egg_info
...
running install_lib
running build_py
...
Processing dependencies for Slingr==0.0.8
Searching for ua-parser
Reading http://pypi.corp.cozi.com/simple/ua-parser/
Found link: http://pypi.corp.cozi.com/packages/ua-parser-0.3.3.tar.gz
Found link: http://pypi.corp.cozi.com/packages/ua-parser-0.3.4.tar.gz
Best match: ua-parser 0.3.4
Downloading http://pypi.corp.cozi.com/packages/ua-parser-0.3.4.tar.gz
Processing ua-parser-0.3.4.tar.gz
Unpacking ua-parser-0.3.4 to /var/folders/j3/cblrmq691pd07lf4148ftplm0000gp/T/easy_install-JMIvVX/ua-parser-0.3.4
Unpacking ua-parser-0.3.4/MANIFEST.in to /var/folders/j3/cblrmq691pd07lf4148ftplm0000gp/T/easy_install-JMIvVX/ua-parser-0.3.4/MANIFEST.in
Unpacking ua-parser-0.3.4/PKG-INFO to /var/folders/j3/cblrmq691pd07lf4148ftplm0000gp/T/easy_install-JMIvVX/ua-parser-0.3.4/PKG-INFO
Unpacking ua-parser-0.3.4/py to /var/folders/j3/cblrmq691pd07lf4148ftplm0000gp/T/easy_install-JMIvVX/ua-parser-0.3.4/py
Unpacking ua-parser-0.3.4/py/ua_parser to /var/folders/j3/cblrmq691pd07lf4148ftplm0000gp/T/easy_install-JMIvVX/ua-parser-0.3.4/py/ua_parser
Unpacking ua-parser-0.3.4/py/ua_parser/__init__.py to /var/folders/j3/cblrmq691pd07lf4148ftplm0000gp/T/easy_install-JMIvVX/ua-parser-0.3.4/py/ua_parser/__init__.py
Unpacking ua-parser-0.3.4/py/ua_parser/user_agent_parser.py to /var/folders/j3/cblrmq691pd07lf4148ftplm0000gp/T/easy_install-JMIvVX/ua-parser-0.3.4/py/ua_parser/user_agent_parser.py
Unpacking ua-parser-0.3.4/py/ua_parser/user_agent_parser_test.py to /var/folders/j3/cblrmq691pd07lf4148ftplm0000gp/T/easy_install-JMIvVX/ua-parser-0.3.4/py/ua_parser/user_agent_parser_test.py
Unpacking ua-parser-0.3.4/py/ua_parser.egg-info to /var/folders/j3/cblrmq691pd07lf4148ftplm0000gp/T/easy_install-JMIvVX/ua-parser-0.3.4/py/ua_parser.egg-info
Unpacking ua-parser-0.3.4/py/ua_parser.egg-info/dependency_links.txt to /var/folders/j3/cblrmq691pd07lf4148ftplm0000gp/T/easy_install-JMIvVX/ua-parser-0.3.4/py/ua_parser.egg-info/dependency_links.txt
Unpacking ua-parser-0.3.4/py/ua_parser.egg-info/not-zip-safe to /var/folders/j3/cblrmq691pd07lf4148ftplm0000gp/T/easy_install-JMIvVX/ua-parser-0.3.4/py/ua_parser.egg-info/not-zip-safe
Unpacking ua-parser-0.3.4/py/ua_parser.egg-info/PKG-INFO to /var/folders/j3/cblrmq691pd07lf4148ftplm0000gp/T/easy_install-JMIvVX/ua-parser-0.3.4/py/ua_parser.egg-info/PKG-INFO
Unpacking ua-parser-0.3.4/py/ua_parser.egg-info/requires.txt to /var/folders/j3/cblrmq691pd07lf4148ftplm0000gp/T/easy_install-JMIvVX/ua-parser-0.3.4/py/ua_parser.egg-info/requires.txt
Unpacking ua-parser-0.3.4/py/ua_parser.egg-info/SOURCES.txt to /var/folders/j3/cblrmq691pd07lf4148ftplm0000gp/T/easy_install-JMIvVX/ua-parser-0.3.4/py/ua_parser.egg-info/SOURCES.txt
Unpacking ua-parser-0.3.4/py/ua_parser.egg-info/top_level.txt to /var/folders/j3/cblrmq691pd07lf4148ftplm0000gp/T/easy_install-JMIvVX/ua-parser-0.3.4/py/ua_parser.egg-info/top_level.txt
Unpacking ua-parser-0.3.4/regexes.yaml to /var/folders/j3/cblrmq691pd07lf4148ftplm0000gp/T/easy_install-JMIvVX/ua-parser-0.3.4/regexes.yaml
Unpacking ua-parser-0.3.4/setup.cfg to /var/folders/j3/cblrmq691pd07lf4148ftplm0000gp/T/easy_install-JMIvVX/ua-parser-0.3.4/setup.cfg
Unpacking ua-parser-0.3.4/setup.py to /var/folders/j3/cblrmq691pd07lf4148ftplm0000gp/T/easy_install-JMIvVX/ua-parser-0.3.4/setup.py
Running ua-parser-0.3.4/setup.py bdist_egg --dist-dir /var/folders/j3/cblrmq691pd07lf4148ftplm0000gp/T/easy_install-JMIvVX/ua-parser-0.3.4/egg-dist-tmp-NtDAFg
running bdist_egg
running egg_info
writing requirements to py/ua_parser.egg-info/requires.txt
writing py/ua_parser.egg-info/PKG-INFO
writing top-level names to py/ua_parser.egg-info/top_level.txt
writing dependency_links to py/ua_parser.egg-info/dependency_links.txt
reading manifest file 'py/ua_parser.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
writing manifest file 'py/ua_parser.egg-info/SOURCES.txt'
installing library code to build/bdist.macosx-10.7-x86_64/egg
running install_lib
running build_py
creating build
creating build/lib
creating build/lib/ua_parser
copying py/ua_parser/__init__.py -> build/lib/ua_parser
copying py/ua_parser/user_agent_parser.py -> build/lib/ua_parser
copying py/ua_parser/user_agent_parser_test.py -> build/lib/ua_parser
creating build/bdist.macosx-10.7-x86_64
creating build/bdist.macosx-10.7-x86_64/egg
creating build/bdist.macosx-10.7-x86_64/egg/ua_parser
copying build/lib/ua_parser/__init__.py -> build/bdist.macosx-10.7-x86_64/egg/ua_parser
copying build/lib/ua_parser/user_agent_parser.py -> build/bdist.macosx-10.7-x86_64/egg/ua_parser
copying build/lib/ua_parser/user_agent_parser_test.py -> build/bdist.macosx-10.7-x86_64/egg/ua_parser
byte-compiling build/bdist.macosx-10.7-x86_64/egg/ua_parser/__init__.py to __init__.pyc
byte-compiling build/bdist.macosx-10.7-x86_64/egg/ua_parser/user_agent_parser.py to user_agent_parser.pyc
byte-compiling build/bdist.macosx-10.7-x86_64/egg/ua_parser/user_agent_parser_test.py to user_agent_parser_test.pyc
creating build/bdist.macosx-10.7-x86_64/egg/EGG-INFO
copying py/ua_parser.egg-info/PKG-INFO -> build/bdist.macosx-10.7-x86_64/egg/EGG-INFO
copying py/ua_parser.egg-info/SOURCES.txt -> build/bdist.macosx-10.7-x86_64/egg/EGG-INFO
copying py/ua_parser.egg-info/dependency_links.txt -> build/bdist.macosx-10.7-x86_64/egg/EGG-INFO
copying py/ua_parser.egg-info/not-zip-safe -> build/bdist.macosx-10.7-x86_64/egg/EGG-INFO
copying py/ua_parser.egg-info/requires.txt -> build/bdist.macosx-10.7-x86_64/egg/EGG-INFO
copying py/ua_parser.egg-info/top_level.txt -> build/bdist.macosx-10.7-x86_64/egg/EGG-INFO
creating '/var/folders/j3/cblrmq691pd07lf4148ftplm0000gp/T/easy_install-JMIvVX/ua-parser-0.3.4/egg-dist-tmp-NtDAFg/ua_parser-0.3.4-py2.7.egg' and adding 'build/bdist.macosx-10.7-x86_64/egg' to it
removing 'build/bdist.macosx-10.7-x86_64/egg' (and everything under it)
creating /Users/georger/.virtualenvs/todo_deploy/lib/python2.7/site-packages/ua_parser-0.3.4-py2.7.egg
Extracting ua_parser-0.3.4-py2.7.egg to /Users/georger/.virtualenvs/todo_deploy/lib/python2.7/site-packages
byte-compiling /Users/georger/.virtualenvs/todo_deploy/lib/python2.7/site-packages/ua_parser-0.3.4-py2.7.egg/ua_parser/__init__.py to __init__.pyc
byte-compiling /Users/georger/.virtualenvs/todo_deploy/lib/python2.7/site-packages/ua_parser-0.3.4-py2.7.egg/ua_parser/user_agent_parser.py to user_agent_parser.pyc
byte-compiling /Users/georger/.virtualenvs/todo_deploy/lib/python2.7/site-packages/ua_parser-0.3.4-py2.7.egg/ua_parser/user_agent_parser_test.py to user_agent_parser_test.pyc
Adding ua-parser 0.3.4 to easy-install.pth file
Saving /Users/georger/.virtualenvs/todo_deploy/lib/python2.7/site-packages/easy-install.pth
Installed /Users/georger/.virtualenvs/todo_deploy/lib/python2.7/site-packages/ua_parser-0.3.4-py2.7.egg
I think you need to do something with regexes.yaml
in the build_py
command.
BTW, you can create a local PyPI easily with pip2pi. You don't even need a web server. In a package that depends on ua-parser, have a setup.cfg
that looks like:
[easy_install]
index_url = file:///Users/georger/.pip2pi/simple
and python setup.py install
will pull from ~/.pip2pi
.
In fact, you don't even need pip2pi. You can just drop the ua-parser tarball created by python setup.py sdist
into ~/.pip2pi/simple/ua-parser/
.
I fixed an issue with the installer failing on Linux. I've pushed the fixes to my branch. See pull request #268
Here's my understanding of how it works.
python setup.py develop
in ua-parser
source directoryua-parser.egg-link
is created in site-packages
pointing back to source directoryregexes.yaml
and regexes.json
get copied to py/ua_parser
python setup.py install
in ua-parser
source directoryua-parser
is created in site-packages
regexes.yaml
and regexes.json
python setup.py sdist
in ua-parser
source directorydist/ua-parser-VERSION.tar.gz
is createdregexes.yaml
, py/ua_parser/regexes.yaml
, and py/ua_parser/regexes.json
python setup.py install
in some other packageeasy_install ua-parser
python setup.py bdist_egg
is runpip install ua-parser
python setup.py install
is runYou can run a PyPI in your local filesystem.
setup.cfg
in the current directory[easy_install]
index_url = file:///Users/georger/.pip2pi/simple
-i
flagpip install ua-parser --index_url file:///Users/georger/.pip2pi/simple
@georgevreilly This fixes the bug for me on linux. Thanks a bunch! @selwin any plans to merge that in?
@malicustommade I'm not a repo conntributor so I can't merge this in. Can @elsigh or @tobie help?
Done deal - thanks!
On Fri, Jun 21, 2013 at 6:24 PM, Selwin Ong notifications@github.comwrote:
@malicustommade https://github.com/malicustommade I'm not a repo conntributor so I can't merge this in. Can @elsighhttps://github.com/elsighor @tobie https://github.com/tobie help?
— Reply to this email directly or view it on GitHubhttps://github.com/tobie/ua-parser/issues/209#issuecomment-19848447 .
Actually, turns out this does not fix the issue at all. Steps to reproduce:
mkdir foo && cd foo
virtualenv env
. env/bin/activate
pip install -e git+https://github.com/tobie/ua-parser.git@9fa4ae1157ebad928e8b24fb6f717c5a71b59267#egg=ua-parser
And I get:
File "/usr/lib/python2.7/distutils/dist.py", line 972, in run_command
cmd_obj.run()
File "/home/vagrant/foo/env/src/ua-parser/setup.py", line 29, in run
install_regexes()
File "/home/vagrant/foo/env/src/ua-parser/setup.py", line 22, in install_regexes
import yaml
ImportError: No module named yaml
Fails both on python 2.7.3 on ubuntu 12.04 and OSX 10.8.2. Works when I install pyyaml manually and reinstall
Has the option of simply compiling the YAML to JSON as part of sdist
been considered? Seems far simpler (and better for the user, who may not need/want a YAML parser installed)
On Tue, Jul 2, 2013 at 10:47 AM, Oliver Beattie notifications@github.comwrote:
Has the option of simply compiling the YAML to JSON as part of sdist been considered? Seems far simpler (and better for the user, who may not need/want a YAML parser installed)
Yes, most of the implementations have a YAML-> JSON converter. We don't host or compile the JSON into a file in the project because we only want to maintain a readable YAML.
— Reply to this email directly or view it on GitHubhttps://github.com/tobie/ua-parser/issues/209#issuecomment-20362770 .
See https://github.com/tobie/ua-parser/pull/279 for a patch that no longer requires pyyaml for 'setup.py install' or subsequently at runtime.
I'm trying to follow the instructions, I'm doing:
Then I'm python I'm trying to do:
I have a file /usr/local/lib/python2.7/dist-packages/ua_parser-0.3.2-py2.7.egg/data/regexes.yaml but the library appears to be using the wrong path?
What am I missing?