Skip to content

Add debian packaging for micropython #521

Closed

Description

@WasabiFan

@dlech I can't figure out what needs to be added so that the library is installed into the correct location for Micropython as well. I am guessing the logic for python3 packaging is implicit here:

dh $@ --with python3 --buildsystem=pybuild

But I'm not sure what the equivalent would be for micropython. Could you give me some pointers?

Activity

  1. dlech commented on Sep 15, 2018

    @dlech
    Member
  2. dlech commented on Sep 15, 2018

    @dlech
    Member

    debhelper knows about python, so basically it does everything for you automatically. It doesn't know anything about micropython, so you have to do everything manually in the debian/rules file. And you will need to add the package that provides mpy-cross to the build depends in debian/control.

  3. WasabiFan commented on Dec 2, 2018

    @WasabiFan
    MemberAuthor

    @dlech a few questions about the micropython-lib rules file and how it applies here:

    • Why does the mpy_files list include things like READMEs? As far as I can tell, it seems like the files that don't end with .mpy will match the % rule and therefore be passed to the dh command... but I don't understand what that's supposed to do.
    • Presuming I want the Micropython files in our existing package, I think I would need separate set of rules to execute dh without the python addon. Is that right, and if so what should the rule structure look like?
  4. dlech commented on Dec 2, 2018

    @dlech
    Member

    Why does the mpy_files list include things like READMEs?

    The READMEs aren't supposed to be there. They probably just got overlooked since there are so many files.

    As far as I can tell, it seems like the files that don't end with .mpy will match the % rule and therefore be passed to the dh command... but I don't understand what that's supposed to do.

    Actually, they are only used as prerequisites. The .mpy files don't exist, so using them as a prerequisite causes them to be create via the %.mpy: %.py rule, but any other files already exist, so no action is taken on these files (other than installing them later in the override_dh_auto_install rule.

    Presuming I want the Micropython files in our existing package,

    They will need to be in the same source package, but in a different binary package. This means we need to add a second binary package (e.g. micropython-ev3dev2) to the debian/control file. Then we will need to add debian/python3-ev3dev2.install and debian/micropython-ev3dev2.install files to get the right files installed in the right packages. We can add the following to debian/rules to ensure we don't miss any files:

    override_dh_install:
    	dh_install --fail-missing

    I think I would need separate set of rules to execute dh without the python addon. Is that right, and if so what should the rule structure look like?

    The rules file only gets called once when building the debian package, so we actually need to extend existing rules rather than adding new ones. So, we should be able to copy the overrides from the micropython-lib rules file but also call the base functions that we are overriding so that the python 3 package still gets built. Something like this should do the trick:

    mpy_files = \
    	...
    
    %.mpy: %.py
    	mpy-cross -v -v -mcache-lookup-bc $<
    
    # compile .py > .mpy
    override_dh_auto_build: $(mpy_files)
    	# build python3 package
    	dh_auto_build
    
    override_dh_auto_install:
    	# install python3 package
    	dh_auto_install
    	# install .mpy files
    	for d in $(mpy_files); do \
    		# NOTE: debian/tmp/ below may not be correct (going from memory)
    		install -D --mode=644 $$d debian/tmp/usr/lib/micropython/$${d#*/}; \
    	done
  5. added this to the v2.0-beta3 milestone on Dec 19, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions