The Python project template I think of.

Here's a Python project template I think of. I have never actually formed a team to develop a project, so I don't know the site. ** Please let us know if you have any suggestions.

Directory structure

First is the structure of the directory. The name when importing with Python will be modulename. There is no need to prepare build or venv, but build is created to encourage the use of setup.py, and venv is created to encourage the use of virtualenv. You may write these in the README.md.

Direcotry


Project\
    modulename\
        hoge.py
    build\
    test\
        test_hoge.py
    docs\
    venv\
    requirements.txt
    setup.py
    LICENCSE
    README.md
    MANIFEST.in

requirements.txt Let's export the development environment to requirements.txt.

pip3 freeze > requirements.txt
# install : pip3 install -r requirements.txt

setup.py

setup.py


#!/usr/bin/env python3
# coding:utf-8

from setuptools import setup

setup(name='Hoge_Project',
      version='0.0.1',
      description='Python Hoge_Project.',
      author='spam',
      author_email='[email protected]',
      url='http://hoge.com',
      packages=['modulename'],
      #install_requires=['hoge','spam','hoge_spam'],
    )

Postscript: 2016/08/23

MANIFEST.in Since hatchinee pointed out, I will add it. If you use setup.py when packaging, by default only the python source files will be added. Therefore, when packaging, files other than python must be explicitly specified.

#Packaging
python setup.py sdist   
#or 
python setup.py bdist_wheel

MANIFEST.in


include MANIFEST.in                                                                                                                
include *.txt                                                                                                                      
# Top-level                                                                                                                        
include setup.py README.md LICENCSE                                                                                                                 
# All-source file                                                                                                                  
recursive-include modulename *                                                                                                     
# All documentation                                                                                                                
recursive-include docs *
# Exclude what we don't want to include
global-exclude *.pyc *~ *.bak *.swp *.pyo

-About Python packaging

It's easy, but that's it.

Recommended Posts

The Python project template I think of.
I didn't know the basics of Python
the zen of Python
Try the free version of Progate [Python I]
Template of python script to read the contents of the file
Towards the retirement of Python2
Around the installation of the Python project management framework Trac
About the ease of Python
I checked out the versions of Blender and Python
I tried using the API of the salmon data project
Tasks at the start of a new python project
About the features of Python
I downloaded the python source
The Power of Pandas: Python
I tried to summarize the string operations of Python
I tried to find the entropy of the image with python
I tried "gamma correction" of the image with Python + OpenCV
I tried the accuracy of three Stirling's approximations in python
I just changed the sample source of Python a little.
I wrote the basic grammar of Python with Jupyter Lab
I evaluated the strategy of stock system trading with Python.
What I learned by solving 30 questions of python Project Euler
[Python] I tried to visualize the follow relationship of Twitter
I want to know the features of Python and pip
[Python] I tried collecting data using the API of wikipedia
The story of Python and the story of NaN
[Python] The stumbling block of import
I investigated the mechanism of flask-login!
Existence from the viewpoint of Python
Change the Python version of Homebrew
Review of the basics of Python (FizzBuzz)
I wrote the queue in Python
About the basics list of Python basics
I wrote the stack in Python
Learn the basics of Python ① Beginners
I compared the speed of Hash with Topaz, Ruby and Python
I tried scraping the ranking of Qiita Advent Calendar with Python
I compared the calculation time of the moving average written in Python
[Python] I wrote the route of the typhoon on the map using folium
I want to output the beginning of the next month with Python
[Python] I thoroughly explained the theory and implementation of logistic regression
I wrote the code to write the code of Brainf * ck in python
I made AI think about the lyrics of Kenshi Yonezu (pre-processing)
[Python] I thoroughly explained the theory and implementation of decision trees
[Super basics of Python] I learned the basics of the basics, so I summarized it briefly.
I made AI think about the lyrics of Kenshi Yonezu (implementation)
I tried to improve the efficiency of daily work with Python
I checked the contents of docker volume
Change the length of Python csv strings
I tried the asynchronous server of Django 3.0
Check the behavior of destructor in Python
[Python3] Understand the basics of Beautiful Soup
Pass the path of the imported python module
The story of making Python an exe
Learning notes from the beginning of Python 1
Check the existence of the file with python
About the virtual environment of python version 3.7
[Python] Understand the content of error messages
[Python3] Rewrite the code object of the function
The result of installing python in Anaconda
[Python] Try pydash of the Python version of lodash