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

Question: Distribution Package with two Import Packages: Install only one Import Package #619

Closed
buhtz opened this issue Jan 6, 2023 · 1 comment

Comments

@buhtz
Copy link

buhtz commented Jan 6, 2023

This question was also asked on setuptools dicussion forum.
I know nothing then setuptools and now try to look around for alternatives that maybe able to solve my "problem".

I have a Distribution Package named bit_demo containing the two Import Packages bitcli and bitgui.

bit_demo
├── pyproject.toml
├── src
│   ├── bitcli
│   │   ├── __init__.py
│   │   └── __main__.py
│   └── bitgui
│       ├── __init__.py
│       └── __main__.py
└── tests
    ├── integration
    └── unit

When I install it via python3 -m pip install bit_demo I do have the two import packages in my system.

Would it be possible to install bit_demo but only with bitcli?
Can I install a distribution package excluding some of its import packages?

For example

python3 -m pip install bit_demo.bitcli

python3 -m pip install bit_demo  --exclude bit_demo.bitgui

Background of my question

I think about the distro maintainers (e.g. Debian, Arch) who need to create a deb file of my upstream repo.
There need to be two packages in the distro. When users only want to use the CLI interface without GUI (e.g. on a headless server) they would do apt install bitcli. But when they need it with GUI they would do apt install bitgui (and bitlic comes in as dependency).

Technically bitcli can live alone. But bitgui is useless alone because it use a lot of bitcli code. Because of that I don't think it would be a good idea to create two separate git repositories. I would prefer to keep them together as one repo/distribution package.

@takluyver
Copy link
Member

takluyver commented Jan 6, 2023

Like Sviatoslav said on the setuptools question, I'd approach this by making two separate packages on PyPI as well. Or install all of the code as one package, but have optional dependencies for the GUI (in this case, you would do something like pip install bit_demo[gui] to install with the GUI dependencies).

The specific thing you're asking about - installing only part of a Python package - is not possible with Flit, and it's not really supported by Python packaging in general. We normally publish wheels on PyPI: installing from a wheel is fast and simple, but you always get the whole thing installed. If you publish only sdists (no wheels), you can get some control over what happens at install time, but you're kind of fighting the tools - e.g. when pip finds an sdist it will build a wheel and cache that for later use. You probably don't want to be going against the tools like that.

@takluyver takluyver closed this as not planned Won't fix, can't repro, duplicate, stale Jan 21, 2023
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

No branches or pull requests

2 participants