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.
pull/25/head
matejcik 6 years ago
parent 6f032456fc
commit ce7a434f2d

@ -5,6 +5,7 @@ import subprocess
from setuptools import setup, Command
from setuptools.command.build_py import build_py
from setuptools.command.develop import develop
install_requires = [
'setuptools>=19.0',
@ -61,10 +62,19 @@ class PrebuildCommand(Command):
print("Using pre-generated files.")
class CustomBuild(build_py):
def run(self):
def _patch_prebuild(cls):
"""Patch a setuptools command to depend on `prebuild`"""
orig_run = cls.run
def new_run(self):
self.run_command('prebuild')
super().run()
orig_run(self)
cls.run = new_run
_patch_prebuild(build_py)
_patch_prebuild(develop)
setup(
@ -99,6 +109,5 @@ setup(
],
cmdclass={
'prebuild': PrebuildCommand,
'build_py': CustomBuild,
},
)

Loading…
Cancel
Save