mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-01-09 23:11:10 +00:00
build: add the prebuild command as a dependency for develop
So, 'python setup.py develop' exists. And of course it doesn't have build_py as a dependency, because of course it doesn't. We could use 'data_files' instead of 'package_data and copying', and then use pkg_resources to find the actual file location, and that could work in theory. But pkg_resources API is weird and messy and this whole area of Python packaging theory barely works as it is. Instead we will force the prebuild command to be a dependency of develop as well as build_py, and we do this by monkey-patching instead of the proper way, because at this point it seems cleaner. I wonder if there are more commands that would need this.
This commit is contained in:
parent
6f032456fc
commit
ce7a434f2d
17
setup.py
17
setup.py
@ -5,6 +5,7 @@ import subprocess
|
|||||||
|
|
||||||
from setuptools import setup, Command
|
from setuptools import setup, Command
|
||||||
from setuptools.command.build_py import build_py
|
from setuptools.command.build_py import build_py
|
||||||
|
from setuptools.command.develop import develop
|
||||||
|
|
||||||
install_requires = [
|
install_requires = [
|
||||||
'setuptools>=19.0',
|
'setuptools>=19.0',
|
||||||
@ -61,10 +62,19 @@ class PrebuildCommand(Command):
|
|||||||
print("Using pre-generated files.")
|
print("Using pre-generated files.")
|
||||||
|
|
||||||
|
|
||||||
class CustomBuild(build_py):
|
def _patch_prebuild(cls):
|
||||||
def run(self):
|
"""Patch a setuptools command to depend on `prebuild`"""
|
||||||
|
orig_run = cls.run
|
||||||
|
|
||||||
|
def new_run(self):
|
||||||
self.run_command('prebuild')
|
self.run_command('prebuild')
|
||||||
super().run()
|
orig_run(self)
|
||||||
|
|
||||||
|
cls.run = new_run
|
||||||
|
|
||||||
|
|
||||||
|
_patch_prebuild(build_py)
|
||||||
|
_patch_prebuild(develop)
|
||||||
|
|
||||||
|
|
||||||
setup(
|
setup(
|
||||||
@ -99,6 +109,5 @@ setup(
|
|||||||
],
|
],
|
||||||
cmdclass={
|
cmdclass={
|
||||||
'prebuild': PrebuildCommand,
|
'prebuild': PrebuildCommand,
|
||||||
'build_py': CustomBuild,
|
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user