Skip to main content

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.

pyproject.toml
Filter by
Sorted by
Tagged with
381 votes
5 answers
337k views

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 <folder> Instead, the package ...
Niko Fohr's user avatar
  • 31.9k
104 votes
5 answers
62k views

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 ...
a_guest's user avatar
  • 35.5k
84 votes
7 answers
71k views

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....
Sherein's user avatar
  • 1,387
79 votes
1 answer
58k views

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 ...
Keto's user avatar
  • 1,800
74 votes
2 answers
37k views

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, ...
bluenote10's user avatar
  • 25.6k
72 votes
6 answers
26k views

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 ...
Haterind's user avatar
  • 1,325
60 votes
5 answers
23k views

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 ...
Bastian Venthur's user avatar
57 votes
2 answers
51k views

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 ...
polm23's user avatar
  • 15.3k
35 votes
3 answers
11k views

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] ...
platypus's user avatar
  • 1,288
34 votes
3 answers
15k views

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?
user17304108's user avatar
29 votes
2 answers
10k views

What's the difference between the [tool.poetry] and [project] tables in pyproject.toml? [closed]

Context So, I'm trying to create a new Python package following this tutorial: https://packaging.python.org/en/latest/tutorials/packaging-projects/ As the tutorial says, in my pyproject.toml I should ...
toiletsandpaper's user avatar
29 votes
2 answers
12k views

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 ...
Sarah Messer's user avatar
  • 3,875
29 votes
2 answers
9k views

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 ...
Devasta's user avatar
  • 1,629
28 votes
5 answers
12k views

Specifying local relative dependency in pyproject.toml

I have the following project structure: root - sample/ - src/ - tests/ - pyproject.toml - libs/ - lol/ - src/ - tests/ - pyproject.toml I'd like to specify lol ...
Opal's user avatar
  • 83.9k
27 votes
2 answers
6k views

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....
Dr Leo's user avatar
  • 459
25 votes
5 answers
71k views

ERROR: Could not build wheels for pyaudio, which is required to install pyproject.toml-based projects

I'm getting this error when trying to install PyAudio: ERROR: Could not build wheels for pyaudio, which is required to install pyproject.toml-based projects Does anyone know why this is happening and ...
Lakeside52's user avatar
25 votes
3 answers
15k views

mypy and pyproject.toml, options only work globally

I wish to use the options disable_error_code = ["name-defined"] and ignore_missing_imports = true only for some specific modules, but I am struggling to make it work. The following is an ...
Barzi2001's user avatar
  • 1,504
24 votes
2 answers
5k views

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 └── ...
northtree's user avatar
  • 9,019
22 votes
5 answers
12k views

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 ...
Clark Sandholtz's user avatar
20 votes
2 answers
15k views

Questions on pyproject.toml vs setup.py

Reading up on pyproject.toml, python -m pip install, poetry, flit, etc - I have several questions regarding replacing setup.py with pyproject.toml. My biggest question was - how does a toml file ...
uncrayon's user avatar
  • 445
20 votes
1 answer
9k views

pyproject.toml configuration to ignore a specific path?

Are there any ways to set a path to ignore in pyproject.toml like: #pyproject.toml [tool.pytest.ini_options] ignore = ["path/to/test"] Instead of using addopts: #pyproject.toml [tool.pytest....
Yauhen Mardan's user avatar
19 votes
4 answers
15k views

MyPy configuration - exclude multiple directories

We're currently using Mypy (v 0.910) in our project with pyproject.toml for configuration. I have the following file structure: src --app --generated --service --data --ingest ...
James B's user avatar
  • 507
19 votes
1 answer
14k views

Pip pyproject.toml: Can optional dependency groups require other optional dependency groups?

I am using the latest version of pip, 23.01. I have a pyproject.toml file with dependencies and optional dependency groups (aka "extras"). To avoid redundancies and make managing optional ...
James's user avatar
  • 303
18 votes
1 answer
12k views

Specifying test dependencies in pyproject.toml and getting them installed with pip install -e

I have a Python project with a pyproject.toml similar to the one below. I use python build to generate an package I use to install in production environments. For development environments, I use pip ...
devnectar's user avatar
  • 199
18 votes
1 answer
34k views

How to build python project based on pyproject.toml

I would like to understand current state of Python build systems and requirements management. Imagine, that I checked out sources of some project that is using poetry (or pipenv). And this project ...
Andrey Tatarinov's user avatar
17 votes
4 answers
10k views

Using environment variables in `pyproject.toml` for versioning

I am trying to migrate my package from setup.py to pyproject.toml and I am not sure how to do the dynamic versioning in the same way as before. Currently I can pass the development version using ...
Ilya's user avatar
  • 782
16 votes
1 answer
13k views

Add private GitHub repo to pyproject.toml as new dependency

How can I define a private GitHub repo as a dependency in the project section of my pyproject.toml file? [project] dependencies = [ "my_repo_name>=<SSH-address_to_my_private_github_repo&...
Andi's user avatar
  • 3,971
16 votes
2 answers
13k views

How to define "python_requires" in pyproject.toml using setuptools?

Setuptools allows you to specify the minimum python version as such: from setuptools import setup [...] setup(name="my_package_name", python_requires='>3.5.2', [...] ...
gebbissimo's user avatar
  • 2,488
15 votes
1 answer
11k views

Why won't pytest use pyproject.toml for this deprecation warning

I have a django project managed with pytest and poetry. I'd like to put my pytest config into the pyproject.toml file, so I added: [tool.pytest] filterwarnings = ["ignore::django.utils....
thclark's user avatar
  • 5,277
15 votes
7 answers
31k views

ERROR: Could not build wheels for mpi4py, which is required to install pyproject.toml-based projects

I want to install mpi4py. The installation fails with the error below. Please share the solution to the same error. note: This error originates from a subprocess, and is likely not a problem with ...
eve's user avatar
  • 383
15 votes
3 answers
84k views

ERROR: Could not build wheels for prophet, which is required to install pyproject.toml-based projects

I am trying to install prophet using pip install prophet installation goes well at first, but then fails with the following error ERROR: Failed building wheel for prophet Failed to build prophet ERROR:...
Andrey Nikitin's user avatar
15 votes
2 answers
5k views

pyproject.toml and cython extension module

I have an existing python project that is using mostly setup.py to build the project. The project has 2 x Cython extension modules configured in setup.py. Initially I did pip install -e . for ...
Juergen's user avatar
  • 811
15 votes
2 answers
3k views

Distribute shell scripts using setuptools and pyproject.toml

I'm trying to distribute a shell script along with a Python package. Ideally, the shell script is installed when I run pip install my_package. I read from this SO that, my expected behavior is exactly ...
Luting Wang's user avatar
14 votes
4 answers
10k views

how to exclude "tests" folder from the wheel of a pyproject.toml managed lib?

I try my best to move from a setup.py managed lib to a pure pyproject.toml one. I have the following folder structure: tests └── <files> docs └── <files> sepal_ui └── <files> ...
Pierrick Rambaud's user avatar
14 votes
1 answer
18k views

How to build a universal wheel with pyproject.toml

This is the project directory structure . ├── meow.py └── pyproject.toml 0 directories, 2 files This is the meow.py: def main(): print("meow world") This is the pyproject.toml: [build-...
platypus's user avatar
  • 1,288
14 votes
2 answers
11k views

pyproject.toml won't find project name with setuptools python -m build format

What is the correct format for supplying a name to a Python package in a pyproject.toml? Here's the pyproject.toml file: [project] name = "foobar" version = "0.0.1" [build-system] ...
polka's user avatar
  • 1,489
13 votes
1 answer
2k views

Single source of truth for Python project version in presence of pyproject.toml

The pyproject.toml specification affords the ability to specify the project version, e.g. [project] name = "foo" version = "0.0.1" However, it is also a common Python idiom to put ...
user14717's user avatar
  • 5,069
12 votes
1 answer
8k views

Git versioning with setuptools in pyproject.toml

I'm trying to build a few packages with an automatic versioning set by setuptools-git-versioning. Unfortunately, even following the documentation and the very few resources online, I can't manage to ...
HCKRMVT's user avatar
  • 414
12 votes
1 answer
14k views

Pytest cov does not read pyproject.toml

Pytest cov is not reading its setting from the pyproject.toml file. I am using nox, so I run the test with: python3 -m nox It seems I have the same issue even without nox. In fact, after running a ...
user1315621's user avatar
  • 3,282
12 votes
1 answer
7k views

Install dependencies from pyproject.toml but not the package

I have a python package that I want to install inside a docker file. pyproject.toml looks like: [build-system] requires = ["setuptools>=61.0"] build-backend = "setuptools.build_meta&...
obk's user avatar
  • 608
11 votes
2 answers
8k views

How to insert test-time environment variable with pytest pyproject.toml

Usually, when defining a Environment Variable for pytest using the pytest-env plugin, this is done using pytest.ini: [pytest] env = DATA_DIR = data/test_assets pytest supports pyproject.toml ...
Seanny123's user avatar
  • 9,108
11 votes
3 answers
22k views

ERROR:Failed building wheel for h5pyFailed to build h5pyERROR:Could not build wheels for h5py,which is required toinstall pyproject.toml-basedprojects

I'm getting this error when I'm running the following command to install tensorflow. python3 -m pip install tensorflow-macos ERROR: Failed building wheel for h5py Failed to build h5py ERROR: Could ...
Lakshay Rohilla's user avatar
11 votes
1 answer
6k views

Replacing Manifest.in with pyproject.toml

Previously, when defining how to build a Python package, you can include folders using a line in Manifest.in: recursive-include my_package/assets * However, I would like to poetry and the associated ...
Seanny123's user avatar
  • 9,108
11 votes
1 answer
5k views

Add py.typed as package data with setuptools in pyproject.toml

From what I read, to make sure that the typing information of your code is distributed alongside your code for linters to read, the py.typed file should be part of your distribution. I find answers ...
Bram Vanroy's user avatar
11 votes
2 answers
11k views

Migration from setup.py to pyproject.toml: how to specify package name?

I'm currently trying to move our internal projects away from setup.py to pyproject.toml (PEP-518). I'd like to not use build backend specific configuration if possible, even though I do specify the ...
arne's user avatar
  • 4,614
11 votes
1 answer
5k views

How does one install a setup.cfg + pyproject.toml python project in editable mode with pip?

Is it possible to halve your cake and eat it too: can one install (via some mechanism) a project with the following structure: pyproject.toml setup.cfg src/... scripts/... In editable mode, like one ...
Chris's user avatar
  • 30.4k
10 votes
2 answers
2k views

setuptools pyproject.toml equivalent to `python setup.py clean --all`

I'm migrating from setup.py to pyproject.toml. The commands to install my package appear to be the same, but I can't find what the pyproject.toml command for cleaning up build artifacts is. What is ...
ringo's user avatar
  • 1,134
10 votes
1 answer
16k views

How do I properly change package name built with poetry?

I built a package using poetry package manager but I regret naming it because it sounds a bit childish. Besides, because poetry's default behavior is to force change the project's name to lower case (...
user8491363's user avatar
  • 3,504
9 votes
2 answers
15k views

Configuring isort and autoflake with project.toml

I have a series of tools running locally and on Jenkins to check and format my Python code: autoflake isort black I use pyproject.toml file to configure black, isort with .isort.cfg and autoflake ...
dzieciou's user avatar
  • 4,422
9 votes
2 answers
9k views

When using Pylint, how to state a particular list of variables which are valid names with the pyproject.toml settings file

Running pylint on a file containing variables such as x or l will raise an error, though these variables might be meaningful in the context that they're in. I could disable all such errors by adding ...
baxx's user avatar
  • 4,338

1
2 3 4 5
8