We assume that GitHub is used as the repository to store the project files and for version control purposes. The developer can create a GitHub account by following the instructions here. Install ‘git’ in your local machine (if not installed) by following the instructions here. To create a new Python repository, follow the workflow below:
1. Create an empty repository in GitHub (See here for an illustration).
2. Clone the repository in your local machine using the command:
git clone https://github.com/<your-github-id>/<project-name>.git
In the above, <your-github-id> and <project-name> must be replaced by your GitHub account id and the name of the Python repository created in the previous step.
3. Now it is important to have a good project structure. A common way to structure the project files is shown below:
<project-name>
|-- README.rst
|-- LICENSE
|-- setup.py
|-- requirements.txt
|-- CHANGES.txt
|-- <project-name>/tests
|-- docs/
README.rst: file with a brief description of the project and important links such as API reference, user manual, mailing list, etc.
LICENSE: file with full license text and copyright claims.
setup.py: file containing packaging and distribution related configuration.
requirements.txt: file specifying the dependencies required for testing, building and generating documentation.
CHANGES.txt: file containing updates in the code across different releases.
<project-name>: directory containing the Python files for your project. Note that, the root directory and directory containing the Python files have the same name.
<project-name>/tests: directory containing files for unit testing purposes.
docs: directory containing documentation related files.
A sample repository with the above files can be viewed here.
4. Create the project files as per the directory structure above and add an empty file in each directory (this is required as git does not track empty directories).
5. Add and push the project files to GitHub repository using the following command executed from project root:
git add .
git commit -a
git push -u origin master
Now, the Python project is created with initial project files are in GitHub repository.