Closed ofek closed 7 years ago
@ofek It would have been really nice if you could have perhaps mentioned some of your concerns in this issue, instead of literally opening an issue that says, "throw your project away", and referencing a PR against another project where you make a bunch of factually incorrect statements about this one.
The purpose that I had for writing this project was to generate detailed graphs like these and SVG badges; I don't see how directing users to a CLI will remedy that.
The README is very clear that this project is a quick solution, and why it was written.
As I clearly stated in the README, when either PyPI or someone else provides download count badges, I'll happily mark this as deprecated. But as far as I know there's nothing else that serves that need right now.
And lastly, what you show above in your code snippet seems to be an argument parsing bug, not a failure to run.
Despite what you said on the awesome-python PR, fresh installs work fine:
jantman@phoenix:pts/8:~/tmp/foo$ virtualenv --python=python3.6 .
Running virtualenv with interpreter /usr/bin/python3.6
Using base prefix '/usr'
New python executable in /tmp/jantman/foo/bin/python3.6
Also creating executable in /tmp/jantman/foo/bin/python
Installing setuptools, pip, wheel...done.
jantman@phoenix:pts/8:~/tmp/foo$ source bin/activate
(foo)jantman@phoenix:pts/8:~/tmp/foo$ pip install pypi-download-stats
Collecting pypi-download-stats
Using cached pypi_download_stats-0.2.1-py2.py3-none-any.whl
Collecting iso3166 (from pypi-download-stats)
Using cached iso3166-0.8-py2.py3-none-any.whl
Collecting bokeh==0.12.1 (from pypi-download-stats)
Using cached bokeh-0.12.1.tar.gz
Collecting google-api-python-client>=1.5.0 (from pypi-download-stats)
Using cached google_api_python_client-1.6.2-py2.py3-none-any.whl
Collecting pytz (from pypi-download-stats)
Using cached pytz-2017.2-py2.py3-none-any.whl
Collecting pandas<1.0,>=0.18 (from pypi-download-stats)
Downloading pandas-0.20.3-cp36-cp36m-manylinux1_x86_64.whl (24.5MB)
100% |████████████████████████████████| 24.5MB 68kB/s
Collecting oauth2client>=3.0.0 (from pypi-download-stats)
Using cached oauth2client-4.1.2-py2.py3-none-any.whl
Collecting tzlocal (from pypi-download-stats)
Using cached tzlocal-1.4.tar.gz
Collecting requests<3.0,>2.0 (from pypi-download-stats)
Using cached requests-2.18.4-py2.py3-none-any.whl
Collecting six>=1.5.2 (from bokeh==0.12.1->pypi-download-stats)
Using cached six-1.10.0-py2.py3-none-any.whl
Collecting PyYAML>=3.10 (from bokeh==0.12.1->pypi-download-stats)
Using cached PyYAML-3.12.tar.gz
Collecting python-dateutil>=2.1 (from bokeh==0.12.1->pypi-download-stats)
Using cached python_dateutil-2.6.1-py2.py3-none-any.whl
Collecting Jinja2>=2.7 (from bokeh==0.12.1->pypi-download-stats)
Using cached Jinja2-2.9.6-py2.py3-none-any.whl
Collecting numpy>=1.7.1 (from bokeh==0.12.1->pypi-download-stats)
Downloading numpy-1.13.1-cp36-cp36m-manylinux1_x86_64.whl (17.0MB)
100% |████████████████████████████████| 17.0MB 90kB/s
Collecting tornado>=4.3 (from bokeh==0.12.1->pypi-download-stats)
Using cached tornado-4.5.1.tar.gz
Collecting uritemplate<4dev,>=3.0.0 (from google-api-python-client>=1.5.0->pypi-download-stats)
Using cached uritemplate-3.0.0-py2.py3-none-any.whl
Collecting httplib2<1dev,>=0.9.2 (from google-api-python-client>=1.5.0->pypi-download-stats)
Using cached httplib2-0.10.3.tar.gz
Collecting pyasn1-modules>=0.0.5 (from oauth2client>=3.0.0->pypi-download-stats)
Using cached pyasn1_modules-0.0.11-py2.py3-none-any.whl
Collecting rsa>=3.1.4 (from oauth2client>=3.0.0->pypi-download-stats)
Using cached rsa-3.4.2-py2.py3-none-any.whl
Collecting pyasn1>=0.1.7 (from oauth2client>=3.0.0->pypi-download-stats)
Using cached pyasn1-0.3.2-py2.py3-none-any.whl
Collecting chardet<3.1.0,>=3.0.2 (from requests<3.0,>2.0->pypi-download-stats)
Using cached chardet-3.0.4-py2.py3-none-any.whl
Collecting certifi>=2017.4.17 (from requests<3.0,>2.0->pypi-download-stats)
Using cached certifi-2017.7.27.1-py2.py3-none-any.whl
Collecting idna<2.7,>=2.5 (from requests<3.0,>2.0->pypi-download-stats)
Using cached idna-2.6-py2.py3-none-any.whl
Collecting urllib3<1.23,>=1.21.1 (from requests<3.0,>2.0->pypi-download-stats)
Using cached urllib3-1.22-py2.py3-none-any.whl
Collecting MarkupSafe>=0.23 (from Jinja2>=2.7->bokeh==0.12.1->pypi-download-stats)
Building wheels for collected packages: bokeh, tzlocal, PyYAML, tornado, httplib2
Running setup.py bdist_wheel for bokeh ... done
Stored in directory: /home/jantman/.cache/pip/wheels/43/81/31/65c9854222564898592b00d984fd49c60fa8de2751236622f0
Running setup.py bdist_wheel for tzlocal ... done
Stored in directory: /home/jantman/.cache/pip/wheels/dc/d6/f0/84194ccbdd3e2551bdb207e1fc1925efd32956c5767328103b
Running setup.py bdist_wheel for PyYAML ... done
Stored in directory: /home/jantman/.cache/pip/wheels/2c/f7/79/13f3a12cd723892437c0cfbde1230ab4d82947ff7b3839a4fc
Running setup.py bdist_wheel for tornado ... done
Stored in directory: /home/jantman/.cache/pip/wheels/84/83/cd/6a04602633457269d161344755e6766d24307189b7a67ff4b7
Running setup.py bdist_wheel for httplib2 ... done
Stored in directory: /home/jantman/.cache/pip/wheels/ca/ac/5f/749651f7925b231103f5316cacca82a487810c22d30f011c0c
Successfully built bokeh tzlocal PyYAML tornado httplib2
Installing collected packages: iso3166, six, chardet, certifi, idna, urllib3, requests, PyYAML, python-dateutil, MarkupSafe, Jinja2, numpy, tornado, bokeh, uritemplate, httplib2, pyasn1, pyasn1-modules, rsa, oauth2client, google-api-python-client, pytz, pandas, tzlocal, pypi-download-stats
Successfully installed Jinja2-2.9.6 MarkupSafe-1.0 PyYAML-3.12 bokeh-0.12.1 certifi-2017.7.27.1 chardet-3.0.4 google-api-python-client-1.6.2 httplib2-0.10.3 idna-2.6 iso3166-0.8 numpy-1.13.1 oauth2client-4.1.2 pandas-0.20.3 pyasn1-0.3.2 pyasn1-modules-0.0.11 pypi-download-stats-0.2.1 python-dateutil-2.6.1 pytz-2017.2 requests-2.18.4 rsa-3.4.2 six-1.10.0 tornado-4.5.1 tzlocal-1.4 uritemplate-3.0.0 urllib3-1.22
(foo)jantman@phoenix:pts/8:~/tmp/foo$ export GOOGLE_APPLICATION_CREDENTIALS=/home/jantman/pypi-bigquery.json
(foo)jantman@phoenix:pts/8:~/tmp/foo$ bin/pypi-download-stats -h
usage: pypi-download-stats [-h] [-V] [-v] [-Q | -G] [-o OUT_DIR]
[-p PROJECT_ID] [-c CACHE_DIR] [-B BACKFILL_DAYS]
[-P PROJECT | -U USER]
pypi-download-stats - Calculate detailed download stats and generate HTML and
badges for PyPI packages - <https://github.com/jantman/pypi-download-stats>
optional arguments:
-h, --help show this help message and exit
-V, --version show program's version number and exit
-v, --verbose verbose output. specify twice for debug-level output.
-Q, --no-query do not query; just generate output from cached data
-G, --no-generate do not generate output; just query data and cache
results
-o OUT_DIR, --out-dir OUT_DIR
output directory (default: ./pypi-stats
-p PROJECT_ID, --project-id PROJECT_ID
ProjectID for your Google Cloud user, if not using
service account credentials JSON file
-c CACHE_DIR, --cache-dir CACHE_DIR
stats cache directory (default: ./pypi-stats-cache)
-B BACKFILL_DAYS, --backfill-num-days BACKFILL_DAYS
number of days of historical data to backfill, if
missing (defaut: 7). Note this may incur BigQuery
charges. Set to -1 to backfill all available history.
-P PROJECT, --project PROJECT
project name to query/generate stats for (can be
specified more than once; this will reduce query cost
for multiple projects)
-U USER, --user USER Run for all PyPI projects owned by the specifieduser.
(foo)jantman@phoenix:pts/8:~/tmp/foo$ bin/pypi-download-stats -B 1 -P awslimitchecker
[2017-08-24 20:13:43,870 WARNING] file_cache is unavailable when using oauth2client >= 4.0.0
Traceback (most recent call last):
File "/tmp/jantman/foo/lib/python3.6/site-packages/googleapiclient/discovery_cache/__init__.py", line 36, in autodetect
from google.appengine.api import memcache
ModuleNotFoundError: No module named 'google'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/tmp/jantman/foo/lib/python3.6/site-packages/googleapiclient/discovery_cache/file_cache.py", line 33, in <module>
from oauth2client.contrib.locked_file import LockedFile
ModuleNotFoundError: No module named 'oauth2client.contrib.locked_file'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/tmp/jantman/foo/lib/python3.6/site-packages/googleapiclient/discovery_cache/file_cache.py", line 37, in <module>
from oauth2client.locked_file import LockedFile
ModuleNotFoundError: No module named 'oauth2client.locked_file'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/tmp/jantman/foo/lib/python3.6/site-packages/googleapiclient/discovery_cache/__init__.py", line 41, in autodetect
from . import file_cache
File "/tmp/jantman/foo/lib/python3.6/site-packages/googleapiclient/discovery_cache/file_cache.py", line 41, in <module>
'file_cache is unavailable when using oauth2client >= 4.0.0')
ImportError: file_cache is unavailable when using oauth2client >= 4.0.0
/tmp/jantman/foo/lib/python3.6/site-packages/bokeh/core/json_encoder.py:33: FutureWarning: pandas.tslib is deprecated and will be removed in a future version.
You can access Timestamp as pandas.Timestamp
if pd and isinstance(obj, pd.tslib.Timestamp):
[2017-08-24 20:14:19,304 ERROR] Only have 1 days of data; cannot calculate downloads per week
(foo)jantman@phoenix:pts/8:~/tmp/foo$ ls
bin include lib pip-selfcheck.json pypi-stats pypi-stats-cache
(foo)jantman@phoenix:pts/8:~/tmp/foo$ ls pypi-stats
awslimitchecker
(foo)jantman@phoenix:pts/8:~/tmp/foo$ ls pypi-stats/awslimitchecker/
index.html per-day.svg
@jantman I do apologize. I wrote that quickly before lunch and should have more carefully considered my wording. I'm sorry.
Have those tracebacks you posted just started recently then? For me on Windows and a fresh Ubuntu 16.04.2 the command you posted hangs and I have to close process. Same tracebacks.
Scratch that, only Windows hangs.
I've never tried running this on Windows before and don't have access to a Windows machine, so I apologize but I can't be of much help there. It's entirely possible this (and/or one of its dependencies) hasn't been run on Windows.
No, those tracebacks have unfortunately always been there. I know this is no longer the case, but when I started this project the libraries I'm using were the official Google ones, but had been unmaintained for quite some time. It appears that this has changed since then, but I'm still hoping that the PyPI folks will roll out some stats of their own and I can stop using this.
FYI, you may want to run in high verbosity (-vv
); queries for one project can take minutes to run, and if you've never had a successful run it will by default backfill 7 days of data.
Dang, that high verbosity is no joke! Nice logging there. I'll poke around a bit more to see why this might be happening.
:) yeah, but it really comes in handy when debugging problems backfilling data (I backfilled all available data for my projects, which was about 18 months IIRC).
Ok, cool. I'm happy to merge any fixes you come up with and always happy to accept PRs, but I don't think I'm putting much more development effort into this myself. My goal was just report/graph/badge generation until an "official" solution comes around, and it's doing that.
@ofek I've fixed the heart of this issue in https://github.com/jantman/pypi-download-stats/commit/870b83a6542f15a290789bab9d19c059599df22a
If it's ok, I'm going to close this just for clarity, but if you find anything more on that hanging problem, please open a new issue for it.
Thanks, Jason
@jantman In reference to vinta/awesome-python#918, perhaps consider directing users to https://github.com/ofek/pypinfo if badge creation isn't desired.