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

Add support for Python 3.12 #219

Closed
wants to merge 5 commits into from
Closed

Conversation

nickbaum
Copy link
Contributor

I've added support for Python 3.12, similar to how /pull/205 added support for 3.11.

The only additional change was renaming assertRaisesRegexp (deprecated since Python 3.2) to assertRaisesRegex (introduced in Python 3.2).

The tests pass, I'm pasting the test run below.

I have not updated the version number since I believe you prefer to do that in a separate pull request, but let me know if you'd like me to create a pull request for that as well.

This is currently blocking us from upgrading from Python 3.12.

Thank you!

-Nick

➜  jsonobject git:(master) python setup.py build_ext --inplace && python setup.py test
/Users/nickbaum/.pyenv/versions/3.12.2/lib/python3.12/site-packages/setuptools/__init__.py:80: _DeprecatedInstaller: setuptools.installer and fetch_build_eggs are deprecated.
!!

        ********************************************************************************
        Requirements should be satisfied by a PEP 517 installer.
        If you are using pip, you can try `pip install --use-pep517`.
        ********************************************************************************

!!
  dist.fetch_build_eggs(dist.setup_requires)
/Users/nickbaum/.pyenv/versions/3.12.2/lib/python3.12/site-packages/setuptools/installer.py:44: UserWarning: Module Cython was already imported from /Users/nickbaum/.pyenv/versions/3.12.2/lib/python3.12/site-packages/Cython/__init__.py, but /Users/nickbaum/jsonobject/.eggs/Cython-0.29.37-py3.12.egg is being added to sys.path
  pkg_resources.working_set.add(dist, replace=True)
/Users/nickbaum/.pyenv/versions/3.12.2/lib/python3.12/site-packages/setuptools/installer.py:44: UserWarning: Module cython was already imported from /Users/nickbaum/.pyenv/versions/3.12.2/lib/python3.12/site-packages/cython.py, but /Users/nickbaum/jsonobject/.eggs/Cython-0.29.37-py3.12.egg is being added to sys.path
  pkg_resources.working_set.add(dist, replace=True)
Warning: 'classifiers' should be a list, got type 'tuple'
running build_ext
copying build/lib.macosx-14.0-arm64-cpython-312/jsonobject/api.cpython-312-darwin.so -> jsonobject
copying build/lib.macosx-14.0-arm64-cpython-312/jsonobject/base.cpython-312-darwin.so -> jsonobject
copying build/lib.macosx-14.0-arm64-cpython-312/jsonobject/base_properties.cpython-312-darwin.so -> jsonobject
copying build/lib.macosx-14.0-arm64-cpython-312/jsonobject/containers.cpython-312-darwin.so -> jsonobject
copying build/lib.macosx-14.0-arm64-cpython-312/jsonobject/properties.cpython-312-darwin.so -> jsonobject
copying build/lib.macosx-14.0-arm64-cpython-312/jsonobject/utils.cpython-312-darwin.so -> jsonobject
/Users/nickbaum/.pyenv/versions/3.12.2/lib/python3.12/site-packages/setuptools/__init__.py:80: _DeprecatedInstaller: setuptools.installer and fetch_build_eggs are deprecated.
!!

        ********************************************************************************
        Requirements should be satisfied by a PEP 517 installer.
        If you are using pip, you can try `pip install --use-pep517`.
        ********************************************************************************

!!
  dist.fetch_build_eggs(dist.setup_requires)
/Users/nickbaum/.pyenv/versions/3.12.2/lib/python3.12/site-packages/setuptools/installer.py:44: UserWarning: Module Cython was already imported from /Users/nickbaum/.pyenv/versions/3.12.2/lib/python3.12/site-packages/Cython/__init__.py, but /Users/nickbaum/jsonobject/.eggs/Cython-0.29.37-py3.12.egg is being added to sys.path
  pkg_resources.working_set.add(dist, replace=True)
/Users/nickbaum/.pyenv/versions/3.12.2/lib/python3.12/site-packages/setuptools/installer.py:44: UserWarning: Module cython was already imported from /Users/nickbaum/.pyenv/versions/3.12.2/lib/python3.12/site-packages/cython.py, but /Users/nickbaum/jsonobject/.eggs/Cython-0.29.37-py3.12.egg is being added to sys.path
  pkg_resources.working_set.add(dist, replace=True)
Warning: 'classifiers' should be a list, got type 'tuple'
running test
WARNING: Testing via this command is deprecated and will be removed in a future version. Users looking for a generic test entry point independent of test runner are encouraged to use tox.
/Users/nickbaum/.pyenv/versions/3.12.2/lib/python3.12/site-packages/setuptools/command/test.py:193: _DeprecatedInstaller: setuptools.installer and fetch_build_eggs are deprecated.
!!

        ********************************************************************************
        Requirements should be satisfied by a PEP 517 installer.
        If you are using pip, you can try `pip install --use-pep517`.
        ********************************************************************************

!!
  ir_d = dist.fetch_build_eggs(dist.install_requires)
/Users/nickbaum/.pyenv/versions/3.12.2/lib/python3.12/site-packages/setuptools/command/test.py:194: _DeprecatedInstaller: setuptools.installer and fetch_build_eggs are deprecated.
!!

        ********************************************************************************
        Requirements should be satisfied by a PEP 517 installer.
        If you are using pip, you can try `pip install --use-pep517`.
        ********************************************************************************

!!
  tr_d = dist.fetch_build_eggs(dist.tests_require or [])
/Users/nickbaum/.pyenv/versions/3.12.2/lib/python3.12/site-packages/setuptools/command/test.py:195: _DeprecatedInstaller: setuptools.installer and fetch_build_eggs are deprecated.
!!

        ********************************************************************************
        Requirements should be satisfied by a PEP 517 installer.
        If you are using pip, you can try `pip install --use-pep517`.
        ********************************************************************************

!!
  er_d = dist.fetch_build_eggs(
running egg_info
writing jsonobject.egg-info/PKG-INFO
writing dependency_links to jsonobject.egg-info/dependency_links.txt
writing requirements to jsonobject.egg-info/requires.txt
writing top-level names to jsonobject.egg-info/top_level.txt
reading manifest file 'jsonobject.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
adding license file 'LICENSE'
writing manifest file 'jsonobject.egg-info/SOURCES.txt'
running build_ext
copying build/lib.macosx-14.0-arm64-cpython-312/jsonobject/api.cpython-312-darwin.so -> jsonobject
copying build/lib.macosx-14.0-arm64-cpython-312/jsonobject/base.cpython-312-darwin.so -> jsonobject
copying build/lib.macosx-14.0-arm64-cpython-312/jsonobject/base_properties.cpython-312-darwin.so -> jsonobject
copying build/lib.macosx-14.0-arm64-cpython-312/jsonobject/containers.cpython-312-darwin.so -> jsonobject
copying build/lib.macosx-14.0-arm64-cpython-312/jsonobject/properties.cpython-312-darwin.so -> jsonobject
copying build/lib.macosx-14.0-arm64-cpython-312/jsonobject/utils.cpython-312-darwin.so -> jsonobject
test_default_conversions (test.test_stringconversions.StringConversionsTest.test_default_conversions) ... ok
test_nested_1 (test.test_stringconversions.StringConversionsTest.test_nested_1) ... ok
test_nested_2 (test.test_stringconversions.StringConversionsTest.test_nested_2) ... ok
test_no_conversions (test.test_stringconversions.StringConversionsTest.test_no_conversions) ... ok
test_update_properties (test.test_stringconversions.StringConversionsTest.test_update_properties) ... ok
test_basic (test.test_couchdbkit.CouchdbkitTestCase.test_basic) ... ok
test_large (test.test_couchdbkit.CouchdbkitTestCase.test_large) ... ok
test_medium (test.test_couchdbkit.CouchdbkitTestCase.test_medium) ... ok
test_multimedia_map (test.test_couchdbkit.CouchdbkitTestCase.test_multimedia_map) ... ok
test_assignment (test.tests.DynamicConversionTestCase.test_assignment) ... ok
test_change_type (test.tests.DynamicConversionTestCase.test_change_type) ... ok
test_kwargs (test.tests.DynamicConversionTestCase.test_kwargs) ... ok
test_manipulation (test.tests.DynamicConversionTestCase.test_manipulation) ... ok
test_properties (test.tests.DynamicConversionTestCase.test_properties) ... ok
test_wrapping (test.tests.DynamicConversionTestCase.test_wrapping) ... ok
test_default (test.tests.IntegerTest.test_default) ... ok
test_init_zero (test.tests.IntegerTest.test_init_zero) ... ok
test_set_zero (test.tests.IntegerTest.test_set_zero) ... ok
test_access_to_descriptor (test.tests.JsonObjectTestCase.test_access_to_descriptor) ... ok
test_bad_wrap (test.tests.JsonObjectTestCase.test_bad_wrap) ... ok
test_choices (test.tests.JsonObjectTestCase.test_choices) ... ok
test_competing_names (test.tests.JsonObjectTestCase.test_competing_names) ... ok
test_default (test.tests.JsonObjectTestCase.test_default) ... ok
test_delete_dynamic (test.tests.JsonObjectTestCase.test_delete_dynamic) ... ok
test_dict_clear (test.tests.JsonObjectTestCase.test_dict_clear) ... ok
test_dynamic_container (test.tests.JsonObjectTestCase.test_dynamic_container) ... ok
test_dynamic_dict_property (test.tests.JsonObjectTestCase.test_dynamic_dict_property)
dates copied from couchdbkit ... ok
test_dynamic_properties (test.tests.JsonObjectTestCase.test_dynamic_properties) ... ok
test_float (test.tests.JsonObjectTestCase.test_float) ... ok
test_init (test.tests.JsonObjectTestCase.test_init) ... ok
test_long (test.tests.JsonObjectTestCase.test_long) ... ok
test_mapping (test.tests.JsonObjectTestCase.test_mapping) ... ok
test_name (test.tests.JsonObjectTestCase.test_name) ... ok
test_object_property_with_lambda (test.tests.JsonObjectTestCase.test_object_property_with_lambda) ... ok
test_pickle (test.tests.JsonObjectTestCase.test_pickle) ... ok
test_recursive_validation (test.tests.JsonObjectTestCase.test_recursive_validation) ... ok
test_required (test.tests.JsonObjectTestCase.test_required) ... ok
test_string_list_property (test.tests.JsonObjectTestCase.test_string_list_property) ... ok
test_string_list_property_deepcopy (test.tests.JsonObjectTestCase.test_string_list_property_deepcopy) ... ok
test_typed_dict_of_dict (test.tests.JsonObjectTestCase.test_typed_dict_of_dict) ... ok
test_wrap (test.tests.JsonObjectTestCase.test_wrap) ... ok
test_dict (test.tests.LazyValidationTest.test_dict) ... ok
test_list (test.tests.LazyValidationTest.test_list) ... ok
test_list_plus_equals (test.tests.LazyValidationTest.test_list_plus_equals) ... ok
test_list_update_by_index (test.tests.LazyValidationTest.test_list_update_by_index) ... ok
test_object (test.tests.LazyValidationTest.test_object) ... ok
test_schema_list_update_by_index (test.tests.LazyValidationTest.test_schema_list_update_by_index) ... ok
test_string (test.tests.LazyValidationTest.test_string) ... ok
test_default_is_required (test.tests.PropertyInsideContainerTest.test_default_is_required) ... ok
test_property (test.tests.PropertyInsideContainerTest.test_property) ... ok
test_property_class_required (test.tests.PropertyInsideContainerTest.test_property_class_required) ... ok
test_required_property (test.tests.PropertyInsideContainerTest.test_required_property) ... ok
test_allow_dynamic (test.tests.PropertyTestCase.test_allow_dynamic) ... ok
test_attribute_error (test.tests.PropertyTestCase.test_attribute_error) ... ok
test_date (test.tests.PropertyTestCase.test_date) ... ok
test_datetime (test.tests.PropertyTestCase.test_datetime) ... ok
test_decimal (test.tests.PropertyTestCase.test_decimal) ... ok
test_descriptor (test.tests.PropertyTestCase.test_descriptor) ... ok
test_dict (test.tests.PropertyTestCase.test_dict) ... ok
test_dict_pop (test.tests.PropertyTestCase.test_dict_pop) ... ok
test_dict_popitem (test.tests.PropertyTestCase.test_dict_popitem) ... ok
test_dict_setdefault (test.tests.PropertyTestCase.test_dict_setdefault) ... ok
test_dict_update (test.tests.PropertyTestCase.test_dict_update) ... ok
test_exclude_if_none (test.tests.PropertyTestCase.test_exclude_if_none) ... ok
test_key_error (test.tests.PropertyTestCase.test_key_error) ... ok
test_time (test.tests.PropertyTestCase.test_time) ... ok
test_typed_dict (test.tests.PropertyTestCase.test_typed_dict) ... ok
test_exact (test.tests.TestExactDateTime.test_exact) ... /Users/nickbaum/jsonobject/test/tests.py:898: DeprecationWarning: datetime.datetime.utcnow() is deprecated and scheduled for removal in a future version. Use timezone-aware objects to represent datetimes in UTC: datetime.datetime.now(datetime.UTC).
  date = datetime.datetime.utcnow()
ok
test_deep_copy (test.tests.TestJsonArray.test_deep_copy) ... ok
test_init_with_list (test.tests.TestJsonArray.test_init_with_list) ... ok
test_init_with_none (test.tests.TestJsonArray.test_init_with_none) ... ok
test_init_with_str (test.tests.TestJsonArray.test_init_with_str) ... ok
test_single_arg_constructor_with_generator (test.tests.TestJsonArray.test_single_arg_constructor_with_generator) ... ok
test_single_arg_constructor_with_list (test.tests.TestJsonArray.test_single_arg_constructor_with_list) ... ok
test (test.tests.TestReadmeExamples.test) ... ok

----------------------------------------------------------------------
Ran 75 tests in 0.041s

OK

@nickbaum
Copy link
Contributor Author

@dannyroberts I imagine you've got a lot going on, but any chance you have a moment to take a look at this pull request?

I'm hopeful that I've done everything I can to make this easy and low risk for you 🤞🏻... but let me know if there's anything else you want me to do.

As mentioned, the one thing missing is incrementing the version number of jsonobject itself, since I figured you'd prefer to do that yourself.

Context:

  • This is a small change to make jsonobject compatible with Python 3.12
  • Taxjar depends on jsonobject
  • We depend on taxjar for all our sales tax calculations
  • ... so we can't upgrade to Python 3.12 until jsonobject is updated

Again, I know that maintaining an open source project can be a thankless task, so let us know how we can help.

@nickbaum
Copy link
Contributor Author

Whoops, I just realized Tammy already pinged you on the related issue. Sorry for the double notification 😅

@gherceg
Copy link
Contributor

gherceg commented Sep 2, 2024

Hey @nickbaum, apologies for the delayed response and thanks for the contribution.

It looks like in addition to the assertRaisesRegex change, you pushed changes to the .c files due to generating them with a newer version of cython. I'm assuming that is out of scope of the necessary changes to support python 3.12. Is that correct? And if so, could you regenerate those files based on the cython requirement specified in setup.py.

I'll be looking closer at this in the coming week and will be sure to provide any updates here. Thanks again for your patience.

@nickbaum
Copy link
Contributor Author

nickbaum commented Sep 3, 2024

And if so, could you regenerate those files based on the cython requirement specified in setup.py.

Thanks so much for the response, and for catching that.

I just updated the pull request to use the same Cython version (0.29.35) as the currently checked in files, which as you suspected removed any changes to the c files.

@nickbaum
Copy link
Contributor Author

nickbaum commented Sep 4, 2024

@gherceg Hi Graham, the tests now fail because the checked in c files are built with cython 0.29.35, while the latest version of cython compatible with setup.py is 0.29.37.

I created a separate pull request to rebuild the c files using cython 0.29.37.

I've also merged that change into this pull request, so the tests pass again.

Once you've merged the Cython 0.29.37 pull request, the diff for the c files should disappear from this pull request.

@gherceg
Copy link
Contributor

gherceg commented Sep 9, 2024

@nickbaum we just released 2.2.0 which supports 3.12. Thanks again for your contributions!

@gherceg gherceg closed this Sep 9, 2024
@nickbaum
Copy link
Contributor Author

nickbaum commented Sep 9, 2024

Fantastic, thanks so much for taking the time to review this 🙏🏻

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