0

I have a directory structure like this MyStuff with an __init__.py in it However I want my package to be This.is.MyStuff however I cannot actually move my code from the directory MyStuff for various reasons.

Is there a way to tell python even though I am in the directory MyStuff that the package I really am is This.is.MyStuff?

=== Edit for clarity ===

My directory structure looks like this:

main/ (This is an aggregate repository)
├── plugins/
│   └── MyStuff (This is our repository)
│       ├── __init__.py
│       └── code.py
├── App/ (This is actually an external repository)
│   └── This
│       ├── __init__.py
│       ├── code.py
│       └── is
│           ├── __init__.py
│           ├── code.py
│           └── TheirStuff
│               ├── __init__.py
│               └── code.py
└── OtherStuff

I dont want to create new sub directories because will be disruptive across all of our branches and install processes. I know the most correct answer is change plugins to have a direcotry This/is/MyStuff but I dont want to do that. So I am looking for how to make the MyStuff Package be the This.is.MyStuff without moving every file.

Jim
  • 2,034
  • 2
  • 15
  • 29
  • 1
    Does ``This`` and ``This/is`` actually exist? Is ``MyStuff`` the executable, or is it imported as ``MyStuff`` or ``This.is.MyStuff`` first? – MisterMiyagi Mar 22 '21 at 15:19
  • It is imported as `This.is.MyStuff` the package `This.is` exists but in another project – Jim Mar 22 '21 at 16:30
  • 1
    Could you please provide a tree structure of your project? See [use powershell to generate a list of files and directories](https://stackoverflow.com/questions/27447014/use-powershell-to-generate-a-list-of-files-and-directories) or [how to use tree command](https://www.tutorialspoint.com/how-to-use-the-tree-command-in-powershell) for an example on how to make one. This makes it easier for us to understand what you want. – Thymen Mar 22 '21 at 16:55
  • Note that if there is a pre-existing package ``This.is``, a [namespace package](https://packaging.python.org/guides/packaging-namespace-packages/) might be appropriate for your use-case. – MisterMiyagi Mar 22 '21 at 16:57
  • @ThymenI edited this for show the directory structure to better explain the problem. – Jim Mar 24 '21 at 12:45
  • @MisterMiyagi Not sure how to employ namespace to solve this – Jim Mar 24 '21 at 12:46

0 Answers0