{"id":17036721,"url":"https://github.com/bast/somepackage","last_synced_at":"2025-04-04T08:04:10.831Z","repository":{"id":43557204,"uuid":"114917621","full_name":"bast/somepackage","owner":"bast","description":"Show how to structure a Python project.","archived":false,"fork":false,"pushed_at":"2020-02-10T14:54:34.000Z","size":26,"stargazers_count":415,"open_issues_count":2,"forks_count":79,"subscribers_count":14,"default_branch":"master","last_synced_at":"2025-03-28T07:05:06.837Z","etag":null,"topics":["api","layout","modular","python","structure"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bast.png","metadata":{"files":{"readme":"README.rst","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-12-20T18:18:01.000Z","updated_at":"2025-03-21T05:49:35.000Z","dependencies_parsed_at":"2022-07-12T18:19:06.114Z","dependency_job_id":null,"html_url":"https://github.com/bast/somepackage","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bast%2Fsomepackage","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bast%2Fsomepackage/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bast%2Fsomepackage/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bast%2Fsomepackage/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bast","download_url":"https://codeload.github.com/bast/somepackage/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247142032,"owners_count":20890651,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api","layout","modular","python","structure"],"created_at":"2024-10-14T08:51:43.640Z","updated_at":"2025-04-04T08:04:10.811Z","avatar_url":"https://github.com/bast.png","language":"Python","readme":".. image:: https://travis-ci.org/bast/somepackage.svg?branch=master\n   :target: https://travis-ci.org/bast/somepackage/builds\n.. image:: https://img.shields.io/badge/license-%20MPL--v2.0-blue.svg\n   :target: ../master/LICENSE\n\n\nSomepackage\n===========\n\nShow how to structure a Python project.\n\nInspired by https://github.com/kennethreitz/samplemod.\n\n\nGreat resources\n===============\n\n- https://manikos.github.io/a-tour-on-python-packaging\n- https://docs.python-guide.org/writing/structure/\n- http://veekaybee.github.io/2017/09/26/python-packaging/\n- https://github.com/audreyr/cookiecutter-pypackage\n- https://medium.com/@jonas.r.kemper/understanding-best-practice-python-tooling-by-comparing-popular-project-templates-6eba49229106\n\n\nRecommendations\n===============\n\nPlease browse this blog post for a good summary of recommendatios and templates: https://medium.com/@jonas.r.kemper/understanding-best-practice-python-tooling-by-comparing-popular-project-templates-6eba49229106\n\n\nPython 2 or 3?\n--------------\n\n- Develop your code under Python 3, test it for both Python 2 and Python 3\n  but consider Python 3 to be the default today.\n\n\nSplit your code into packages, modules, and functions\n-----------------------------------------------------\n\n- All code should be inside some function (except perhaps ``if __name__ == '__main__':``).\n- Split long functions into smaller functions.\n- If you need to scroll through a function over several screens, it is probably too long.\n- Functions should do one thing and one thing only.\n- Hide internals with underscores.\n- Organize related functions into modules.\n- If modules grow too large, split them.\n- Import from other modules under ``somepackage/`` using ``from .somemodule import something``.\n- Do file I/O on the \"outside\" of your code, not deep inside.\n\n\nClasses vs. functions\n---------------------\n\n- Do not overuse classes.\n- Prefer immutable data structures.\n- Prefer pure functions.\n\n\nNaming\n------\n\n- Give the subdirectory the same name as your package.\n- Before you name your package, check that the name is not taken on https://pypi.org\n  (you may want to upload your package to PyPI one day).\n\n\nInterfaces\n----------\n\n- In ``somepackage/__init__.py`` define what should be visible to the outside.\n- Use https://semver.org.\n\n\nTesting\n-------\n\n- Test all non-trivial code. I recommend to use https://pytest.org.\n- Use Travis CI: https://docs.travis-ci.com/user/languages/python/.\n\n\nDependency management\n---------------------\n\n- Package dependencies for developers should be listed in ``requirements.txt``.\n- Alternatively, consider using http://pipenv.readthedocs.io.\n- Package dependencies for users of your code (who will probably install via pip) should be listed in ``setup.py``.\n\n\nCode style\n----------\n\n- Follow PEP8: https://www.python.org/dev/peps/pep-0008/\n- Use ``pycodestyle`` to automatically check for PEP8.\n\n\nType checking\n-------------\n\n- Consider using type hints: https://docs.python.org/3/library/typing.html\n- Consider using http://mypy-lang.org.\n- Consider verifying type annotations at runtime: https://github.com/RussBaz/enforce\n\n\nShare your package\n------------------\n\n- Choose a license and add a LICENSE file.\n- Share your package on PyPI. For this you can follow https://github.com/bast/pypi-howto.\n\n\nDocumentation\n-------------\n\nI used to recommend reStructuredText for READMEs in contrast to Markdown but\nPyPI no longer requires reStructuredText. You can use Markdown as noted on\nhttps://pypi.org/help/ under \"How can I upload a project description in a\ndifferent format?\".\n\nExample shown here: https://packaging.python.org/tutorials/packaging-projects/#creating-setup-py\n\n\nSuggestions? Corrections? Pull requests?\n----------------------------------------\n\nYes please!\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbast%2Fsomepackage","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbast%2Fsomepackage","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbast%2Fsomepackage/lists"}