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

🐛 Fix C Extension Packaging #253

Merged
merged 13 commits into from
Sep 11, 2021
Merged

🐛 Fix C Extension Packaging #253

merged 13 commits into from
Sep 11, 2021

Conversation

TeoZosa
Copy link
Owner

@TeoZosa TeoZosa commented Sep 9, 2021

C extensions (i.e., .so shared library files) were not previously being included in wheel package distributions.

@TeoZosa TeoZosa added bug Something isn't working ci Changes to CI configuration files and scripts build Changes that affect the build system or external dependencies labels Sep 9, 2021
@TeoZosa TeoZosa self-assigned this Sep 9, 2021
@TeoZosa TeoZosa force-pushed the fix-c-extension-packaging branch 8 times, most recently from 0f665a3 to 4942915 Compare September 11, 2021 01:47
@TeoZosa TeoZosa force-pushed the fix-c-extension-packaging branch from 4942915 to f67f974 Compare September 11, 2021 02:26
A `setup.py` file is needed for `poetry build` to include compiled
libaries in the final wheel.
@TeoZosa TeoZosa force-pushed the fix-c-extension-packaging branch 5 times, most recently from 57fb33b to 329cceb Compare September 11, 2021 03:53
C extension compilation pops off the initial stack frame. Thresholding
indexing to prevent `IndexError`s (this should work for both C
extensions and pure Python packages).
Errors due to `structlog_sentry` dependency.

`TypeError` example:
```
Run echo "Default output (JSON)"
  echo "Default output (JSON)"
  python ./docs_src/pure_structlog_logging_without_sentry.py
  echo "dev-local output (formatted)"
  export CI_ENVIRONMENT_SLUG=dev-local
  python ./docs_src/pure_structlog_logging_without_sentry.py
  shell: /usr/bin/bash --noprofile --norc -e -o pipefail {0}
  env:
    pythonLocation: /opt/hostedtoolcache/Python/3.7.11/x64
    LD_LIBRARY_PATH: /opt/hostedtoolcache/Python/3.7.11/x64/lib
Default output (JSON)
Traceback (most recent call last):
  File "./docs_src/pure_structlog_logging_without_sentry.py", line 3, in <module>
    LOGGER = structlog_sentry_logger.get_logger()
  File "structlog_sentry_logger/_config.py", line 80, in get_logger
    set_structlog_config(timestamper)
  File "structlog_sentry_logger/_config.py", line 204, in set_structlog_config
    SentryBreadcrumbJsonProcessor(level=logging.ERROR, tag_keys="__all__"),
  File "structlog_sentry_logger/_config.py", line 406, in __init__
    super().__init__(
  File "structlog_sentry_logger/_config.py", line 352, in __init__
    super().__init__(*args, **kwargs)
TypeError: int object expected; got tuple[
Error: Process completed with exit code 1.
```

`SystemError` example:
```
Run echo "Default output (JSON)"
Default output (JSON)
Traceback (most recent call last):
  File "/home/runner/work/structlog-sentry-logger/structlog-sentry-logger/./docs_src/pure_structlog_logging_without_sentry.py", line 3, in <module>
    LOGGER = structlog_sentry_logger.get_logger()
  File "structlog_sentry_logger/_config.py", line 77, in get_logger
    set_structlog_config(timestamper)
  File "structlog_sentry_logger/_config.py", line 201, in set_structlog_config
    SentryBreadcrumbJsonProcessor(level=logging.ERROR, tag_keys="__all__"),
  File "structlog_sentry_logger/_config.py", line 242, in __init__
    super().__init__(
  File "/opt/hostedtoolcache/Python/3.9.6/x64/lib/python3.9/site-packages/structlog_sentry/__init__.py", line 132, in __init__
    super().__init__(*args, **kwargs)
  File "/opt/hostedtoolcache/Python/3.9.6/x64/lib/python3.9/site-packages/structlog_sentry/__init__.py", line 33, in __init__
    self.level = level
SystemError: Objects/dictobject.c:bug: bad argument to internal function
Error: Process completed with exit code 1.
```
Since these tests use monkeypatching, they are unable to modify the
underlying C-compiled Python modules, rendering their output spurious
outside the context of pure Python library testing.
Excluding tests only valid in a pure Python context.
`.so`/`.pyd` files get included in project sdist package installations
intended to be pure Python packages (in other words, `.so`/`.pyd` files
are executed instead of the corresponding Python modules) which
incidentally causes `test_invalid_git_repository()` to fail.
@TeoZosa TeoZosa force-pushed the fix-c-extension-packaging branch 2 times, most recently from d3f84a0 to b972627 Compare September 11, 2021 04:26
@TeoZosa TeoZosa merged commit a562b29 into master Sep 11, 2021
@TeoZosa TeoZosa deleted the fix-c-extension-packaging branch September 11, 2021 04:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working build Changes that affect the build system or external dependencies ci Changes to CI configuration files and scripts
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant