Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove astpretty as a dependency of pyflamegpu #1166

Merged
merged 2 commits into from
Dec 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason to remove it from the venv, if it's used by the codegen tests?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is adding it to the venv if pytest is also being installed.

Previously it would be implicitly installed as a dependency of pyflamegpu.

The changes to test_codegen.py itself making it optional within the test is not really neccesarry, just adds a bit more flexibility, it makes it so that just pyflamegpu and pytest are required, but if codegen debugging is wanted then astpretty might help.

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 @@ -590,7 +594,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