Follow these guidelines to successfully migrate your Python project into the new structure.
- Analyze Your Current Structure
- Integrate Codebase
- Utilize Development Tools
- Documentation
- Testing and Validation
- Final Steps
- Example for New GitHub Project
- Identify and Organize Components:
- Examine your codebase and categorize components: core functionality, utility functions, models, data analysis scripts, etc.
- Organize these into modules for easy navigation and maintenance.
- Review Dependencies:
- List all external dependencies.
- Update
pyproject.toml
(orrequirements.txt
) for runtime dependencies andrequirements-dev.txt
for development-only packages.
- Migrate Source Code:
- Move primary source code to
src/
directory. - Create sub-directories within
src/
for each module and include an empty__init__.py
. - Adjust import statements as needed.
- Move primary source code to
- Adapt Tests:
- Relocate tests to
tests/
directory. - Mirror project structure in
tests/
or use a flat hierarchy if few tests. - Update
pytest
configuration to reflect new paths.
- Relocate tests to
- Integrate Configuration Files:
- Review and adapt existing configuration files (e.g., database, external services) to match the new structure.
- Code Quality Tools:
- Use
flake8
,mypy
,pylint
, andruff
to review and adjust code for quality standards.
- Use
- Pre-commit Hooks:
- Ensure
pre-commit
hooks are installed and configured to run automatically.
- Ensure
- Update README:
- Modify
README.md
to reflect project specifics: purpose, running instructions, and contribution guidelines. - Remove or update template-specific sections.
- Modify
- Add Contributing Guide:
- Create or update
CONTRIBUTING.md
with guidelines for contributing, including coding standards and pull request process.
- Create or update
- Run Tests:
- Execute all tests to ensure they pass in the new setup.
- Code Quality Checks:
- Run linters and static type checkers to identify and fix issues.
- Manual Testing:
- Perform manual tests to ensure expected application behavior.
-
Remove Existing Git History:
- Detach from the template's version history:
rm -rf .git
-
Initialize or Reuse Repository:
- Follow version control instructions to add files to your new or existing repository.
-
Commit Changes:
- Commit the integrated changes with a detailed message describing the migration process.
-
Continuous Learning:
- Stay open to new tools and practices to enhance your development workflow.
For a new project on GitHub, after creating chosen-python-project-name, initialize and push your repository:
git init
git add .
git commit -m "Initial commit"
git branch -M master
git remote add origin git@github.com:Name/chosen-python-project-name.git
git push -u origin master