docs: some documentation/thoughts on properly implementing overlay packages
This commit is contained in:
parent
a843407e40
commit
f30d9b5b5b
12 changed files with 237 additions and 0 deletions
4
doc/overlays/install_packages.sh
Executable file
4
doc/overlays/install_packages.sh
Executable file
|
@ -0,0 +1,4 @@
|
|||
#!/bin/bash
|
||||
set -eux
|
||||
pip3 install --user -e overlay/
|
||||
pip3 install --user -e main/
|
17
doc/overlays/main/setup.py
Normal file
17
doc/overlays/main/setup.py
Normal file
|
@ -0,0 +1,17 @@
|
|||
from setuptools import setup, find_namespace_packages # type: ignore
|
||||
|
||||
|
||||
def main() -> None:
|
||||
pkgs = find_namespace_packages('src')
|
||||
pkg = min(pkgs)
|
||||
setup(
|
||||
name='hpi-main',
|
||||
zip_safe=False,
|
||||
packages=pkgs,
|
||||
package_dir={'': 'src'},
|
||||
package_data={pkg: ['py.typed']},
|
||||
)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
0
doc/overlays/main/src/my/py.typed
Normal file
0
doc/overlays/main/src/my/py.typed
Normal file
11
doc/overlays/main/src/my/reddit.py
Normal file
11
doc/overlays/main/src/my/reddit.py
Normal file
|
@ -0,0 +1,11 @@
|
|||
print(f'[main] {__name__} hello')
|
||||
|
||||
|
||||
def upvotes() -> list[str]:
|
||||
return [
|
||||
'reddit upvote1',
|
||||
'reddit upvote2',
|
||||
]
|
||||
|
||||
|
||||
trigger_mypy_error: str = 123
|
7
doc/overlays/main/src/my/twitter/all.py
Normal file
7
doc/overlays/main/src/my/twitter/all.py
Normal file
|
@ -0,0 +1,7 @@
|
|||
print(f'[main] {__name__} hello')
|
||||
|
||||
from .common import merge
|
||||
|
||||
def tweets() -> list[str]:
|
||||
from . import gdpr
|
||||
return merge(gdpr)
|
11
doc/overlays/main/src/my/twitter/common.py
Normal file
11
doc/overlays/main/src/my/twitter/common.py
Normal file
|
@ -0,0 +1,11 @@
|
|||
print(f'[main] {__name__} hello')
|
||||
|
||||
from typing import Protocol
|
||||
|
||||
class Source(Protocol):
|
||||
def tweets(self) -> list[str]:
|
||||
...
|
||||
|
||||
def merge(*sources: Source) -> list[str]:
|
||||
from itertools import chain
|
||||
return list(chain.from_iterable(src.tweets() for src in sources))
|
9
doc/overlays/main/src/my/twitter/gdpr.py
Normal file
9
doc/overlays/main/src/my/twitter/gdpr.py
Normal file
|
@ -0,0 +1,9 @@
|
|||
print(f'[main] {__name__} hello')
|
||||
|
||||
def tweets() -> list[str]:
|
||||
return [
|
||||
'gdpr tweet 1',
|
||||
'gdpr tweet 2',
|
||||
]
|
||||
|
||||
trigger_mypy_error: str = 123
|
17
doc/overlays/overlay/setup.py
Normal file
17
doc/overlays/overlay/setup.py
Normal file
|
@ -0,0 +1,17 @@
|
|||
from setuptools import setup, find_namespace_packages # type: ignore
|
||||
|
||||
|
||||
def main() -> None:
|
||||
pkgs = find_namespace_packages('src')
|
||||
pkg = min(pkgs)
|
||||
setup(
|
||||
name='hpi-overlay',
|
||||
zip_safe=False,
|
||||
packages=pkgs,
|
||||
package_dir={'': 'src'},
|
||||
package_data={pkg: ['py.typed']},
|
||||
)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
0
doc/overlays/overlay/src/my/py.typed
Normal file
0
doc/overlays/overlay/src/my/py.typed
Normal file
8
doc/overlays/overlay/src/my/twitter/all.py
Normal file
8
doc/overlays/overlay/src/my/twitter/all.py
Normal file
|
@ -0,0 +1,8 @@
|
|||
print(f'[overlay] {__name__} hello')
|
||||
|
||||
from .common import merge
|
||||
|
||||
def tweets() -> list[str]:
|
||||
from . import gdpr
|
||||
from . import talon
|
||||
return merge(gdpr, talon)
|
9
doc/overlays/overlay/src/my/twitter/talon.py
Normal file
9
doc/overlays/overlay/src/my/twitter/talon.py
Normal file
|
@ -0,0 +1,9 @@
|
|||
print(f'[overlay] {__name__} hello')
|
||||
|
||||
def tweets() -> list[str]:
|
||||
return [
|
||||
'talon tweet 1',
|
||||
'talon tweet 2',
|
||||
]
|
||||
|
||||
trigger_mypy_error: str = 123
|
Loading…
Add table
Add a link
Reference in a new issue