Skip to content

Commit 9177c64

Browse files
committed
Python: Migrate to use "implicit namespace packages" (PEP 420)
... instead of "declared namespaces" for the `crate` namespace package, see PEP 420 [1], and setuptools docs [2]. > Historically, there were two methods to create namespace packages. One > is the `pkg_resources` style supported by `setuptools` and the other > one being `pkgutils` style offered by `pkgutils` module in Python. > Both are now considered _deprecated_. > > -- Legacy Namespace Packages [3] [1] https://peps.python.org/pep-0420/ [2] https://setuptools.pypa.io/en/latest/references/keywords.html#keyword-namespace-packages [3] https://setuptools.pypa.io/en/latest/userguide/package_discovery.html#legacy-namespace-packages
1 parent 7f3244e commit 9177c64

File tree

4 files changed

+6
-35
lines changed

4 files changed

+6
-35
lines changed

CHANGES.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,12 @@ Unreleased
1717
- Error handling: At two spots in cursor / value converter handling, where
1818
``assert`` statements have been used, ``ValueError`` exceptions are raised
1919
now.
20+
- Python: Migrated to use "implicit namespace packages" instead of "declared
21+
namespaces" for the ``crate`` namespace package, see `PEP 420`_.
2022

2123

2224
.. _Migrate from crate.client to sqlalchemy-cratedb: https://cratedb.com/docs/sqlalchemy-cratedb/migrate-from-crate-client.html
25+
.. _PEP 420: https://peps.python.org/pep-0420/
2326
.. _sqlalchemy-cratedb: https://pypi.org/project/sqlalchemy-cratedb/
2427

2528

setup.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
import os
2323
import re
2424

25-
from setuptools import find_packages, setup
25+
from setuptools import find_namespace_packages, setup
2626

2727

2828
def read(path):
@@ -45,15 +45,14 @@ def read(path):
4545
url="https://github.com/crate/crate-python",
4646
author="Crate.io",
4747
author_email="[email protected]",
48-
package_dir={"": "src"},
4948
description="CrateDB Python Client",
5049
long_description=long_description,
5150
long_description_content_type="text/x-rst",
5251
platforms=["any"],
5352
license="Apache License 2.0",
5453
keywords="cratedb db api dbapi database sql http rdbms olap",
55-
packages=find_packages("src"),
56-
namespace_packages=["crate"],
54+
packages=find_namespace_packages("src"),
55+
package_dir={"": "src"},
5756
install_requires=[
5857
"urllib3",
5958
"verlib2",

src/crate/__init__.py

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +0,0 @@
1-
# -*- coding: utf-8; -*-
2-
#
3-
# Licensed to CRATE Technology GmbH ("Crate") under one or more contributor
4-
# license agreements. See the NOTICE file distributed with this work for
5-
# additional information regarding copyright ownership. Crate licenses
6-
# this file to you under the Apache License, Version 2.0 (the "License");
7-
# you may not use this file except in compliance with the License. You may
8-
# obtain a copy of the License at
9-
#
10-
# http://www.apache.org/licenses/LICENSE-2.0
11-
#
12-
# Unless required by applicable law or agreed to in writing, software
13-
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
14-
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
15-
# License for the specific language governing permissions and limitations
16-
# under the License.
17-
#
18-
# However, if you have executed another commercial license agreement
19-
# with Crate these terms will supersede the license and you may use the
20-
# software solely pursuant to the terms of the relevant commercial agreement.
21-
22-
# this is a namespace package
23-
try:
24-
import pkg_resources
25-
26-
pkg_resources.declare_namespace(__name__)
27-
except ImportError:
28-
import pkgutil
29-
30-
__path__ = pkgutil.extend_path(__path__, __name__)

src/crate/testing/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +0,0 @@
1-
# package

0 commit comments

Comments
 (0)