An existing project is setup in a way that the repository has an __init__.py
in at the root folder. I would like to create a setup.py
in the repository so this would be the resulting project structure:
project-master/
├── __init__.py
├── setup.py
└── submodule1
├── code.py
└── __init__.py
└── submodule2
├── code.py
└── __init__.py
and you should be able to:
git clone project.url
cd project-master
pip install -e .
from project.submodule1 import ...
I tried the hacky solution of temporarily copying the contents in a subfolder so that setup.py
is one level up from the package folder and installing from there. This works well if I pip install.
but unfortunately this solution doesn't work in editable mode because I delete the temporary folder after installing.
Question : What is the right way to create a proper setup.py
that works in editable mode and lives in the same root folder as the package's __init__.py
?
This doesn't seem to be possible for an editable installation. As far as I know the closest one can get is as following:
project-master/
├── __init__.py
├── setup.py
└── submodule1
└── __init__.py
#!/usr/bin/env python3
import setuptools
setuptools.setup(
name='ProjectMaster',
version='0.0.0.dev0',
packages=['project', 'project.submodule'],
package_dir={
'project': '.',
'project.submodule': './submodule1',
},
)
Update
See the following for an idea how to use such a project in editable or develop mode: https://stackoverflow.com/a/58429242/11138259
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.