|
1 | 1 | # Example Python package |
2 | 2 |
|
| 3 | +## How to use |
| 4 | + |
| 5 | +Can be used as GitHub template repository, |
| 6 | +see [GitHub documentation](https://docs.github.com/en/repositories/creating-and-managing-repositories/creating-a-repository-from-a-template). |
| 7 | + |
| 8 | +You will need to find and replace occurences of `mockup` with the name of your package. This still might |
| 9 | +need further testing: |
| 10 | + |
| 11 | +```bash |
| 12 | +# currently these are (v24.03) |
| 13 | + |
| 14 | +pyproject.toml: |
| 15 | + 5 description = "A small example package" |
| 16 | + 6: name = "rasmussenlab-mockup" |
| 17 | + 7 # This means: Load the version from the package itself. |
| 18 | + |
| 19 | +README.md: |
| 20 | + 7 |
| 21 | + 8: You will need to find and replace occurences of `mockup` with the name of your package. This still might |
| 22 | + 9 need further testing. |
| 23 | + |
| 24 | + 22 |
| 25 | + 23: Install vom [TestPyPI](https://test.pypi.org/project/rasmussenlab-mockup): |
| 26 | + 24 |
| 27 | + 25 ``` |
| 28 | + 26: pip install -i https://test.pypi.org/simple/ rasmussenlab-mockup |
| 29 | + 27 ``` |
| 30 | + 28 |
| 31 | + 29: > The package on PyPI is call `rasmussenlab-mockup` and not `mockup` as the package name is already taken. The import is still `import mockup`. |
| 32 | + 30 |
| 33 | + |
| 34 | +docs\conf.py: |
| 35 | + 18 |
| 36 | + 19: project = "mockup" |
| 37 | + 20 copyright = "2024, Jakob Nybo Nissen, Henry Webel" |
| 38 | + 21 author = "Jakob Nybo Nissen, Henry Webel" |
| 39 | + 22: PACKAGE_VERSION = metadata.version("rasmussenlab-mockup") |
| 40 | + 23 version = PACKAGE_VERSION |
| 41 | + |
| 42 | + 119 PROJECT_ROOT = Path(__file__).parent.parent |
| 43 | + 120: PACKAGE_ROOT = PROJECT_ROOT / "src" / "mockup" |
| 44 | + 121 |
| 45 | + |
| 46 | +docs\index.rst: |
| 47 | + 1: .. mockup documentation master file, created by |
| 48 | + 2 sphinx-quickstart on Mon Aug 28 14:09:15 2023. |
| 49 | + |
| 50 | + 5 |
| 51 | + 6: The mockup package |
| 52 | + 7 ================================== |
| 53 | + 8 |
| 54 | + 9: Mockup is a Python package with some simple example code. |
| 55 | + 10: To get started, explore the :class:`mockup.Circle` class. |
| 56 | + 11 |
| 57 | + |
| 58 | +docs\README.md: |
| 59 | + 27 # apidoc |
| 60 | + 28: sphinx-apidoc --force --implicit-namespaces --module-first -o reference ../src/mockup |
| 61 | + 29 # build docs |
| 62 | + |
| 63 | +docs\tutorial\tutorial.ipynb: |
| 64 | + 6 "source": [ |
| 65 | + 7: "# Mockup tutorial" |
| 66 | + 8 ] |
| 67 | + |
| 68 | + 15 "source": [ |
| 69 | + 16: "from mockup import mockup" |
| 70 | + 17 ] |
| 71 | + |
| 72 | + 24 "source": [ |
| 73 | + 25: "mockup.add_one(-11)" |
| 74 | + 26 ] |
| 75 | + |
| 76 | + 33 "source": [ |
| 77 | + 34: "list(mockup.flatten_ints([[9, 11], [12], [4, 5]]))" |
| 78 | + 35 ] |
| 79 | + |
| 80 | + 42 "source": [ |
| 81 | + 43: "c2 = mockup.Circle.from_circumference(100)\n", |
| 82 | + 44 "round(c2.radius, 3)" |
| 83 | + |
| 84 | +src\mockup\__init__.py: |
| 85 | + 6 |
| 86 | + 7: __version__ = metadata.version("rasmussenlab-mockup") |
| 87 | + 8 |
| 88 | + 9: from .mockup import add_one, Circle |
| 89 | + 10 |
| 90 | + |
| 91 | +tests\test_circle.py: |
| 92 | + 1 import unittest |
| 93 | + 2: from mockup.mockup import Circle |
| 94 | + 3 |
| 95 | +``` |
| 96 | +
|
| 97 | +> Potentially a cookiecutter could be based on this template repository. |
| 98 | +
|
3 | 99 | ## Development environment |
4 | 100 |
|
5 | 101 | Install package so that new code is picked up in a restared python interpreter: |
|
0 commit comments