-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Execute python code before parsing setup.cfg #2467
Comments
@rickstaa you cannot put Python code in Also, do you know about the |
As webknjaz said, a |
@webknjaz Thanks a lot for your explanation! The solution works when I keep both a Just out of curiosity after your comment, I also tried achieving the same behaviour using the find_namespace: directive. I, however, was not able to find the right [options]
include_package_data = True
packages=find_namespace:
[options.packages.find]
where=
.
./main_package/stand_alone_subpackage/stand_alone_subpackage
exclude=
main_package.stand_alone_subpackage
include=
main_package.stand_alone_subpackage.stand_alone_subpackage But this doesn't seem to work because of the following reasons. An example repository of the things I tried can be found here. First as far as I understand it the where option doesn't support a list of paths. Further, although the exclude and include keywords work, they do not provide a way to change the import namespace. I, therefore, don't think I can achieve the desired setup without using the additional logic that is added to the ├── stand_alone_subpackage_1
│ ├── main_package
│ │ └── submodule_1
│ │ └── __init__.py
│ └── setup.py
└── stand_alone_subpackage_1
├── main_package
│ └── submodule_2
│ └── __init__.py
└── setup.py This would, however make the GitHub folder structure more complicated. I, therefore, came to the following conclusions:
@webknjaz and @nschloe If you could let me know if you think my conclusions are correct, I would be very grateful! I really appreciate any help you can provide. @nschloe Also thanks a lot for the example repository and telling me that such a setup is not unusual. I need C++ sources in a further stage of my project, so I think the repository is very helpful. |
Sounds about right |
@webknjaz Amazing thanks a lot! I will close the issue for now! |
I'm currently trying to make my python packages PEP517/518 compatible. For this, I'm replacing the
setup.py
with asetup.cfg
file and aproject.toml
file. This was quite straightforward to do for most of my packages, but for one package, I was not able to do this translation.Package description
The package in question contains a (parent) python package that includes several packages that can also be installed as stand-alone python packages. For this, I created the following project structure:
I use the following
setup.py
file to install the subpackage in the parent package while getting rid of the redundantstand_alone_subpackage
namespace.Why this works can be found inside a StackOverflow question I opened some months ago. The main thing it does is adds the virtual shortened modules to the
PACKAGES
andPACKAGES_DIR
variables. This way the
PythonClassinside the
standalone_subpackage` can be imported using the following import command:Translated setup.py file
I translated the setup.py to the following
setup.cfg
file:I, however, did not yet find a way to inject the extra virtual (shortened) modules before the
packages = find:
command is parsed. One possible way would be to read the PACKAGES and PACKAGE_DIR variables from a file. This would be similar to using thefile:
andattr:
arguments for the package version parameter. While doing so, this file has to be created before thesetup.cfg
file is parsed. I, however, did not find a way to do this in setuptools 50.3.2. My question is, therefore, does anybody know a way of achieving the more complicated setup procedure I am trying to achieve?Update
I just found out that you can combine both the
setup.cfg
andsetup.py
code. This allows me to define most of the setup information inside thesetup.cfg
file while keeping thepackages
andpackage_dir
arguments inside thesetup.py
file. This allows me to inject the virtual shortened modules inside thesetup.py
file. I currently use the followingsetup.py
file:If anybody knows if it is possible to put everything inside the
setup.cfg
file please let me know. Thanks a lot in advance!The text was updated successfully, but these errors were encountered: