NDAR / nda_aws_token_generator

Repository with sample code and libraries for obtaining AWS credentials to use with your NIMH Data Archives account
MIT License
9 stars 11 forks source link

install via pip #3

Open kdaily opened 6 years ago

kdaily commented 6 years ago

Could you provide instructions on how to install the python version of this with pip? I tried (unsuccessfully) in my setup.py:

install_requires=['nda-aws-token-generator'],
dependency_links=['https://github.com/NDAR/nda_aws_token_generator/tarball/master/#egg=nda_aws_token_generator&subdirectory=python'],

Happy to help make this a standalone Python package as well.

devjason commented 6 years ago

Using Python 3.5.1 + pip 9.0.1 I was able to install it directly from github using the pip vcs integration.

Upgrading to latest PIP

For these instructions you'll need the pip version which supports VCS integration python -m pip install --upgrade pip

Installing on Linux/OS X

pip install git+https://github.com/NDAR/nda_aws_token_generator.git#egg=nda-aws-token-generator&subdirectory=python

Installing on MS Windows

Note that if you are on Windows you'll need to escape the ampersand: pip install git+https://github.com/NDAR/nda_aws_token_generator.git#egg=nda-aws-token-generator^&subdirectory=python


Let us know if this doesn't work or if you have other questions. Also, we're always happy to receive pull requests!

kdaily commented 6 years ago

Thanks for the prompt reply!

Sorry, I should have been more clear.

I can install with pip. What I want is to make another Python package that has nda-aws-token-generator as a dependency. Hence, I gave above what I put in my own setup.py for my own package. Here's the relevant output/error after running python setup.py install using my own package:

Searching for nda-aws-token-generator
Reading https://github.com/NDAR/nda_aws_token_generator.git#egg=nda-aws-token-generator&subdirectory=python
Reading https://pypi.python.org/simple/nda-aws-token-generator/
Couldn't find index page for 'nda-aws-token-generator' (maybe misspelled?)
Scanning index of all packages (this may take a while)
Reading https://pypi.python.org/simple/
No local packages or working download links found for nda-aws-token-generator
error: Could not find suitable distribution for Requirement.parse('nda-aws-token-generator')
kdaily commented 6 years ago

I should have said I want to use setuptools to install a package that has nda-aws-token-generator as a dependency, not pip. setuptools supposedly can use the pip-style URLs to github. I was following an example here:

https://python-packaging.readthedocs.io/en/latest/dependencies.html

devjason commented 6 years ago

Sorry for the confusion, I think I understand what you're trying to do.

Can you try something like:

from setuptools import setup

setup(name='console-nda-aws-token-generator',
      version='1.0',
      dependency_links=['https://github.com/NDAR/nda_aws_token_generator.git#egg=nda-aws-token-generator-1.1&subdirectory=python'])

That should make the version explicit in the dependency link.


Update

Sorry, that doesn't work. I'm still seeing if there is a way to specify the dependency or if we need to see about distributing something via PyPi or similar.

kdaily commented 6 years ago

Glad we're on the same page! But that resulted in the same error...I'm wondering if it's ignoring the subdirectory. I tried changing to this:

dependency_links=['https://github.com/NDAR/nda_aws_token_generator/tarball/master#egg=nda-aws-token-generator'],

and get this error:

Searching for nda-aws-token-generator
Downloading https://github.com/NDAR/nda_aws_token_generator/tarball/master#egg=nda-aws-token-generator
Best match: nda-aws-token-generator [unknown version]
Processing master
error: Couldn't find a setup script in /tmp/easy_install-y_H8hu/master
kdaily commented 6 years ago

This confirms it:

https://github.com/kdaily/nda_aws_token_generator/tree/setuptoolsinstall

Refactored to a standalone Python package so there would be no subdirectory involved, and then setting this works:

dependency_links=['https://github.com/kdaily/nda_aws_token_generator/tarball/setuptoolsinstall#egg=nda-aws-token-generator'],
devjason commented 6 years ago

Thanks for confirming the subdirectory was causing the problem, our original intention was to be able to host multiple language client examples in this repo but I think it will be bettter if we split them out for easier packaging system integration (as you've demonstrated!).

I'll talk to some folks tomorrow about how we want to proceed. It would be nice to have this more easily installable as a package requirement, thanks for bringing this up!

kdaily commented 6 years ago

I assumed in my convos with @obenshaindw that was the case, and it gets most people pretty far! I'm unblocked for now to use my fork, but will switch over to a repo maintained on your end if you do decide to so I get any updates or improvements that may come down.

Thanks again!

obenshaindw commented 6 years ago

@devjason and @kdaily I think we can create standalone repos and can keep this one with just client implementation examples that can refer to those. This way we don't break links, and we can organize the projects better.