0

I have a Django app developed as part of my existing Django site that I'd like to separate out and publish on PyPI. What folder structure is required to make the app suitable for publishing to PyPI and importable via pip?

Current folder structure (truncated):

mysite/
- conf/
- mysite/
  - __init__.py
  - settings.py
- myapp/
  - __init__.py
  - admin.py
  - models.py
- manage.py
lofidevops
  • 15,528
  • 14
  • 79
  • 119

2 Answers2

0

Per the Packaging your app section of Advanced tutorial: How to write reusable apps you need to make a new parent folder for your app (outside the Django project) and move your app folder there:

mysite/
- conf/
- mysite/
  - __init__.py
  - settings.py
- <-- removed here
- manage.py

django-myapp/
- myapp/ <-- inserted here
  - __init__.py
  - admin.py
  - models.py
- setup.py

The folder structure is now publishable. (You still need to add setup.py and the other files required for PyPI packaging and pip installation.)

lofidevops
  • 15,528
  • 14
  • 79
  • 119
-1

Following Django tutorials on main page you probabily will have this structure, keep in mind some paths is required since overrides django framework like static, migrations, templates... but about your application you can make some changes but you will have to handle it manualy

mysite/
    manage.py
    mysite/
        __init__.py
        settings.py
        urls.py
        wsgi.py
    polls/
        __init__.py
        admin.py
        migrations/
            __init__.py
            0001_initial.py
        models.py
        static/
            polls/
                images/
                    background.gif
                style.css
        templates/
            polls/
                detail.html
                index.html
                results.html
        tests.py
        urls.py
        views.py
    templates/
        admin/
            base_site.html

https://docs.djangoproject.com/en/2.0/intro/reusable-apps/

Diego Vinícius
  • 2,125
  • 1
  • 12
  • 23