Copy files to pip's build directory
(Nasty) use-case: I have a 3rd party subproject that I have to endow with setup.py, so that it would run make
producing certain artifacts that I want to list in scripts=
. I've derived a class from setuptools.install.install
that chdir()
s into a folder adjacent to __file__
and make
s.
However, when run with pip install
, pip
would only copy what seems to be source files to the build directory.
I've tried specifying data_files=
, but that didn't help.
How can I hint pip
to copy specific files to the build dir?
P.S. I know it may look like a wrong problem to solve, but I do specifically want to copy those files to build dir, to make
and to add artifacts to the wheel.
UPD: in reply to the comment on setup.py MVE.
Example project structure:
├── libs
│ └── external
│ ├── Makefile
│ └── src
│ └── _...
├── setup.py
└── src
└── __init__.py
Example setup.py:
from setuptools import setup
from setuptools.command.install import install
from subprocess import Popen
import os
import glob
EXT_DIR = os.path.join(os.path.dirname(__file__), 'libs', 'external')
class RunMake(install):
"""Makefile on setuptools install."""
def run(self):
old_dir = os.getcwd()
try:
os.chdir(EXT_DIR)
self.spawn(['make'])
finally:
os.chdir(old_dir)
install.run(self)
setup(name='example',
version='0.0.1',
packages=['example'],
package_dir={'example': 'src'},
cmdclass={'install': RunMake},
scripts=['libs/external/build/bin/SomeBinary'],
data_files=[
('libs', glob.glob('libs/**'))
]
)
UPD: MANIFEST.in
Tried out just this, and Makefile still isn't there
include libs/external/Makefile
include libs/external/*
The resulting .egg-info:
setup.py
poisson_reconstruction.egg-info/PKG-INFO
poisson_reconstruction.egg-info/SOURCES.txt
poisson_reconstruction.egg-info/dependency_links.txt
poisson_reconstruction.egg-info/top_level.txt
src/__init__.py