Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Update setup.py to enable pip installs direct from github #12

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

Merged
merged 1 commit into from
Oct 1, 2015
Merged

Update setup.py to enable pip installs direct from github #12

merged 1 commit into from
Oct 1, 2015

Conversation

crbunney
Copy link

Edit: Did a bit more work on this and rewrote the pull request description to be clearer

I've found that you can't install the uap-python library direct from github using pip or as a dependency for a project installed using setuptools.

There are 2 possible URLs that you can point pip/setup.py at:

  • Git repo: git+https://github.com/ua-parser/uap-python.git@master#egg=ua-parser-0.4.0
  • Tarball: https://github.com/ua-parser/uap-python/tarball/master#egg=ua-parser-0.4.0

There appears to be 2 issues:

  • The tarball download doesn't include the uap-core submodule, so doesn't include the regexes.yaml
  • The setup.py install command doesn't install the regexes.yaml and regexes.json files (unlike the develop and sdist commands)

I can't find a workaround/solution for the tarball download not including the submodule, it seems to be a limitation of the feature that github provides.

For the installation of the regexes files, I updated the setup.py (hence this pull request)

Test Methodology

  • I ran all the tests within a virtualenv using pip 1.5.6 (although I'm confident it works fine with later versions as well).
  • Between each test case I ran wipeenv from virtualenvwrapper to remove all installed python modules.
  • To check whether the test passed, I ran python -c 'import ua_parser.user_agent_parser', which produces a traceback if the regexes aren't installed correctly.
  • For the tests that installed uap-python as a dependency declared in a setup.py, I created a simple project with the following setup.py:
from setuptools import setup

setup(
    name='ua-test',
    version='0.1',
    packages=['ua-test'],
    url='',
    license='',
    author='Chris Bunney',
    author_email='[email protected]',
    description='',
    install_requires=[
        'ua-parser==0.4.0'
    ],
    dependency_links=[
        'INSERT_TEST_URL_HERE'
    ]
)

These are the tests cases I tried:

  • pip installs:
    • Direct pip install using git URL: pip install <git_url>
    • Direct pip install in editable mode using git URL: pip install -e <git_url>
    • Direct pip install using tarball URL: pip install <tarball_url>
    • Direct pip install in editable mode using tarball URL: pip install -e <tarball_url>
  • setup.py installs (executed from test project root)
    • setup.py install using git URL: pip install --process-dependency-links . # (dependency_links=['<git_url>'])
    • setup.py install in editable mode using git URL: pip install --process-dependency-links -e . # (dependency_links=['<git_url>'])
    • setup.py install using tarball URL: pip install --process-dependency-links . # (dependency_links=['<tarball_url>'])
    • setup.py install in editable mode using tarball URL: pip install --process-dependency-links -e . # (dependency_links=['<tarball_url>'])

Test Results Using ua-parser/uap-python/master
git URL: git+https://github.com/ua-parser/uap-python.git@master#egg=ua-parser-0.4.0
tarball URL: https://github.com/ua-parser/uap-python/tarball/master#egg=ua-parser-0.4.0

Test Case Result
Direct pip install using git URL FAILED
Direct pip install in editable mode using git URL FAILED
Direct pip install using tarball URL FAILED
Direct pip install in editable mode using tarball URL INVALID COMMAND (included for completeness)
setup.py install using git URL FAILED
setup.py install in editable mode using git URL FAILED
setup.py install using tarball URL FAILED
setup.py install in editable mode using tarball URL FAILED

Test Results Using crbunney/uap-python/fix_pip_install_from_source
git URL: git+https://github.com/crbunney/uap-python.git@fix_pip_install_from_source#egg=ua-parser-0.4.0
tarball URL: https://github.com/crbunney/uap-python/tarball/fix_pip_install_from_source#egg=ua-parser-0.4.0

Test Case Result
Direct pip install using git URL PASSED
Direct pip install in editable mode using git URL PASSED
Direct pip install using tarball URL FAILED (due to the tarball download not included the uap-core submodule)
Direct pip install in editable mode using tarball URL INVALID COMMAND (included for completeness)
setup.py install using git URL PASSED
setup.py install in editable mode using git URL PASSED
setup.py install using tarball URL FAILED (due to the tarball download not included the uap-core submodule)
setup.py install in editable mode using tarball URL FAILED (due to the tarball download not included the uap-core submodule)

@@ -50,10 +57,12 @@ def run(self):
url='https://github.com/ua-parser/uap-python',
include_package_data=True,
package_data={'ua_parser': ['regexes.yaml', 'regexes.json']},
setup_requires=['pyyaml'],
install_requires=['pyyaml'],
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changing this line from install_requires=['pyyaml'] to tests_require=['pyyaml'] would let users choose not to install pyyaml if they only want to use the parser, since user_agent_parser.py doesn't use pyyaml, but it would still be installed if python setup.py test was run.

The only other pyyaml usage was in the setup.py itself, and I had to add setup_requires to ensure it was available to the setup.py script.

@crbunney crbunney changed the title Run install_regexes() for install command as well as sdist and develop Update setup.py to enable pip installs direct from github Aug 12, 2015
@elsigh
Copy link
Contributor

elsigh commented Sep 21, 2015

I honestly am happy to merge this though I don't really understand the ramifications of it. I also don't personally use the python version in prod. Can anyone else say anything about this idea? I like the notion of being able to install from github in principle. @selwin ?

@elsigh
Copy link
Contributor

elsigh commented Oct 1, 2015

Ok, well, in the interest of moving fast and supporting anyone who writes a PR I'm going to merge this. If there are issues, will you please take the lead on fixing them? =() thanks.

elsigh added a commit that referenced this pull request Oct 1, 2015
Update setup.py to enable pip installs direct from github
@elsigh elsigh merged commit 112eefc into ua-parser:master Oct 1, 2015
selwin pushed a commit to selwin/uap-python that referenced this pull request Oct 14, 2015
@crbunney crbunney deleted the fix_pip_install_from_source branch October 15, 2015 16:33
@crbunney
Copy link
Author

I'll keep an eye on it, of course :)

@crbunney crbunney restored the fix_pip_install_from_source branch October 15, 2015 17:23
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

Successfully merging this pull request may close these issues.

2 participants