Skip to content
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

chore(hardware): add opentrons hardware package to ot 2 build #13770

Merged
merged 4 commits into from
Oct 19, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Config.in
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ source "$BR2_EXTERNAL_OPENTRONS_MONOREPO_PATH/robot-server/Config.in"
source "$BR2_EXTERNAL_OPENTRONS_MONOREPO_PATH/shared-data/python/Config.in"
source "$BR2_EXTERNAL_OPENTRONS_MONOREPO_PATH/notify-server/Config.in"
source "$BR2_EXTERNAL_OPENTRONS_MONOREPO_PATH/system-server/Config.in"
source "$BR2_EXTERNAL_OPENTRONS_MONOREPO_PATH/server-utils/Config.in"
source "$BR2_EXTERNAL_OPENTRONS_MONOREPO_PATH/server-utils/Config.in"
source "$BR2_EXTERNAL_OPENTRONS_MONOREPO_PATH/hardware/Config.in"
2 changes: 1 addition & 1 deletion api/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ setup:
.PHONY: setup-ot2
setup-ot2:
$(pipenv) sync $(pipenv_opts)
$(pipenv) run pip uninstall -y opentrons_hardware
$(pipenv) run pip uninstall -y python-can
$(pipenv) run pip freeze

.PHONY: clean
Expand Down
2 changes: 1 addition & 1 deletion api/Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ types-mock = "==4.0.1"
types-setuptools = "==57.0.2"
opentrons-shared-data = { editable = true, path = "../shared-data/python" }
opentrons = { editable = true, path = "." }
opentrons-hardware = { editable = true, path = "./../hardware" }
opentrons-hardware = { editable = true, path = "./../hardware", extras= ["CAN"] }
# specify typing-extensions explicitly to force lockfile inclusion on Python >= 3.8
typing-extensions = ">=4.0.0,<5"
pytest-profiling = "~=1.7.0"
Expand Down
1 change: 1 addition & 0 deletions api/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ def get_version():
PACKAGES = find_packages(where="src")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we see if we can make the extras thing transitive? like, add an extra to api that is 'flex-hardware' that requires opentrons_hardware["CAN"], an extra that is ot2-hardware that requires opentrons_hardware (maybe eventually opentrons_hardware["SERIAL"] or whatever). Then the pipfile for api installs opentrons["flex-hardware"].

The reason for this is that ideally we don't require hardware support for default in the api server.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep this worked pretty nicely. Tested running all of the following and they seem to filter the packages correctly:

  • pipenv run pip install . --> no hardware package
  • pipenv run pip install ".[ot2-hardware]" --> opentrons_hardware without python-can
  • pipenv run pip install ".[flex-hardware]" --> opentrons_hardware with python_can

INSTALL_REQUIRES = [
f"opentrons-shared-data=={VERSION}",
f"opentrons-hardware=={VERSION}",
"aionotify==0.2.0",
"anyio==3.3.0",
"jsonschema==3.0.2",
Expand Down
1 change: 1 addition & 0 deletions external.mk
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ include $(BR2_EXTERNAL_OPENTRONS_MONOREPO_PATH)/shared-data/python/buildroot.mk
include $(BR2_EXTERNAL_OPENTRONS_MONOREPO_PATH)/notify-server/buildroot.mk
include $(BR2_EXTERNAL_OPENTRONS_MONOREPO_PATH)/system-server/buildroot.mk
include $(BR2_EXTERNAL_OPENTRONS_MONOREPO_PATH)/server-utils/buildroot.mk
include $(BR2_EXTERNAL_OPENTRONS_MONOREPO_PATH)/hardware/buildroot.mk
17 changes: 17 additions & 0 deletions hardware/Config.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
config BR2_PACKAGE_PYTHON_OPENTRONS_HARDWARE
bool "python-opentrons-hardware"
depends on BR2_PACKAGE_PYTHON3
select BR2_PACKAGE_PYTHON_AIONOTIFY # runtime
select BR2_PACKAGE_PYTHON_ANYIO # runtime
select BR2_PACKAGE_PYTHON_JSONSCHEMA # runtime
select BR2_PACKAGE_PYTHON_NUMPY # runtime
select BR2_PACKAGE_PYTHON_PYDANTIC # runtime
select BR2_PACKAGE_PYTHON_SERIAL # runtime
select BR2_PACKAGE_PYTHON_SYSTEMD # runtime
select BR2_PACKAGE_PYTHON_TYPING_EXTENSIONS # runtime
select BR2_PACKAGE_PYTHON_CLICK # runtime

help
Opentrons hardware package. Provides an interface for OT-2 and Flex control.

https://opentrons.com
32 changes: 32 additions & 0 deletions hardware/buildroot.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
################################################################################
#
# python-opentrons-hardware
#
################################################################################

define OTHARDWARE_CALL_PBU
$(shell python $(BR2_EXTERNAL_OPENTRONS_MONOREPO_PATH)/scripts/python_build_utils.py hardware $(or $(OPENTRONS_PROJECT),robot-stack) $(1))
endef

PYTHON_OPENTRONS_HARDWARE_VERSION = $(call OTHARDWARE_CALL_PBU,get_version)
PYTHON_OPENTRONS_HARDWARE_LICENSE = Apache-2
PYTHON_OPENTRONS_HARDWARE_LICENSE_FILES = $(BR2_EXTERNAL_OPENTRONS_MONOREPO_PATH)/LICENSE
PYTHON_OPENTRONS_HARDWARE_SETUP_TYPE = setuptools
PYTHON_OPENTRONS_HARDWARE_SITE_METHOD = local
PYTHON_OPENTRONS_HARDWARE_SITE = $(BR2_EXTERNAL_OPENTRONS_MONOREPO_PATH)
PYTHON_OPENTRONS_HARDWARE_SUBDIR = hardware
PYTHON_OPENTRONS_HARDWARE_POST_INSTALL_TARGET_HOOKS = PYTHON_OPENTRONS_HARDWARE_INSTALL_VERSION

define PYTHON_OPENTRONS_HARDWARE_INSTALL_VERSION
echo '$(call OTHARDWARE_CALL_PBU,dump_br_version)' > $(BINARIES_DIR)/opentrons-hardware-version.json
endef

ot_hardware_name := python-opentrons-hardware

export OPENTRONS_GIT_DIR=$(BR2_EXTERNAL_OPENTRONS_MONOREPO_PATH)

# Calling inner-python-package directly instead of using python-package macro
# because our directory layout doesn’t conform to buildroot’s expectation of
# having the directory name be the package name
$(eval $(call inner-python-package,$(ot_hardware_name),$(call UPPERCASE,$(ot_hardware_name)),$(call UPPERCASE,$(ot_hardware_name)),target))

6 changes: 5 additions & 1 deletion hardware/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,14 @@ def get_version() -> str:
DESCRIPTION = "Hardware control for Opentrons Robots."
PACKAGES = find_packages(where=".", exclude=["tests.*", "tests"])
INSTALL_REQUIRES = [
"python-can==3.3.4",
"pyserial==3.5",
f"opentrons_shared_data=={VERSION}",
]

EXTRAS = {
"CAN": ["python-can==3.3.4"],
}


def read(*parts: str) -> str:
"""Build an absolute path from parts and return the contents of the resulting file.
Expand Down Expand Up @@ -80,6 +83,7 @@ def read(*parts: str) -> str:
zip_safe=False,
classifiers=CLASSIFIERS,
install_requires=INSTALL_REQUIRES,
extras_require=EXTRAS,
include_package_data=True,
package_data={
"opentrons_hardware": ["py.typed", "opentrons_hardware.cmakefind"]
Expand Down
2 changes: 1 addition & 1 deletion notify-server/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ setup:
.PHONY: setup-ot2
setup-ot2:
$(pipenv) sync $(pipenv_opts)
$(pipenv) run pip uninstall -y opentrons_hardware
$(pipenv) run pip uninstall -y python-can
$(pipenv) run pip freeze

.PHONY: clean
Expand Down
2 changes: 1 addition & 1 deletion robot-server/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ setup:
.PHONY: setup-ot2
setup-ot2:
$(pipenv) sync $(pipenv_opts)
$(pipenv) run pip uninstall -y opentrons_hardware
$(pipenv) run pip uninstall -y python-can
$(pipenv) run pip freeze

.PHONY: clean
Expand Down