Skip to content

expose public regulated data types as a python package #148

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

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://[email protected]/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

setup.py Outdated
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})

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants