Skip to content

Commit

Permalink
Possibly better fix for tox
Browse files Browse the repository at this point in the history
  • Loading branch information
WilliamJamieson committed Jan 17, 2024
1 parent 2d136e2 commit 2c264ff
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 11 deletions.
24 changes: 20 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,39 @@

from setuptools import Extension, setup
from setuptools.command.build_ext import build_ext
from setuptools.command.sdist import sdist


def _run_generator():
"""Run the generator"""
roman_datamodels = Path(__file__).parent / "src"
sys.path.append(str(roman_datamodels))

from roman_datamodels.generator import setup_files

setup_files()


class PostBuildExtCommand(build_ext):
"""Post-installation for extension."""

def run(self):
roman_datamodels = Path(__file__).parent / "src"
sys.path.append(str(roman_datamodels))
_run_generator()
super().run()


from roman_datamodels.generator import setup_files
class PostSDistCommand(sdist):
"""Post-installation for source distribution."""

setup_files()
def run(self):
super().run()
_run_generator()


setup(
cmdclass={
"build_ext": PostBuildExtCommand,
"sdist": PostSDistCommand,
},
ext_modules=[
Extension(
Expand Down
6 changes: 0 additions & 6 deletions src/roman_datamodels/datamodels/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,6 @@

warnings.warn("Failed to import the data model objects, attempting to run the generator.")

from roman_datamodels.generator import setup_files

setup_files()

from ._generated import * # noqa: F403


def __getattr__(name):
"""Allow use of deprecated model names"""
Expand Down
1 change: 0 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ commands_pre =
oldestdeps: minimum_dependencies roman_datamodels --filename requirements-min.txt
oldestdeps: pip install -r requirements-min.txt
devdeps: pip install -r requirements-dev.txt -U --upgrade-strategy eager
python ./src/roman_datamodels/generator
pip freeze
commands =
pytest \
Expand Down

0 comments on commit 2c264ff

Please sign in to comment.