0

I am trying to create a pyproject.toml that also installs some ROS packages as extras from https://rospypi.github.io/simple/.

In my first explorations, installation via pip install --extra-index-url https://rospypi.github.io/simple/ rospy rosbag worked perfectly. Now, I would like to specify a pyproject.toml which installs these dependencies via extra sources.

Here's my (abbreviated) pyproject.toml:

[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"

[tool.poetry]
name = "myproject"
version = "0.0.1"
description = "..."
license = "MIT"
# more of this here ...


[tool.poetry.dependencies]
python = "^3.7"
click = "*"
numpy = "*"
pandas = "*"

# Tests
pytest = {version = "*", optional = true }

# ros-stuff
matplotlib = {version = "*", optional = true }
geopandas = {version = "*", optional = true }
rospy = {version="*",  optional = true, source="rospypi"}
rosbag = {version="*", optional = true, source="rospypi"}

[tool.poetry.extras]
test = ["pytest"]
ros = [
    "matplotlib",
    "geopandas",
    "rospy",
    "rosbag"
]

[[tool.poetry.source]]
name = "rospypi"
url = "https://rospypi.github.io/simple/"
secondary = true

Now, I can create a new project and venv and install this project as dependency via pip install ~/path/to/myproject. It installs fine, including all dependencies.

However, when I try to pip install ~/path/to/myproject[ros], I see the following output:

Processing /Users/myself/path/to/myproject
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
Requirement already satisfied: pandas in ./venv/lib/python3.9/site-packages (from frenetic==0.0.1) (1.4.3)
... (shortened) ... 
Collecting matplotlib
  Using cached matplotlib-3.5.2-cp39-cp39-macosx_10_9_x86_64.whl (7.3 MB)
ERROR: Could not find a version that satisfies the requirement rospy; extra == "ros" (from myproject[ros]) (from versions: none)
ERROR: No matching distribution found for rospy; extra == "ros"

So far, I tried playing with the "rospypi" definition (values of url, secondary, default), changing values of rospy/rosbag's optional, and a few other things. Unfortunately to no luck.

PS: I use poetry, since as far as I understand, setuptools does not allow for definition of additional sources at all. However, I am happy to switch to any build system that will make this work.

stklik
  • 834
  • 1
  • 8
  • 19
  • i've just encountered a similar problem. I have two packages stored in a private registry. pkg_b depends on pkg_a and I wasn't sure how to go about defining that in the `project.toml`. I've listed pkg_a as a dependency in pkg_b's project.toml, but am not relying on pip to actually install it. I'll just be letting my internal consumers of pkg_b know that they must also install pkg_a. Not very elegant, but the easiest thing i could get going without much legwork – nibudd Nov 23 '22 at 14:05

0 Answers0