Skip to content

Conversation

@ot-goegelem
Copy link

Problem

I want to write a small tool that uses pycyphal and the public regulated data types.
But is quite annoying that it is not possible to just add/install the public regulated data types as a dependency.

I understand that this is a deliberate decision to make it possible to add custom data types, but my tool does not rely on custom data types and I want to being able to have one setup with all dependencies without needing some custom setup from the end user.

Solution

It is then possible to use this dependency by just specifying the git repository

pip install git+ssh://git@github.com/ot-goegelem/public_regulated_data_types.git@feature/python_package

@ot-goegelem ot-goegelem marked this pull request as ready for review November 6, 2024 12:22
Copy link
Member

@pavel-kirienko pavel-kirienko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Please see my comment inquiring if it's possible to strap down the setup.py

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the following not a valid replacement?

import setuptools
import distutils.command.build_py
from pathlib import Path

class BuildPy(distutils.command.build_py.build_py):
    def run(self):
        import pycyphal
        output_dir = Path(self.build_lib, self.pkg_name, ".demo_dsdl_compiled")
        cur_path = pathlib.Path(__file__).parent
        pycyphal.dsdl.compile_all(
            [
                cur_path / "uavcan",
                cur_path / "reg",
            ],
            output_directory=output_dir,
        )
        super().run()

setuptools.setup(cmdclass={"build_py": BuildPy})

ot-goegelem and others added 2 commits April 23, 2025 15:14
Co-authored-by: Pavel Kirienko <pavel.kirienko@gmail.com>
Copy link
Member

@pavel-kirienko pavel-kirienko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you. I think the use case is very valid but I don't want to add Python-specific things to this repository because that will become cumbersome to maintain. We should create a new repository instead that is solely dedicated to republishing DSDL definitions as a Python package. There could be similar packages published for other languages. That repository could simply automatically reupload releases every week or so, running as a cron CI job.

If I created a new repo, would you be able to move your changes there? Can you also help us set up the CD pipeline for automatic publication?

@thirtytwobits @emrainey any objections?

@ot-goegelem
Copy link
Author

I would rather not do it periodically via a cron job.

I did a quick research and it is possible to inject build settings (config_settings, see https://peps.python.org/pep-0517/) in a package build.
What is your opinion on having another repository that you can directly install via pip and you can pass the public_regulated_data_types commit hash you want to install via config_settings to the build process. It will then clone the respective public_regulated_data_types commit and build/install those types.

@pavel-kirienko
Copy link
Member

As long as the default behavior is to install the latest master, I'm good with that. I suppose public_regulated_data_types_pip sounds like a good name?

@ot-goegelem
Copy link
Author

Sounds like a plan 🤗

@pavel-kirienko
Copy link
Member

okay let's give Scott and/or Erik some time to think about it as well

@emrainey
Copy link

I like it.

@pavel-kirienko
Copy link
Member

Okay I created the new repo here: https://github.com/OpenCyphal-Garage/public_regulated_data_types_pypi

We will roll it out of the garage once it's ready.

@ot-goegelem can you please send a PR there? If you could set up a nice readme in the process that would help! Thanks!

@pavel-kirienko
Copy link
Member

@ot-goegelem I added a repository secret called PYPI_TOKEN that allows publishing the package on https://test.pypi.org. It will not work for the main pypi.org; we will move it there later once it's done.

@thirtytwobits
Copy link
Member

Sorry all. Was a bit absent recently. Looking at this but it sounds like were' thinking about the right thing. As long as we're always adding optional features that don't increase required dependencies by the python package then I'm going to be included to approve.

@pavel-kirienko
Copy link
Member

Hey @ot-goegelem is there interest in continuing?

@ot-goegelem
Copy link
Author

Hey, sorry for not following up.
Right now I don't find much time to do this as I am involved at work.
I guess at the start of 2026 I might have time to take another look.
But don't worry this is still on my ToDo list.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants