logical or linkage in pyproject.toml Dependencies

151 Views Asked by At

I'm trying to build a package with the build editor setuptools. For this I created the following

pyproject.toml file:

[build-system]
requires = ["setuptools>=61.0"]
build-backend = "setuptools.build_meta"

[project]
name = "AIB_Board"
version = "1.0.0"

description = "description"

requires-python = ">=3.7"
classifiers = [
    "Programming Language :: Python :: 3",
    "License :: OSI Approved :: MIT License",
    "Operating System :: OS Independent",
]
dependencies = [
    "PakageOwn==0.0.0", 
]

This also works perfectly. However, I would like to use a logical OR in the dependencies, but unfortunately I fail.

I tryed:

dependencies = [    
     "PakageOne==0.0.0 | PakageTwo==1.0.0",  
]

and also

dependencies = [    
     "PakageOne==0.0.0 or PakageTwo==1.0.0",     
]

but this isn't working.

I always get the error:

ValueError: invalid pyproject.toml config: project.dependencies\[1\]. configuration error: project.dependencies\[1\] must be pep508

so i read PEP 508 and tryed:

dependencies = [    
     "name; os_name=='a' or os_name=='b'", 
]

this worked, but why doesn't work mine? I don't have Moduls under my packages i just have different Versions. Maybe thats a simple Question but I am a noob with build packages. So my Question is how is the syntax to use a logical or in the case i have tryed Thank you for your help!

1

There are 1 best solutions below

0
Noob_Sim On

Thanks for your answer sinoroc.

I use PIP to do a compatibility check. here is an example:

I have the following components:

Pen, Tablet, Case

all of the components have different versions with specific dependencies

Pen: 1.0.0 ;2.0.0 ;3.0.0

Tablet: 1.0.0 ;2.0.0 ;3.0.0

Case: 1.0.0 ;2.0.0 ;3.0.0

The pen now has the following dependency:

Dependencies: Tablet >= 3.0.0 or Pen <= 2.0.0

This is probably not the best example but I hope this makes the problem clearer.