Skip to content

Commit

Permalink
Remove astpretty as a dependency of pyflamegpu (#1166)
Browse files Browse the repository at this point in the history
* Remove astpretty as a dependency of pyflamegpu

astpretty is only used for prettyprint debugging in codegen testing - it is not a pyflamegpu dependency.

This commit also makes it an optional test_codegen.py dependency (but installs it in the test venv by default)
  • Loading branch information
ptheywood authored Dec 15, 2023
1 parent 3e166e6 commit a4fb913
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
4 changes: 2 additions & 2 deletions swig/python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -413,8 +413,8 @@ if(FLAMEGPU_BUILD_PYTHON_VENV)
# Install the wheel from the dist dir. Specify a version incase the same build dir has been used for a previous build
# Relaxed the no-index option to allow setup.py to install requirements
COMMAND ${VENV_PIP} install --force-reinstall --find-links=dist -U ${PYTHON_DISTRIBUTION_NAME}==${FLAMEGPU_VERSION_PYTHON}
# install pytest
COMMAND ${VENV_PIP} install pytest
# install pytest and astpretty
COMMAND ${VENV_PIP} install pytest astpretty
BYPRODUCTS ${VENV_BYPRODUCTS}
WORKING_DIRECTORY ${PYTHON_LIB_OUTPUT_DIRECTORY}
COMMENT "Install ${PYTHON_DISTRIBUTION_NAME} ${FLAMEGPU_VERSION_PYTHON} wheel into ${VENV_DIR}"
Expand Down
1 change: 0 additions & 1 deletion swig/python/setup.py.in
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,5 @@ setup(
'@PYTHON_MODULE_NAME@':['$<TARGET_FILE_NAME:@PYTHON_SWIG_TARGET_NAME@>', @FLAMEGPU_CODEGEN_INCLUDE_CLEAN@@FLAMEGPU_INCLUDE_CLEAN@@FLAMEGPU_PYTHON_PACKAGE_DATA_OS_SPECIFIC@@GLM_INCLUDE_CLEAN@],
},
install_requires=[
'astpretty',
],
)
11 changes: 9 additions & 2 deletions tests/python/codegen/test_codegen.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@
import unittest
import ast
import pyflamegpu.codegen
import astpretty
# Import astpretty if it is available
try:
import astpretty
except ImportError:
print("Install astpretty if ast tree printing required for test debugging")


DEBUG_OUT = True
Expand Down Expand Up @@ -688,7 +692,10 @@ def _checkExpected(self, source, expected):
source = source.strip()
tree = ast.parse(source)
if DEBUG_OUT:
astpretty.pprint(tree)
try:
astpretty.pprint(tree)
except NameError:
pass
code = pyflamegpu.codegen.codegen(tree)
# remove new lines
code = code.strip()
Expand Down

0 comments on commit a4fb913

Please sign in to comment.