question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

pip build command

See original GitHub issue

Phase 2 from #5407

Allow pip to build packages for distribution - pip build

Some notes in https://github.com/pypa/pip/issues/5407#issuecomment-389621303


pip now has PEP 517 support and uses build isolation by default on packages with pyproject.toml files – which means the way pip builds is difficult to reproduce externally in a trivial manner.

The pip build command would use the same code paths as PEP 517 with the sole difference being that it does not install the packages. It’s essentially the pip wheel in a PEP 517 world.

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:12
  • Comments:20 (17 by maintainers)

github_iconTop GitHub Comments

7reactions
pradyunsgcommented, Sep 3, 2021

I think we should still do this, using pypa/build or our existing code. We already host the logic for this, and I still feel that exposing this to users more directly would be a genuine usability improvement for them.

All frontends that are attempting to encapsulate the user workflow are providing a build command on their CLI as well, for usability reasons.

3reactions
pgansslecommented, Jul 30, 2019

I would like to suggest that this is probably a bad idea at least if the motivation is to create a recommended build tool to replace setup.py sdist bdist_wheel. I think instead we should have a simple dedicated tool for this purpose rather than a pip subcommand.

One reason for this is that build doesn’t obviously fit in either pip or twine - the only reason it makes sense for pip to have a build command is that pip already needs the ability to build packages in order to install them from source, but pip is generally a tool for consumers of packages, not for producers of packages. twine is usually for producers of packages but it has historically only acted upon already existing distributions and so while conceptually it makes sense for twine to be able to do the builds, it would in some sense change the nature of the tool from a tool that uploads things to PyPI into one that builds packages and uploads them to PyPI. To me, the fact that build has a reasonable claim to live in either package makes me think that build is its own thing and should be given its own package.

I’ll note that while it seems like pip “already needs the capability to do builds”, it in fact currently doesn’t need the ability to build source distributions, since it is perfectly capable of building wheels directly from the source. tox both needs and has the ability to build source distributions, but I would not really suggest adding a tox build command to expose this functionality.

Another reason to avoid adding this to pip is that pip already has some unifying themes to its subcommands, including huge reams of command line arguments, some shared and some not. For example, the pip wheel command already exists and is quite valuable for marshalling all the build artifacts one needs to install a given package because it gets you a wheel for the thing you want to install and all its dependencies; this is, however, a terrible and counter-intuitive behavior for a tool for building a wheel for upload - you need to do the magical pip wheel --no-deps -w dist/ . invocation to do what most people actually want to do. If we add a pip build command, we’ll suddenly either have to deprecate the existing and useful pip wheel command or we’ll confuse everyone by having two slightly different commands with very different purposes and semantics.

One box labeled "needles" next to one labeled "poison-tipped needles", the "needles" box is labeled pip build -w, the "poison-tipped needles" box is labeled pip wheel

The one time where I think it would make sense for pip to have a pip build command would be if pip wants to move to a situation where instead of source builds going source → wheel → install, they would go source → sdist → wheel → install (for a consistent flow that produces artifacts at each stage), that would make sense, but even then I wouldn’t want to recommend it as “the way to create distributable artifacts”, but rather as a tool for marshalling resources.

Read more comments on GitHub >

github_iconTop Results From Across the Web

pip documentation v22.3.1
This option specifies default behavior when path already exists. Possible cases: downloading files or checking out repositories for installation, creating ...
Read more >
Packaging Python Projects
pyproject.toml tells “frontend” build tools like pip and build what “backend” tool to use to create distribution packages for your project.
Read more >
Using Python's pip to Manage Your Projects' Dependencies
The pip list command renders a table that shows all installed packages in your current environment. The output above shows the version of...
Read more >
14 Must-Know pip Commands For Data Scientists and ...
Usage:pip <command> [options]Commands: install Install packages. download Download packages. uninstall Uninstall packages. freeze Output ...
Read more >
pip 10.0.0.dev0 documentation
Pip builds packages by invoking the build system. Presently, the only supported build system is setuptools , but future developments to the Python...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found