Have several packages share the same file placed in a different folder - and how to correctly build the package?

Viewed 24

I currently have several packages with this structure (showing only 2 here)

├── package1
│   ├── setup.py
│   ├── package1
│       ├── __init__.py
|       ├── main.py
|       ├── abstract_classes.py
├── package2
│   ├── setup.py
│   ├── package2
│       ├── __init__.py
|       ├── main.py
|       ├── abstract_classes.py

Each package contains the file abstract_classes.py, which contains abstract classes which are inherited by the specific classes of each package. This file must be the same for each package. However, since I also need to ship the packages individually to pypi, I ended up making local copies of this file in each package folder, which is particularly annoying because if I make a change I need to make sure to copy the file in all the other directories.

Is there a way to keep only one copy of abstract_classes.py, for example in the top directory, and then add some instructions (maybe in the setup.py file?) to make sure that abstract_classes.py is retrieved when the package is being built and shipped to pypi? Or do you think it would be better to create a separate package just for the abstract_classes.py file?

0 Answers
Related