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

PYTHON-4163 Rename src/ to bsonjs/ to avoid setuptools bug that shadows bson package #53

Merged
merged 2 commits into from
Jan 26, 2024

Conversation

ShaneHarvey
Copy link
Collaborator

https://jira.mongodb.org/browse/PYTHON-4163

New installed site-packages looks like this:

$ ls /Users/shane/work/pycharm/python-bsonjs/lib/python3.11/site-packages/       
__pycache__                     build                           easy-install.pth                pkg_resources                   setuptools-67.4.0.dist-info
_distutils_hack                 build-0.10.0.dist-info          gridfs                          pymongo                         setuptools-67.4.0.virtualenv
_virtualenv.pth                 check_manifest-0.49.dist-info   packaging                       pymongo-4.4.1.dist-info         wheel
_virtualenv.py                  check_manifest.py               packaging-23.1.dist-info        pyproject_hooks                 wheel-0.38.4.dist-info
bson                            distutils-precedence.pth        pip                             pyproject_hooks-1.0.0.dist-info wheel-0.38.4.virtualenv
bsonjs                          dns                             pip-23.0.1.dist-info            python_bsonjs-0.3.0.dist-info
bsonjs.abi3.so                  dnspython-2.4.1.dist-info       pip-23.0.1.virtualenv           setuptools
$  ls /Users/shane/work/pycharm/python-bsonjs/lib/python3.11/site-packages/bsonjs/
bson     bsonjs.c bsonjs.h common   jsonsl

The packages and loaded as expected:

$ python
>>> import bsonjs
>>> bsonjs.__spec__
ModuleSpec(name='bsonjs', loader=<_frozen_importlib_external.ExtensionFileLoader object at 0x100659910>, origin='/Users/shane/git/python-bsonjs/bsonjs.abi3.so')
>>> import bson
>>> bson.encode({})
b'\x05\x00\x00\x00\x00'
>>> import jsonsl
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'jsonsl'

@ShaneHarvey ShaneHarvey requested a review from blink1073 January 25, 2024 19:44
@ShaneHarvey ShaneHarvey requested a review from a team as a code owner January 25, 2024 19:44
Copy link
Member

@blink1073 blink1073 left a comment

Choose a reason for hiding this comment

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

LGTM!

@blink1073
Copy link
Member

        To avoid accidental inclusion of unwanted files or directories,
        setuptools will not proceed with this build.
        
        If you are trying to create a single distribution with multiple packages
        on purpose, you should not rely on automatic discovery.
        Instead, consider the following options:
        
        1. set up custom discovery (`find` directive with `include` or `exclude`)
        2. use a `src-layout`
        3. explicitly set `py_modules` or `packages` with a list of names
        
        To find more information, look for "package discovery" on setuptools docs.
        [end of output]

@ShaneHarvey ShaneHarvey requested a review from blink1073 January 25, 2024 20:41
@ShaneHarvey
Copy link
Collaborator Author

Fixed the wheel error by adding this:

[tool.setuptools]
packages = ["bsonjs"]

@ShaneHarvey ShaneHarvey merged commit f45de61 into mongodb-labs:master Jan 26, 2024
48 checks passed
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.

2 participants