• <legend id='iV9Mo'><style id='iV9Mo'><dir id='iV9Mo'><q id='iV9Mo'></q></dir></style></legend>

      • <bdo id='iV9Mo'></bdo><ul id='iV9Mo'></ul>
    1. <small id='iV9Mo'></small><noframes id='iV9Mo'>

      <i id='iV9Mo'><tr id='iV9Mo'><dt id='iV9Mo'><q id='iV9Mo'><span id='iV9Mo'><b id='iV9Mo'><form id='iV9Mo'><ins id='iV9Mo'></ins><ul id='iV9Mo'></ul><sub id='iV9Mo'></sub></form><legend id='iV9Mo'></legend><bdo id='iV9Mo'><pre id='iV9Mo'><center id='iV9Mo'></center></pre></bdo></b><th id='iV9Mo'></th></span></q></dt></tr></i><div id='iV9Mo'><tfoot id='iV9Mo'></tfoot><dl id='iV9Mo'><fieldset id='iV9Mo'></fieldset></dl></div>
      1. <tfoot id='iV9Mo'></tfoot>

        相当于 `pip` 的 `package.json' 和 `package-lock.json`

        Equivalent of `package.json#39; and `package-lock.json` for `pip`(相当于 `pip` 的 `package.json 和 `package-lock.json`)
        1. <small id='uDFIC'></small><noframes id='uDFIC'>

        2. <legend id='uDFIC'><style id='uDFIC'><dir id='uDFIC'><q id='uDFIC'></q></dir></style></legend>

                <tbody id='uDFIC'></tbody>

              <i id='uDFIC'><tr id='uDFIC'><dt id='uDFIC'><q id='uDFIC'><span id='uDFIC'><b id='uDFIC'><form id='uDFIC'><ins id='uDFIC'></ins><ul id='uDFIC'></ul><sub id='uDFIC'></sub></form><legend id='uDFIC'></legend><bdo id='uDFIC'><pre id='uDFIC'><center id='uDFIC'></center></pre></bdo></b><th id='uDFIC'></th></span></q></dt></tr></i><div id='uDFIC'><tfoot id='uDFIC'></tfoot><dl id='uDFIC'><fieldset id='uDFIC'></fieldset></dl></div>
              <tfoot id='uDFIC'></tfoot>
                • <bdo id='uDFIC'></bdo><ul id='uDFIC'></ul>

                  本文介绍了相当于 `pip` 的 `package.json' 和 `package-lock.json`的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  JavaScript 的包管理器,例如 npmyarn 使用 package.json 来指定顶级' 依赖项,并创建一个 lock-file 来跟踪 所有作为结果安装的包(即顶级子级依赖项).

                  Package managers for JavaScript like npm and yarn use a package.json to specify 'top-level' dependencies, and create a lock-file to keep track of the specific versions of all packages (i.e. top-level and sub-level dependencies) that are installed as a result.

                  此外,package.json 允许我们区分顶级依赖项的类型,例如 productiondevelopment.

                  In addition, the package.json allows us to make a distinction between types of top-level dependencies, such as production and development.

                  另一方面,对于 Python,我们有 pip.我想 pip 等效于 lock-file 将是 pip freeze > 的结果.requirements.txt.

                  For Python, on the other hand, we have pip. I suppose the pip equivalent of a lock-file would be the result of pip freeze > requirements.txt.

                  但是,如果您只维护这个单个 requirements.txt 文件,则很难区分顶级和子级依赖项(例如,您需要 pipdeptree -r 来解决这些问题).如果您想删除或更改顶级依赖项,这可能会很痛苦,因为很容易留下孤立的包(据我所知,pip 当你pip卸载一个包时不会删除子依赖.

                  However, if you maintain only this single requirements.txt file, it is difficult to distinguish between top-level and sub-level dependencies (you would need for e.g. pipdeptree -r to figure those out). This can be a real pain if you want to remove or change top-level dependencies, as it is easy to be left with orphaned packages (as far as I know, pip does not remove sub-dependencies when you pip uninstall a package).

                  现在,我想知道:是否有一些约定来处理这些不同类型的 requirements 文件并用 区分顶级和子级依赖项点子?

                  Now, I wonder: Is there some convention for dealing with different types of these requirements files and distinguishing between top-level and sub-level dependencies with pip?

                  例如,我可以想象有一个 requirements-prod.txt 仅包含生产环境的顶级需求,作为 package.json<的(简化)等价物/code> 和一个 requirements-prod.lock,其中包含 pip freeze 的输出,并充当我的 lock 文件.此外,我可以有一个 requirements-dev.txt 用于开发依赖项,依此类推.

                  For example, I can imagine having a requirements-prod.txt which contains only the top-level requirements for the production environment, as the (simplified) equivalent of package.json, and a requirements-prod.lock, which contains the output of pip freeze, and acts as my lock-file. In addition I could have a requirements-dev.txt for development dependencies, and so on and so forth.

                  我想知道这是要走的路,还是有更好的方法.

                  I would like to know if this is the way to go, or if there is a better approach.

                  附言condaenvironment.yml 可能会问同样的问题.

                  p.s. The same question could be asked for conda's environment.yml.

                  推荐答案

                  今天至少有三个不错的选择:

                  There are at least three good options available today:

                  1. pipenv 使用 PipfilePipfile.lock 类似于您描述类似 JavaScript 文件的方式.pipenv 是一个更大"的文件.比 pip 更重要的工具,因为它还创建和管理 virtualenvs.

                  1. pipenv uses Pipfile and Pipfile.lock similarly to how you describe the similar JavaScript files. pipenv is a "bigger" tool than pip, in the sense that it also creates and manages virtualenvs.

                  这可能是当今最流行的选项,它几乎肯定会在许多开发人员的工作流程中取代 pip.

                  This is likely the most popular option available today, and it will almost certainly replace pip in many developers' workflows.

                  诗歌使用pyproject.tomlpoetry.lock 文件,也类似于您描述 JavaScript 文件的方式.

                  poetry uses pyproject.toml and poetry.lock files, also similarly to how you describe the JavaScript files.

                  pip-tools 提供 pip-compilepip-sync 命令.在这里,requirements.in 列出了您的直接依赖项,通常带有松散的版本约束,并且 pip-compile 从您的 requirements.txt 生成锁定的文件code>.in 文件.

                  pip-tools provides pip-compile and pip-sync commands. Here, requirements.in lists your direct dependencies, often with loose version constraints and pip-compile generates locked down requirements.txt files from your .in files.

                  我个人喜欢这个工具,因为它向后兼容(生成的 requirements.txt 可以由 pip 处理)和 pip-sync 工具确保 virtualenv 与锁定的版本完全匹配,删除不在你锁定"中的东西.文件.

                  Personally, I like this tool since it's backwards-compatible (the generated requirements.txt can be processed by pip) and the pip-sync tool ensures that the virtualenv exactly matches the locked versions, removing things that aren't in your "lock" file.

                  这篇关于相当于 `pip` 的 `package.json' 和 `package-lock.json`的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  env: python: No such file or directory(env: python: 没有这样的文件或目录)
                  How to evaluate environment variables into a string in Python?(如何在 Python 中将环境变量评估为字符串?)
                  Python - temporarily modify the current process#39;s environment(Python - 临时修改当前进程的环境)
                  Change current process environment#39;s LD_LIBRARY_PATH(更改当前进程环境的 LD_LIBRARY_PATH)
                  Reading and writing environment variables in Python?(在 Python 中读写环境变量?)
                  When to use sys.path.append and when modifying %PYTHONPATH% is enough(何时使用 sys.path.append 以及何时修改 %PYTHONPATH% 就足够了)

                  <tfoot id='gzL6X'></tfoot>

                        <legend id='gzL6X'><style id='gzL6X'><dir id='gzL6X'><q id='gzL6X'></q></dir></style></legend>
                        <i id='gzL6X'><tr id='gzL6X'><dt id='gzL6X'><q id='gzL6X'><span id='gzL6X'><b id='gzL6X'><form id='gzL6X'><ins id='gzL6X'></ins><ul id='gzL6X'></ul><sub id='gzL6X'></sub></form><legend id='gzL6X'></legend><bdo id='gzL6X'><pre id='gzL6X'><center id='gzL6X'></center></pre></bdo></b><th id='gzL6X'></th></span></q></dt></tr></i><div id='gzL6X'><tfoot id='gzL6X'></tfoot><dl id='gzL6X'><fieldset id='gzL6X'></fieldset></dl></div>
                            <tbody id='gzL6X'></tbody>

                          <small id='gzL6X'></small><noframes id='gzL6X'>

                            <bdo id='gzL6X'></bdo><ul id='gzL6X'></ul>