-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added example pyproject and package. #11
Merged
gonuke
merged 19 commits into
main
from
3-add-pyprojecttoml-and-arrange-files-per-standards
Aug 22, 2024
Merged
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
07611ae
Created ACME packing slip for order #1.
MicahGale b5c7341
Built box for order #1.
MicahGale 00f9f67
Built piano for order 1
MicahGale c3af5d1
Made package executable.
MicahGale fac136f
Exposed piano properties to fulfill order 1 spec.
MicahGale 2965da0
Tested piano against spec for order 1
MicahGale ca1b00f
I can't spell.
MicahGale d3fc1a3
Merge branch 'main' into 3-add-pyprojecttoml-and-arrange-files-per-st…
MicahGale faafe99
Removed top level scripts.
MicahGale 6b7e05e
Updated do_task tests for move.
MicahGale 65667a0
Added an entry point script.
MicahGale dc4e4d0
Also demonstrated building and installing as part of test suite.
MicahGale 4555e40
Switched doc strings to sphinx style.
MicahGale ec8a70c
debugging install failure.
MicahGale dcf8c72
Fixed install
MicahGale f4f7553
Forgot that files don't persist.
MicahGale 844a084
It's dist not build.
MicahGale 9c5520e
typo corrections.
MicahGale 9162956
Verbs are hard.
MicahGale File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# make piano a top-level class | ||
from .piano import Piano |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
from . import Piano | ||
|
||
""" | ||
This is a special file that makes this package executable. | ||
|
||
It will only be run when this package is run from the command line, i.e., | ||
|
||
``python -m acme_corp`` | ||
""" | ||
|
||
|
||
def set_trap(): | ||
piano = Piano() | ||
piano.lift() | ||
return piano | ||
|
||
|
||
if __name__ == "__main__": | ||
trap = set_trap() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
class Piano: | ||
""" | ||
A grand piano proudly built by ACME corporation. | ||
|
||
Weighing half a ton be careful when hoisting this precariously over | ||
sidewalks. | ||
|
||
.. warning:: | ||
Always use proper rigging techniques when hoisting this above | ||
above any paths that may be occupied by any Road Runners. | ||
""" | ||
|
||
def __init__(self): | ||
self._weight = 1_000 | ||
# start on ground level | ||
self._height = 0 | ||
|
||
def lift(self): | ||
self._height = 3 # [m] | ||
|
||
def drop(self): | ||
pass | ||
|
||
@property | ||
def weight(self): | ||
""" | ||
The current weight of the piano. | ||
|
||
:returns: the current weight. | ||
:rtype: float | ||
""" | ||
return self._weight | ||
|
||
@property | ||
def height(self): | ||
""" | ||
The current height of the piano. | ||
|
||
:returns: the current height. | ||
:rtype: float | ||
""" | ||
return self._height |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# reference: <https://packaging.python.org/en/latest/guides/writing-pyproject-toml/> | ||
[project] | ||
name = "acme_corp" | ||
description = "A package, or box, created by the Acme Corporation for all of your Road Runner hunting needs." | ||
# use semantic versioning: <https://semver.org/> | ||
version = "0.0.1" | ||
|
||
readme = "README.md" | ||
requires-python = ">=3.9" | ||
maintainers = [{name = "G. C. Runner", email = "[email protected]"}] | ||
authors = [{name = "G. C. Runner", email = "[email protected]"}] | ||
|
||
keywords = ["Piano", "Anvil", "Instant Tunnel"] | ||
|
||
# these will be install with `pip install .` | ||
dependencies = ["pyyaml"] | ||
|
||
# these will only be installed with `pip install .[test]` | ||
[project.optional-dependencies] | ||
test =["pytest"] | ||
|
||
[project.scripts] | ||
do_thing = "acme_corp:do_task.do_task" | ||
|
||
# these show up on the left bar on pypi.org | ||
[project.urls] | ||
Homepage = "https://github.com/cnerg/py-template" | ||
|
||
[build-system] | ||
requires = ["setuptools>=64.0.0"] | ||
build-backend = "setuptools.build_meta" | ||
|
||
[tools.pytest.ini_options] | ||
minversion = "6.0" | ||
junit_logging = "all" |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import acme_corp | ||
|
||
import pytest | ||
|
||
|
||
@pytest.fixture | ||
def blank_piano(): | ||
return acme_corp.Piano() | ||
|
||
|
||
def test_piano_init(blank_piano): | ||
assert blank_piano.weight == pytest.approx(1_000.0) | ||
assert blank_piano.height == pytest.approx(0.0) | ||
|
||
|
||
def test_lifting_piano(blank_piano): | ||
blank_piano.lift() | ||
assert blank_piano.height == pytest.approx(3) | ||
|
||
|
||
def test_dropping_piano(blank_piano): | ||
pass |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
did we decide to switch to numpy docstring style?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we decided to make that a separate PR #12.