Migration to PyScaffold¶
Migrating your existing project to PyScaffold is in most cases quite easy and requires
only a few steps. We assume your project resides in the Git repository
and includes a package directory
my_package with your Python modules.
Since you surely don’t want to lose your Git history, we will just deploy a new scaffold in the same repository and move as well as change some files. But before you start, please make that your working tree is not dirty, i.e. all changes are committed and all important files are under version control.
Change into the parent folder of
putup my_project --force --no-skeleton -p my_package
in order to deploy the new project structure in your repository.
Now change into
my_projectand move your old package folder into
git mv my_package/* src/my_package/
Use the same technique if your project has a test folder other than
testsor a documentation folder other than
git statusto check for untracked files and add them with
git difftoolto check all overwritten files for changes that need to be transferred. Most important is that all configuration that you may have done in
setup.pyby passing parameters to
setup(...)need to be moved to
setup.cfg. You will figure that out quite easily by putting your old
setup.pyand the new
setup.cfgtemplate side by side. Checkout the documentation of setuptools for more information about this conversion. In most cases you will not need to make changes to the new
setup.pyfile provided by PyScaffold. The only exceptions are if your project uses compiled resources, e.g. Cython, or if you need to specify
In order to check that everything works, run
python setup.py installand
python setup.py sdist. If those two commands don’t work, check
setup.pyas well as your package under
srcagain. Where all modules moved correctly? Is there maybe some
__init__.pyfile missing? After these basic commands, try also to run
python setup.py docsand
python setup.py testto check that Sphinx and PyTest runs correctly.