Skip to content

Python3 port of SCL library - #408

Closed
devonsparks wants to merge 9 commits into
stepcode:masterfrom
devonsparks:py3
Closed

devonsparks wants to merge 9 commits into
stepcode:masterfrom
devonsparks:py3

Conversation

@devonsparks

Copy link
Copy Markdown
Contributor

Motivation

I've been using the Py2 SCL library in the stepcode library to good effect for some IFC experiments. I now would like to integrate this with adjacent libraries that have a Py3 dependency. Considering Python2 is sunset, and there's interest (Issue 407) from the stepcode community in a Py3 port, it seemed like a good time to start. This PR is the result.

Summary of Changes

Changes fell in two categories:

  1. Those changes critical to make SCL run under Py3 at all
  2. Convenience features like egg packaging that will hopefully make working with SCL easier in the future.

Changes on (1) were minor (updating the use of the new print function, migrating all modules to use new-style classes).

Changes on (2) were more significant. They include:

  1. Creating a proper setup.cfg configuration to allow us to build SCL as a Python Package and automatically install required dependencies. This also opens the door to publishing the library on PyPI, so users could install with pip and friends.
  2. Ensure the test suite can run using python3 -m unittest discover
  3. Adding a new set of test cases, test_parser.py, that do a basic sanity check on the parser logic against a sample Part 21 file.
  4. Adding a separate LICENSE file (that mirrors those already shown in line at the top of SCL files), and basic README that provides a starting point for newcomers.

The only "breaking change" is a test case file, test_unitary_schemas.py, that I prefixed with an underscore to avoid being called by unittest discover. test_untiary_schemas.py relies on Python modules autogenerated by exp2python in the parent directory. Those autogenerated modules make use of a decorator, called @apply, I haven't been able to find/grep in the source tree. The tests won't be able to run until this decorator definition is found/written and put back in the sys.path. For now I've added this note in the test case file with an open invitation for others to bring it back to life if they know where the missing dependencies are. If the meaning or source for @apply can be found, it doesn't seem like we're far off from resurrecting these particular tests.

Validation

I'm able to successfully build the package (python3 -m build) and run all unit tests (python -m unittest discover - 101/101 pass) on my local machine. I can also build the full stepcode project using the usual cmake workflow from scratch without errors.

Includes:
- Updating core to remove Py2 dependencies (especially print_function)
- Migrating setup.py to setup.cfg to support integration with PyPA build
- Making all imports absolute
- Fixing the test suite to ensure it runs again (with the exception of unitary schema, which seems to depend on modules that no longer exist)
… into a package to support use with unittest.
@tpaviot

tpaviot commented May 18, 2021

Copy link
Copy Markdown
Member

In Python3 there's no need to explicitly inherit from the object class

@cshorler
cshorler self-requested a review August 23, 2021 20:00

@cshorler cshorler left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

agree with @tpaviot - no need for inheriting object in Python 3. Also, we can use relative imports for library imports. I'll rebase and rework locally today or tomorrow.

@cshorler

Copy link
Copy Markdown
Member

also looking at the remaining commits at a glance - are there redundant commits in this, looks like there could be.

@cshorler

Copy link
Copy Markdown
Member

also we need to update exp2py for this change as well - this is currently missing.

@cshorler

Copy link
Copy Markdown
Member

superseded by #429 and #430

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants