Edit: Unfortunately it's easy to confuse the above tutorial with this one[2], which is specifically for setuptools. So I can appreciate end user confusion around the documentation, particularly in that respect!
[1]: https://packaging.python.org/en/latest/tutorials/packaging-p...
[2]: https://packaging.python.org/en/latest/guides/distributing-p...
To be honest that entire pypa doc should be like two paragraphs long instead of 1000+ words. It should be basically, "ok to package your python app just run <official python tool to init a package>, that's it you're done!". Every decision should be made for me, like it is with npm, cargo, etc. I shouldn't have to think beyond running one command.
That's what python end users need. We don't need a million tools and huge docs with seemingly no vision or goal. We need to get shit done and the less time we faff about with packaging and tooling the better.
The whole 'let the community figure it out' seems to have failed and is causing nothing but more confusion and now attacks on people. They need to step up and say, "this is how python packaging will work, period. End of story, end of debate.". That was the one good thing a BDFL model for leadership could achieve, making a hard decision.
I worked at one company that used buildout back then, which seemed relatively rare, but buildout was more flexible and allowed you to do things like installing system packages or running your own scripts. We used it to pull down config files that weren't checked into the repo but still wanted to be shared, helping setup the local developer environment, and a few other things.
A definitive statement from Python.org as to The Way would go so far.
In the context of `pip-audit`, that makes a little less sense: most of our dependencies are semantically versioned, and we'd rather users receive patches and fixes to our subdependencies automatically, rather than having to wait for us to release a corresponding fix version. Similarly, we expect users to install `pip-audit` into pre-existing virtual environments, meaning that excessive pinning will produce overly conservative dependency conflict errors.
[1]: https://github.com/sigstore/sigstore-python/tree/main/instal...
In other words, it's generally a superset of the resolutions collected by `pip-compile`. This may or may not be what you want, or what your users expect!
(The point about other development tooling is, I believe, still accurate -- if you e.g. have `black` installed, `pip freeze` will show it.)
If you go to Python.org and follow through to the beginners guide [0] this is what's suggested:
> There are several methods to install additional Python packages:
> Packages can be installed via the standard Python distutils mode (python setup.py install).
> Many packages can also be installed via the setuptools extension or pip wrapper, see https://pip.pypa.io/.
That is so out of date and fundamentally confuses people coming to Python for the first time. How is pip secondary, and no mention of venv?
The PyPA need to get buy in from Python Core to put one tool front and centre first. It needs to be like Rust with Cargo, literally the first thing you learn to use and core to all beginners guides.
That's not to diminish the work of PyPA, you are all amazing I just want your work to be more obvious!
0: https://docs.python.org/3/using/mac.html#installing-addition...
https://packaging.python.org/en/latest/tutorials/installing-...
https://packaging.python.org/en/latest/tutorials/packaging-p...
install .[dev]
format/syntax defined ? I was trying to find what was possible and how to make sense of it in setup.cfg toolsI found one mention in the docs but no more.
pip install jupyter[notebook]
this is the same thing, just for . (current directory) and dev variant.> Optional components of a distribution may be specified using the extras field:
identifier_end = letterOrDigit | (('-' | '_' | '.' )* letterOrDigit)
identifier = letterOrDigit identifier_end*
name = identifier
extras_list = identifier (wsp* ',' wsp* identifier)*
extras = '[' wsp* extras_list? wsp* ']'
as well as explaining their behavior, albeit briefly:> Extras union in the dependencies they define with the dependencies of the distribution they are attached to.
The resolution on . is explained by the pip documentation[1]:
> pip looks for packages in a number of places: on PyPI (if not disabled via --no-index), in the local filesystem, and in any additional repositories specified via --find-links or --index-url. There is no ordering in the locations that are searched. Rather they are all checked, and the “best” match for the requirements (in terms of version number - see PEP 440 for details) is selected.
[0]: https://peps.python.org/pep-0508/#grammar
[1]: https://pip.pypa.io/en/stable/cli/pip_install/#finding-packa...
[1]: https://www.pypa.io/ [2]: https://pypi.org/static/images/logo-large.svg/
requires = ["flit_core >=3.2,<4"]
build-backend = "flit_core.buildapi"
Python.org defaults to using hatchling in the docs[1].PyPA has a sample repository using setuptools[2]. This project is linked from Python.org on this page.[3]
Python.org recommends using setuptools under packaging recommendations as well, with no mention of hatchling or flit even on that page.[4]
No wonder so many devs are frustrated about this. I've been writing mostly Python for work and fun the past 11 years and I'm f*cking confused what tools to use. When I start a new side project I don't know whether a tool is going to exist and still work in a few years, because there's 10 tools trying to do the same things and it's not clear what the community is actually getting behind.
[1]: https://packaging.python.org/en/latest/tutorials/packaging-p...
[2]: https://github.com/pypa/sampleproject/blob/main/pyproject.to...
[3]: https://packaging.python.org/en/latest/guides/distributing-p...
[4]: https://packaging.python.org/en/latest/guides/tool-recommend...
Here's a PyPA project (FD: one I work on) that uses a single pyproject.toml to handle all aspects of packaging (and most non-packaging tool configuration, to boot)[1]. With a single file like that, the only thing you need to do to start a local development environment is:
(We provide a `make dev` target that does that for you as well.)Similarly, to build distributions, all you need is `build`:
[1]: https://github.com/pypa/pip-audit