Skip to content

Build wheel in Polylithic project structure - include src folder #906

@mstumberger

Description

@mstumberger

Problem description

I have a following project structure:

Image

I have source files in src folder, and pyproject.toml of a package I want to build.

root pyproject.toml

### Main SDK: izoelektro-sdk

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

[bdist_wheel]
universal = 1

[project]
name = "izoelektro-sdk"
version = "v1.2.4"
description = "Izoelektro SDK for various automation and IoT integrations."
authors = [{ name = "...", email = "...@...i" }]
license = "MIT"
readme = "Readme.md"

[project.optional-dependencies]
ble = [
    "izoelektro-ble-sdk"
]
slack = [
    "izoelektro-slack"
]
ram_center = [
    "izoelektro-ram-center"
]
all = [
    "izoelektro-ram-center", "izoelektro-slack", ...
]

packages/connection_ble includes:

[project]
name = "izoelektro-ble-sdk"
version = "v1.2.4"
description = "RAM Center module for Izoelektro SDK"
authors = [{ name = "...", email = "...@...i" }]
dependencies = [
    "bleak",
    "nest_asyncio",
]

[build-system]
requires = ["setuptools", "wheel"]
build-backend = "setuptools.build_meta"

I specify which packages to include in setup.py file.

from setuptools import setup

setup(
    name="izoelektro-ble-sdk",
    package_dir={"": "../../src"},
    url='https://gitlab.com/SDK',
    packages=[
        'izoelektro',
        'izoelektro.connection',
        'izoelektro.connection.ble',
        'izoelektro.connection.ble.ble_adv_scan',
        'izoelektro.device',
    ],
    description="BLE Izoelektro SDK",
    author="Marko",
)

When I install the package with pip install -e . install passes but when I want to build a wheel from project root with python -m build packages/connection_ble/ I get an error:

...
copying ..\..\src\izoelektro_ble_sdk.egg-info\requires.txt -> izoelektro_ble_sdk-1.2.4\..\..\src\izoelektro_ble_sdk.egg-info
copying ..\..\src\izoelektro_ble_sdk.egg-info\top_level.txt -> izoelektro_ble_sdk-1.2.4\..\..\src\izoelektro_ble_sdk.egg-info
copying ..\..\src\izoelektro_ble_sdk.egg-info\SOURCES.txt -> izoelektro_ble_sdk-1.2.4\..\..\src\izoelektro_ble_sdk.egg-info
Writing izoelektro_ble_sdk-1.2.4\setup.cfg
Creating tar archive
removing 'izoelektro_ble_sdk-1.2.4' (and everything under it)
* Building wheel from sdist
* Creating isolated environment: venv+pip...
* Installing packages in isolated environment:
  - setuptools
* Getting build dependencies for wheel...
running egg_info
error: error in 'egg_base' option: '../../src' does not exist or is not a directory

ERROR Backend subprocess exited when trying to invoke get_requires_for_build_wheel

As far as I figured out files are copied to the temp folder when building wheel and the files don't exist there.

How can I include src folder?

I saw it can be done with poetry with something like this in pyproject.toml:

[tool.poetry]
name = "izoelektro-ble-sdk"
version = "1.2.4"
description = "BLE Izoelektro SDK"
authors = [{ name = "...", email = "...@...i" }]
license = "MIT"
readme = "Readme.md"

packages = [
    { include = "izoelektro", from = "../../src" },
    { include = "izoelektro/connection", from = "../../src" },
    { include = "izoelektro/connection/ble", from = "../../src" },
    { include = "izoelektro/connection/ble/adv_scan", from = "../../src" },
    { include = "izoelektro/device", from = "../../src" }
]

but It's overkill for my use.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions