I have the following setup:
`- MyLibrary
`- pyproject.toml
`- setup.cfg
`- setup.py
`- Package1
`- ...
`- Package2
`- ...
`- CodeGen
`- __init__.py
`- Generate.py
and I need the install script to run a generate()
function from CodeGen.Generate
to include some extra code in the distribution.
I have tried the following:
from setuptools import setup, find_packages
from setuptools.command.install import install
from .CodeGen import generate
class CustomInstall(install):
def run(self):
install.run(self)
generate()
setup(
cmdclass={"install": CustomInstall},
name="MyLibrary",
packages=find_packages(),
)
With setuptools as my build backend. But running pip install .
fails with the following error:
ImportError: attempted relative import with no known parent package
on the line from .CodeGen import generate
.
How can I make it so that the CodeGen
script is importable in my setup.py
? Note that it depends on some package dependencies, which are listed in the [build-system]
requires
field of my pyproject.toml
.
Alternatively, how would I achieve this differently?