-
Notifications
You must be signed in to change notification settings - Fork 19
Adding pycrypto 2.6. Replacing random module with Crytpo.Random #10
Conversation
|
||
:: | ||
|
||
python hawk/tests/test_*.py |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
Adding pycrypto 2.6. Replacing random module with Crytpo.Random
Nonces now use PyCrypto.
@peterbe @lonnen whatchu think?