javascript dependencies in python project

前端 未结 3 828
一个人的身影
一个人的身影 2021-02-19 00:12

I\'m writing software that allows one to publish mathematical books as websites. It is based mostly on Python + Flask, but to deal with equations I\'m using MathJax. MathJax can

3条回答
  •  滥情空心
    2021-02-19 01:05

    My question is: what is the best practice of dealing with such heterogenous dependencies in Python?

    In the case of Node dependencies, I would include a package.json file in the directory which specifies the Node dependencies needed. For other languages/package managers, I would also use whatever the conventional way of specifying dependencies is (e.g. add a Gemfile for Ruby dependencies).

    Another common example of this that comes up with Python/Flask is using the Bower package manager for static frontend dependencies. In that case, the dependencies are specified in the bower.json file and are usually pulled into a bower folder in Flask's static directory.

    I can just put all the javascript sources I need into my distribution itself, but maybe there's a better way to do it?

    Once you've got the package.json with the dependencies specified, you can fetch and install all the Node dependencies needed by running npm install which, in my opinion, is a more elegant solution than including the javascript sources with the project.

    Now that you've got multiple package managers (e.g. maybe you're using pip for the Python dependencies in addition to npm for the Node dependencies), you might want to make a Makefile or some deployment/build script to fetch/install using all of them (for example, if I were using Travis CI, I would update my .travis.yml to call npm install in addition to pip install -r).

提交回复
热议问题