Homebrew - easy package manager for MacOS:
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
pipenv - makes canonical environment management easy:
brew install pipenv
pyenv - allows for installation of multiple Python interpreters for tox testing:
brew install pyenv pyenv install <python version>
cookiecutter - templated setup of Python projects:
brew install cookiecutter
travis - command line app for Travis caution:
brew install travis
Generate cookiecutter project using cookiecutter-pipenv template:
cookiecutter gh:elgertam/cookiecutter-pipenv # follow prompts cd <project-name>
Create local git repo:
git init git add . git commit -m "Initial commit"
Setup repo on GitHub:
# Create repo on GitHub site without Readme, license, .gitignore # Copy remote repository URL git remote add origin <repository URL> git remote -v git push -u origin master
Install dev requirements:
pipenv install --dev
Add
__main__.py
to main code folder (see example file)Add repo on Travis and setup config for future PyPI deployment:
# Sign up on Travis using GitHub login # Activate repo on Travis python3 travis_pypi_setup.py --password <PyPI password> pipenv lock --requirements --dev # Edit .travis.yml to use desired Travis versions (see example file)
Add repo to ReadTheDocs (RTD):
# Sign up on RTD using GitHub login # Activate repo on RTD
Set up bumpversion config file .bumpversion.cfg (see example file)
Edit setup.py
Set tags to match project plan (i.e. Python versions, etc)
Add entry point for
__main__.py
:setup( ..., entry_points = { 'console_scripts': [ 'cycle_calendar_generator = cycle_calendar_generator.__main__:main']}, ..., )
Setup tox.ini for desired Python versions
- The default tox.ini is good, but might hit more versions than you need.
Commit and push
Normal development should take place in the pipenv shell:
pipenv shell
Integration Testing
If using subprocess.run()
, make sure to use the -m
flag in *args
:
subprocess.run(['python3', '-m', <other arguments>])
Installing dependencies:
pipenv install <dependency name> # or for development dependencies pipenv install --dev <dependency name> # same dependency name as on PyPI pipenv lock --requirements --dev # for Travis compatibility # Update setup.py (requirements or test_requirements) for testing compatibility if needed
Testing:
setup.py testing (current Python version):
python3 setup.py test
tox testing (multiple versions):
# must be outside pipenv shell deactivate tox
New version deployment:
# Make sure all tests pass (especially tox!) # update HISTORY.rst git add HISTORY.rst git commit -m "Version update: <new version>" bumpversion <major|minor|patch> git push && git push --tags # Travis will test commits and deploy tagged commit to PyPI