googleapis / python-spanner-sqlalchemy

Apache License 2.0
38 stars 28 forks source link

feat: Introduce compatibility with native namespace packages #375

Open parthea opened 7 months ago

parthea commented 7 months ago

This PR:

To obtain the version at runtime, use google.cloud.sqlalchemy_spanner.__version__

(py39) partheniou@partheniou-vm-3:~/git/python-spanner-sqlalchemy$ python3
Python 3.9.16 (main, Mar  2 2023, 17:52:22) 
[GCC 12.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import google.cloud.sqlalchemy_spanner 
>>> google.cloud.sqlalchemy_spanner.__version__
'1.6.2'

Fixes #337 🦕

parthea commented 7 months ago

Adding do not merge as there is an upcoming release freeze. This should be merged after the release freeze ends on November 29th.

harshachinta commented 5 months ago

Hi @parthea, The python-spanner-sqlalchemy presubmits are failing with below error after the latest 3.41.0 release of python-spanner,

ModuleNotFoundError: No module named 'google.cloud.spanner_v1'

From my analysis below, it looks like this PR should be merged for the presubmits to not face this issue.

Analysis

  1. I wrote a sample Python application with python-spanner 3.41.0 as dependency (Assuming python-spanner release is the issue), but the application did not face this import issue and was working perfectly.
  2. This should be some issue with the python-spanner-sqlalchemy package setup. Analyzing more pointed out to this PR which is in draft stage. We did the same change in python-spanner in the latest release.
  3. I checked out this PR on my local and ran presubmits. The above import issue was not seen. I think we should merge this PR to have similar package setup as python-spanner.

cc: @ankiaga @olavloite

parthea commented 5 months ago

@harshachinta,

Please can you check if the issue is resolved with this PR which removes editable installations from tests? https://github.com/googleapis/python-spanner-sqlalchemy/pull/383

There are limitations for editable installations, and this type of installation is still listed as experimental on pypa.io: https://setuptools.pypa.io/en/latest/userguide/development_mode.html#limitations

We may be able to improve support for editable installations by switching to a src layout instead of a flat layout. https://github.com/googleapis/google-cloud-python/issues/12078