-
Notifications
You must be signed in to change notification settings - Fork 182
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
Load prototypes from JSON #30
base: master
Are you sure you want to change the base?
Conversation
Python only really installs packages. This moves prototypes.json into a hashid_data directory. And the directory needs a __init_.py to actually be a package.
This first commit is just moving stuff around so that setup.py/pip can install the data. Python only really installs packages. This moves prototypes.json into a hashid_data directory. And the directory needs a _init.py to actually be a package. (Python packaging drives me insane.) I would actually rather make a I'll actually start work on loading the prototypes JSON in hashID now. |
Please test this on all platforms and installation methods you support. I tested it on Python 2.7.8 running from the repo directory and as a local installation. Package it however you usually do and maybe even upload it to testpypi. And test it on Python 3 please. I just discovered pkgutil.get_data() which made this less much less terrible than I expected. Apparently it's in the standard library and lets me just ask for the contents of a file placed relatively to a module. |
I tested this on Python 3 and
json accepts bytestrings in Python 2. In Python 3, the input must be Unicode string. I think we should reorganize and make a hashid package (as you suggested in your comment) and lay out our files somewhat like this:
The only thing I can't get to work is to install the prototypes.json file using setup.py. Neither |
Hmm. I think I just have to decode the Unicode encoding first. I will reintroduce
Looks good. We may actually want hashid.py to become the
And you listed the file in Manifest.in? Not sure what it would be then. |
You are right, I didn't think of this, thanks for the heads up! I think I found my mistake with the packaging, will try again after we restructured the files. |
First try at moving everything into a However a few errors are shown when I do a
...Except everything seems to work fine and it actually installs correctly. Running the command line I tried my best to fix up |
This error happens because of But when I run
Python 3.4.2:
|
😧 OK, I'll look at it some more. Both of your errors seem to be because it can't load the package data file for some reason. Does it work fine when use the version installed into your PATH via pip? Also, I still haven't fixed the byte string stuff for python3 yet. So it isn't expected to work yet. |
Yes it does work fine when I install it via pip. I also haven't figured out yet why it doesn't load the package data. 😞 |
Ok. Good. Also swear I tested it from the command line like that too. It may matter what directory you run it from? Considering pip/setup.py is now the reccomended installation method, this doesn't matter too much, right? It just makes testing and development a problem. (Though you can already just use |
@@ -39,14 +39,15 @@ def get_version(*file_paths): | |||
setup( | |||
name='hashID', | |||
packages=find_packages(exclude=['HASHINFO.xlsx']), |
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.
I made a mistake here excluding HASHINFO.xlsx
, this is not needed at all - the line should be just
packages=find_packages(),
Don't merge this yet. Let's leave this pull request open so we can have a discussion on the changes.
Load prototype definitions from JSON as discussed in #29.