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

Added pypi package de-autobahn from autogeneration as extra dependency #47

Merged
merged 8 commits into from
Nov 28, 2021

Conversation

wirthual
Copy link
Member

@wirthual wirthual commented Nov 25, 2021

Used native namespace package for deutschland. This needed some refactoring of the imports since there is no init.py in the top level anymore (which imported all the subpackages, I think this is a bad idea for a growing package anyways) --> https://packaging.python.org/guides/packaging-namespace-packages/

Also put everything in a src folder and I swtiched from setup.py to pyproject.toml, because otherwise I could not make the namespace work (https://docs.pytest.org/en/latest/explanation/goodpractices.html).

The extra package which is called de-autobahn (since only autobahn was already taken) is here:
https://pypi.org/project/de-autobahn/

So if you install the deutschland package and you want to use the autobahn api you can use:
pip install deutschland[autobahn] which will give you the additional installed package which you can import "from deutschland import autobahn" as if it would be part of the regular package

In poetry this would look like:
poetry add deutschland -E autobahn

which should give an entry in the pyproject.toml like this:
deutschland = {version = "^1.0.4",extras=["autobahn"]}

If we want to switch to having it installed by default, we would just to remove the extra section from pyproject.toml and remove the option=true parameters.

If you want to test it:
python -c "from deutschland.autobahn.apis import DefaultApi;print(DefaultApi().list_autobahnen()['roads'][:4])"

should work as well as

poetry run python -c "from deutschland.verena import Verena"

which means the namespace packaging seems to work.

If you want to isntall the package from local source with autobahn support, you should be able to use:
pip install .[autobahn]

@LilithWittmann LilithWittmann merged commit 2f8475f into bundesAPI:main Nov 28, 2021
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