Two packages but only one setupc.cfg #3566
-
I'm using the But I was wandering if it is possible to use one
When I do Of course I still tried and it doesn't work because you can not have two Is there a way to handle that? I want to have A and B in the same repo. There is no way to separate them. |
Beta Was this translation helpful? Give feedback.
Replies: 6 comments 1 reply
-
@Codeberg-AsGithubAlternative-buhtz what is the error message you are seeing? (And could you share the relevant parts of your configuration file?) In the Python packaging ecosystem the terminology is a bit abused, but for the sake of simplicity let's say that in one distribution (the stuff that you upload to PyPI) can have multiple importable packages. So theoretically there is nothing forbidding you to do that. Of course it all depends on what you have added to your configuration files... |
Beta Was this translation helpful? Give feedback.
-
Thank you for your quick reply. My apologize for that broad question. It wasn't clear for me what I really want. 😄 This is the repo structure with two folders in the
I know that config is not well but it gives an idea of my goal I hope:
Now I "install" it.
The output is not what I want. I would like to see something like this
OK but
I don't want to hack something. If setuptools is not designed for something like this I will use another way. Maybe it was a stupid idea of an inexperienced python "developer". For example I simply could create two totally separate repositories
Or I could use subpackages:
|
Beta Was this translation helpful? Give feedback.
-
Thank you very much for sharing part of your config. I think I have an idea what is happening with the imports. If you don't have a package_dir =
bit = src/bit
qt = src/qt The easiest way to deal with that is to replace it with the equivalent: package_dir =
= src # Yes, the value starts with an `=` character Alternatively you can also add a [build-system]
requires = ["setuptools"]
build-backend = "setuptools.build_meta"
# or "setuptools.build_meta:__legacy__" if you need to import something
# from your local folders in your `setup.py` file. If you do at least one of these changes you should be able to import both packages.
The output of the Think about This |
Beta Was this translation helpful? Give feedback.
-
I think I understand the difference between a distribution (represented by a whl file) and a package inside that distribution. As you described I would say choosing So I tried but still have problems. But maybe I didn't understood all of your advice's. The
The
The usual
I can not Solution (?)I played a bit around and poked in the dark The
The
|
Beta Was this translation helpful? Give feedback.
-
You can use both at the same time. To be honest, with the configuration you are showing, things should be working. I can demonstrate that by running the following commands: rm -rf /tmp/cliqt_demo
mkdir -p /tmp/cliqt_demo/src/bit
mkdir -p /tmp/cliqt_demo/src/qt
touch /tmp/cliqt_demo/src/bit/__init__.py
touch /tmp/cliqt_demo/src/qt/__init__.py
cd /tmp/cliqt_demo
cat <<EOF > setup.cfg
[metadata]
name = bit
[options]
packages =
bit
qt
package_dir =
bit = src/bit
qt = src/qt
EOF
cat <<EOF > setup.py
from setuptools import setup
setup()
EOF
cat <<EOF > pyproject.toml
[build-system]
requires = ["setuptools"]
build-backend = "setuptools.build_meta"
EOF
python3 -m venv .venv
.venv/bin/python -m pip install -U pip
.venv/bin/python -m pip install -e .
.venv/bin/python -c 'import bit, qt; print(bit, qt)'
# Will output:
# <module 'bit' from '/tmp/cliqt_demo/src/bit/__init__.py'> <module 'qt' from '/tmp/cliqt_demo/src/qt/__init__.py'> Maybe something is getting cached?
Some things fields can be dynamically derived via
|
Beta Was this translation helpful? Give feedback.
-
I opened a separate but related question (#3725) about using |
Beta Was this translation helpful? Give feedback.
You can use both at the same time. To be honest, with the configuration you are showing, things should be working. I can demonstrate that by running the following commands: