Did you find any of these instructions confusing? Edit this file and submit a pull request with your improvements!
To start with, you will need a GitHub account and an account on PyPI. Create these before you get started on this tutorial. If you are new to Git and GitHub, you should probably spend a few minutes on some of the tutorials at the top of the page at GitHub Help.
Step 2: Generate Your Package¶
Now it’s time to generate your Python package.
Use cookiecutter, pointing it at the cookiecutter-pypackage repo:
You’ll be asked to enter a bunch of values to set the package up. If you don’t know what to enter, stick with the defaults.
Step 3: Create a GitHub Repo¶
Go to your GitHub account and create a new repo named
mypackage matches the
[project_slug] from your answers to running cookiecutter. This is so that Travis CI and pyup.io can find it when we get to Step 5.
If your virtualenv folder is within your project folder, be sure to add the virtualenv folder name to your .gitignore file.
You will find one folder named after the
[project_slug]. Move into this folder, and then setup git to use your GitHub repo and upload the code:
cd mypackage git init . git add . git commit -m "Initial skeleton." git remote add origin firstname.lastname@example.org:myusername/mypackage.git git push -u origin master
mypackage are adjusted for your username and package name.
Step 4: Install Dev Requirements¶
You should still be in the folder containing the
Your virtualenv should still be activated. If it isn’t, activate it now. Install the new project’s local development requirements:
pip install -r requirements_dev.txt
If you have issues building the wheel for cryptography, make sure that the required dependencies are installed. Follow the Cryptography Instruction for your OS
Step 5: Set Up Travis CI¶
Login using your Github credentials. It may take a few minutes for Travis CI to load up a list of all your GitHub repos. They will be listed with boxes to the left of the repo name, where the boxes have an
X in them, meaning it is not connected to Travis CI.
Add the public repo to your Travis CI account by clicking the
X to switch it “on” in the box next to the
mypackage repo. Do not try to follow the other instructions, that will be taken care of next.
In your terminal, your virtualenv should still be activated. If it isn’t, activate it now. Run the script to do your Travis CI setup:
- Encrypt your PyPI password in your Travis config.
- Activate automated deployment on PyPI when you push a new tag to master branch.
See Travis/PyPI Setup for more information.
|[*]||For private projects go to Travis CI com|
Step 6: Set Up ReadTheDocs¶
ReadTheDocs hosts documentation for the open source community. Think of it as Continuous Documentation.
Log into your account at ReadTheDocs . If you don’t have one, create one and log into it.
If you are not at your dashboard, choose the pull-down next to your username in the upper right, and select “My Projects”. Choose the button to Import the repository and follow the directions.
In your GitHub repo, select Settings > Webhooks & Services, turn on the ReadTheDocs service hook.
Now your documentation will get rebuilt when you make documentation changes to your package.
Step 7: Set Up pyup.io¶
pyup.io is a service that helps you to keep your requirements files up to date. It sends you automated pull requests whenever there’s a new release for one of your dependencies.
To use it, create a new account at pyup.io or log into your existing account.
Click on the green
Add Repo button in the top left corner and select the repo you created in Step 3. A popup will
ask you whether you want to pin your dependencies. Click on
Pin to add the repo.
Once your repo is set up correctly, the pyup.io badge will show your current update status.
Step 8: Release on PyPI¶
The Python Package Index or PyPI is the official third-party software repository for the Python programming language. Python developers intend it to be a comprehensive catalog of all open source Python packages.
When you are ready, release your package the standard Python way.
See PyPI Help for more information about submitting a package.
Here’s a release checklist you can use: https://gist.github.com/audreyr/5990987