Questions tagged [pyproject.toml]

Questions pertaining to the python package configuration system based on a pyproject.toml file, as discussed in PEP517 and PEP518, among others.

Questions pertaining to the python package configuration system based on a pyproject.toml file, as discussed in PEP517 and PEP518, among others.

268 questions
323
votes
5 answers

What is pyproject.toml file for?

Background I was about to try Python package downloaded from GitHub, and realized that it did not have a setup.py, so I could not install it with pip install -e Instead, the package had a pyproject.toml file which seems to have very…
Niko Föhr
  • 28,336
  • 10
  • 93
  • 96
86
votes
5 answers

How to install a package using pip in editable mode with pyproject.toml?

When a project is specified only via pyproject.toml (i.e. no setup.{py,cfg} files), how can it be installed in editable mode via pip (i.e. python -m pip install -e .)? I tried both setuptools and poetry for the build system, but neither…
a_guest
  • 34,165
  • 12
  • 64
  • 118
65
votes
1 answer

How to write a minimally working pyproject.toml file that can install packages?

Pip supports the pyproject.toml file but so far all practical usage of the new schema requires a 3rd party tool that auto-generates these files (e.g., poetry and pip). Unlike setup.py which is already human-writeable, pyproject.toml is not…
Keto
  • 1,470
  • 1
  • 12
  • 25
54
votes
4 answers

How to specify version in only one place when using pyproject.toml?

My package version is defined in two places: __version__ = 1.2.3 in mypackage/__init__.py version = "1.2.3" in pyproject.toml (I am using Poetry) I have to update both whenever I bump the version which is annoying and not DRY. Is there a way to…
Haterind
  • 1,095
  • 1
  • 8
  • 16
43
votes
2 answers

How to reference a requirements.txt in the pyproject.toml of a setuptools project?

I'm trying to migrate a setuptools-based project from the legacy setup.py towards modern pyproject.toml configuration. At the same time I want to keep well established workflows based on pip-compile, i.e., a requirements.in that gets compiled to a…
bluenote10
  • 23,414
  • 14
  • 122
  • 178
43
votes
3 answers

Download dependencies declared in pyproject.toml using Pip

I have a Python project that doesn't contain requirements.txt. But it has a pyproject.toml file. How can I download packages (dependencies) required by this Python project and declared in pyproject.toml using the Pip package manager (instead of the…
Sherein
  • 947
  • 1
  • 11
  • 23
34
votes
2 answers

Specifying command line scripts in pyproject.toml

I'm trying to add a pyproject.toml to a project that's been using setup.py in order to enable support by pipx. I'd like to specify the command line scripts the project includes in pyproject.toml, but all the guides I can find give instructions for…
polm23
  • 14,456
  • 7
  • 35
  • 59
31
votes
3 answers

How to build a source distribution without using setup.py file?

With the following package structure . ├── my_package │ └── __init__.py ├── setup.cfg └── setup.py Contents of setup.py from setuptools import setup setup() Contents of setup.cfg [metadata] name = my_package version = 0.1 [options] packages =…
platypus
  • 1,128
  • 8
  • 15
24
votes
5 answers

Is requirements.txt still needed when using pyproject.toml?

Since mid 2022 it is now possible to get rid of setup.py, setup.cfg in favor of pyproject.toml. Editable installs work with recent versions of setuptools and pip and even the official packaging tutorial switched away from setup.py to…
Bastian Venthur
  • 12,515
  • 5
  • 44
  • 78
24
votes
2 answers

Is there a simple way to convert setup.py to pyproject.toml

We have multiple python projects, and are considering converting them to use pyproject.toml instead of setup.py. Is there a simple way to automate this?
24
votes
1 answer

Does Poetry have an equivalent for the flag "--trusted-host" that is available on Pip?

I wish to start using poetry on some projects at work, where I am stuck behind corporate filters that sometimes interfere with certs. If I use pip, I can ignore SSL errors by doing something like the below: $ pip install --trusted-host pypi.org…
Devasta
  • 1,489
  • 2
  • 17
  • 28
21
votes
2 answers

How to reuse pyproject.toml in monorepo with Poetry?

There are multiple projects in my monorepo, which has package management via Poetry individually. For instance, monorepo ├── a │   └── pyproject.toml ├── b │   └── pyproject.toml └── c └── pyproject.toml Each project has its own sessions for…
northtree
  • 8,569
  • 11
  • 61
  • 80
21
votes
5 answers

Ignoring Django Migrations in pyproject.toml file for Black formatter

I just got Black and Pre-Commit set up for my Django repository. I used the default config for Black from the tutorial I followed and it's been working great, but I am having trouble excluding my migrations files from it. Here is the default…
Clark Sandholtz
  • 701
  • 6
  • 14
20
votes
2 answers

How to build a C extension in keeping with PEP 517, i.e. with pyproject.toml instead of setup.py?

I want to build a C extension for CPython. I could do it traditionally with a setup.py file. However, for the reasons mentioned in PEP 517, I would prefer a declarative approach using a pyproject.toml. I understand that setuptools is the only build…
17
votes
2 answers

How do I specify "extra" / bracket dependencies in a pyproject.toml?

I'm working on a project that specifies its dependencies using Poetry and a pyproject.toml file to manage dependencies. The documentation for one of the libraries I need suggests pip-installing with an "extra" option to one of the dependencies, like…
Sarah Messer
  • 3,592
  • 1
  • 26
  • 43
1
2 3
17 18