Skip to content

Commit 7a5cfef

Browse files
committed
Use pubtools namespace to resolve init file conflict [RHELDST-17607]
Currently, there's an issue with packaging where most of the pubtool-<lib> projects contains __init__.py and other stuff which is supposed to belong only to pubtools. Python namespaces are a convenient way to work around this issue.
1 parent 70a9b52 commit 7a5cfef

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+20
-5
lines changed

pubtools/__init__.py

-1
This file was deleted.

setup.py

+18-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,19 @@
1-
from setuptools import setup, find_packages
1+
from setuptools import setup
2+
3+
try:
4+
from setuptools import find_namespace_packages
5+
except ImportError:
6+
# Workaround for RHEL-8 RPM packaging that uses setuptools 39.2
7+
# find_namespace_packages is supported since setuptools 40.1
8+
# Loosely backported from https://github.com/pypa/setuptools/blob/main/setuptools/discovery.py
9+
from setuptools import PackageFinder
10+
11+
class PEP420PackageFinder(PackageFinder):
12+
@staticmethod
13+
def _looks_like_package(_path):
14+
return True
15+
16+
find_namespace_packages = PEP420PackageFinder.find
217

318

419
def get_description():
@@ -22,7 +37,8 @@ def get_requirements():
2237
setup(
2338
name="pubtools-pulplib",
2439
version="2.39.1",
25-
packages=find_packages(exclude=["tests"]),
40+
packages=find_namespace_packages(where="src"),
41+
package_dir={"": "src"},
2642
package_data={"pubtools.pulplib._impl.schema": ["*.yaml"]},
2743
url="https://github.com/release-engineering/pubtools-pulplib",
2844
license="GNU General Public License",
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

tox.ini

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ deps=
1313
pylint==2.7.2
1414
commands=
1515
black --check .
16-
sh -c 'pylint pubtools; test $(( $? & (1|2|4|32) )) = 0'
16+
sh -c 'pylint /src/pubtools/pulplib; test $(( $? & (1|2|4|32) )) = 0'
1717

1818
[testenv:pidiff]
1919
deps=pidiff
@@ -27,7 +27,7 @@ deps=
2727
pytest-timeout
2828
usedevelop=true
2929
commands=
30-
pytest -svv --timeout 60 --cov-report=html --cov-report=xml --cov=pubtools --cov-fail-under=100 {posargs}
30+
pytest -svv --timeout 60 --cov-report=html --cov-report=xml --cov=pubtools.pulplib --cov-fail-under=100 {posargs}
3131

3232
[testenv:lock]
3333
deps=

0 commit comments

Comments
 (0)