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

This is a somewhat controversial topic, and the answer for the moment is that there is no one single tool that everyone agrees is the “right way” to build source distributions, nor what that tool would be. You can see a long thread about it on the Python Packaging discourse. I hesitate to give too … Read more

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

Quoting myself from here My current assumption is: […] you put your (mostly unpinned) dependencies to pyproject.toml instead of setup.py, so you library can be installed as a dependency of something else without causing much troubles because of issues resolving version constraints. On top of that, for “deployable applications” (for lack of a better term), … Read more

Specifying command line scripts in pyproject.toml

Update July 2022: if your TOML file uses setuptools as its build system, setuptools will happily create and install a command-line script. For example, my pyproject.toml file starts like this: [build-system] requires = [“setuptools>=61.0”] build-backend = “setuptools.build_meta” Extend your pyproject.toml file with an entry like this, naming the package, module and entry-point function names: [project.scripts] … Read more

Download dependencies declared in pyproject.toml using Pip

Here is an example of .toml file: [build-system] requires = [ “flit_core >=3.2,<4”, ] build-backend = “flit_core.buildapi” [project] name = “aedttest” authors = [ {name = “Maksim Beliaev”, email = “[email protected]”}, {name = “Bo Yang”, email = “[email protected]”}, ] readme = “README.md” requires-python = “>=3.7” classifiers = [“License :: OSI Approved :: MIT License”] dynamic … Read more

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

Use dynamic metadata: [project] dynamic = [“dependencies”] [tool.setuptools.dynamic] dependencies = {file = [“requirements.txt”]} Note that this will use a requirements.txt–like syntax; each line must conform to PEP 508, so flags like -r, -c, and -e are not supported inside this requirements.txt. Additionally: If you are using an old version of setuptools, you might need to … Read more

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

After you have installed your project – either in editable mode by poetry install or from the wheel – you can access several metadata via importlib.metadata (importlib_metadata for python < 3.8). So keep the version only in the pyproject.toml and use this in your python code: import importlib.metadata __version__ = importlib.metadata.version(“mypackage”)

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

PEP 660 – Editable installs for pyproject.toml based builds defines how to build projects that only use pyproject.toml. Build tools must implement PEP 660 for editable installs to work. You need a front-end (such as pip ≥ 21.3) and a backend. The statuses of some popular backends are: Setuptools implements PEP 660 as of version … Read more

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

my question differ because I ask for a human-written pyproject.toml First, the pyproject.toml file is always “human-writable“. Then, it is important to know that in this context setuptools and Poetry take the role of what are called “build back-ends” (in a “PEP 517” sense), and there are many such build back-ends available today, setuptools and … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)