2

We have big project which works with *.json files in the directory: project/data/{locale}/*.json.

And we need to minify the contents of json files. We already created script which minify all json files in directory, but what we actually need is minimizing json files only in package which will publish, i.e dist/package.v0.1.1.tar.gz.

Does distutils provides some API for doing this? Can we minify json data only in production version of our library, which will hosted on PyPi.org?

Maybe something like this:

# setup.py
from distutils import before_publish

@before_publish
def minify_json():
   # logic here
Lo L
  • 243
  • 2
  • 10
  • Been a long time, but I think you can override `install` using the `cmdclass` property. – Grimmy Jul 17 '17 at 08:09
  • I will try this. Thanks. – Lo L Jul 17 '17 at 08:24
  • I guess the trick is to find the correct command to override. I'm not sure if there is any specific command that runs for `bdist_wheel` only that could minifly all json files in the `build` folder so the `.whl` file will contain the compressed files. Docs can be very confusing. – Grimmy Jul 17 '17 at 08:33
  • https://stackoverflow.com/a/25761434/1754709 could be a starting point – Grimmy Jul 17 '17 at 08:37
  • As far as I can tell it's looks suitable for me. Thank you! – Lo L Jul 17 '17 at 09:20

0 Answers0