Skip to content
This repository has been archived by the owner on Feb 7, 2024. It is now read-only.

Adding pycrypto 2.6. Replacing random module with Crytpo.Random #10

Merged
merged 2 commits into from
Jul 29, 2013

Conversation

ozten
Copy link
Contributor

@ozten ozten commented Jul 25, 2013

Nonces now use PyCrypto.

@peterbe @lonnen whatchu think?


::

python hawk/tests/test_*.py
Copy link
Contributor

Choose a reason for hiding this comment

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

This can be replaced with just

nosetests hawk

since it crawls the directory and finds all tests.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmmm, I'm not sure why this blows up. (Also submitted this comment already, but didn't show up, sorry for dup)

(pyhawk)ozten@nutria:~/pyhawk$ nosetests hawk/
E
======================================================================
ERROR: Failure: DistributionNotFound (pyhawk)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/lib/pymodules/python2.7/nose/loader.py", line 390, in loadTestsFromName
    addr.filename, addr.module)
  File "/usr/lib/pymodules/python2.7/nose/importer.py", line 39, in importFromPath
    return self.importFromDir(dir_path, fqname)
  File "/usr/lib/pymodules/python2.7/nose/importer.py", line 86, in importFromDir
    mod = load_module(part_fqname, fh, filename, desc)
  File "/home/ozten/pyhawk/hawk/__init__.py", line 15, in <module>
    __version__ = pkg_resources.get_distribution(__title__).version
  File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 298, in get_distribution
    if isinstance(dist,Requirement): dist = get_provider(dist)
  File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 177, in get_provider
    return working_set.find(moduleOrReq) or require(str(moduleOrReq))[0]
  File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 654, in require
    needed = self.resolve(parse_requirements(requirements))
  File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 552, in resolve
    raise DistributionNotFound(req)
DistributionNotFound: pyhawk

----------------------------------------------------------------------
Ran 1 test in 0.001s

FAILED (errors=1)

Copy link
Contributor

Choose a reason for hiding this comment

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

uh?!
Try:

nosetests  # no arguments; inside ./pyhawk

What about running a specific test like:

nosetests hawk/tests/test_foo.py

Copy link
Contributor

Choose a reason for hiding this comment

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

Actually, this looks suspect:
https://github.com/mozilla/PyHawk/blob/master/hawk/__init__.py#L15

Within the package you depend on it being packaged. So, if someone unpacks your pyhawk package and installs it manually with cp -r hawk /my/pythons/site-packages then this line will stop working.

Basically, the __init__.py file does too much. I would recommend you just write it like this:

__version__ = '0.1.0'

And then, in setup.py you add the following:

import re
import codecs

def read(*parts):
    return codecs.open(os.path.join(os.path.dirname(__file__), *parts)).read()

def find_version(*file_paths):
    version_file = read(*file_paths)
    version_match = re.search(r"^__version__ = ['\"]([^'\"]*)['\"]",
                              version_file, re.M)
    if version_match:
        return version_match.group(1)
    raise RuntimeError("Unable to find version string.")

...
setup(
    name="PyHawk",
    version=find_version('hawk/__init__.py'),
    url='https://github.com/mozilla/PyHawk',
...

See https://github.com/peterbe/mincss/blob/master/setup.py

Note there how I also these lines which prevent a nasty setuptools bug that's going around at the moment.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm, I think we had a setup like that in this repo already.

Copy link
Contributor

Choose a reason for hiding this comment

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

Wow! I'm surprised. @ametaireau knows what he's doing. Perhaps he can help explain the error you get from nosetests and perhaps he can also explain what to with the package if it's extracted outside a package.

@ozten ozten mentioned this pull request Jul 25, 2013
ozten added a commit that referenced this pull request Jul 29, 2013
Adding pycrypto 2.6. Replacing random module with Crytpo.Random
@ozten ozten merged commit 43d6237 into master Jul 29, 2013
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants