Skip to content

Commit

Permalink
Merge pull request #192 from robotpy/rm-exec
Browse files Browse the repository at this point in the history
Minimal 2022 upgrades
  • Loading branch information
virtuald committed Jan 17, 2022
2 parents 47d4aef + cb6600a commit 953e949
Show file tree
Hide file tree
Showing 9 changed files with 69 additions and 101 deletions.
77 changes: 10 additions & 67 deletions .github/workflows/dist.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,70 +10,13 @@ on:
- '*'

jobs:
check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: psf/black@stable

#
# Test wheels
#

# test:
# runs-on: ${{ matrix.os }}
# strategy:
# matrix:
# os: [windows-latest, macos-latest, ubuntu-18.04]
# python_version: [3.6, 3.7, 3.8, 3.9]
# architecture: [x86, x64]
# exclude:
# - os: macos-latest
# architecture: x86
# - os: ubuntu-18.04
# architecture: x86

# steps:
# - uses: actions/checkout@v2
# - uses: actions/setup-python@v2
# with:
# python-version: ${{ matrix.python_version }}
# architecture: ${{ matrix.architecture }}

# - uses: robotpy/build-actions/build-wheel@v2021
# # - uses: robotpy/build-actions/test-native-wheel@v2021

# - uses: robotpy/build-actions/validate-sphinx@v2021
# if: ${{ matrix.python_version == '3.7' && matrix.os == 'ubuntu-18.04' }}


publish-pypi:
runs-on: ubuntu-latest
needs: [check]
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags')

steps:
- uses: actions/checkout@v2

- uses: actions/setup-python@v2
with:
python-version: 3.8
- run: pip install wheel

- name: Build packages
run: python setup.py sdist bdist_wheel
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@master
with:
user: __token__
password: ${{ secrets.pypi_password }}

ping:
runs-on: ubuntu-latest
needs: [publish-pypi]
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags')

steps:
- uses: robotpy/build-actions/ping-meta@v2021
with:
token: ${{ secrets.REPO_ACCESS_TOKEN }}
ci:
uses: robotpy/build-actions/.github/workflows/package-pure.yml@v2022
with:
enable_sphinx_check: false
secrets:
SSH_USER: ${{ secrets.SSH_USER }}
SSH_KEY: ${{ secrets.SSH_KEY }}
SSH_PASSPHRASE: ${{ secrets.SSH_PASSPHRASE }}
META_REPO_ACCESS_TOKEN: ${{ secrets.REPO_ACCESS_TOKEN }}
PYPI_API_TOKEN: ${{ secrets.PYPI_PASSWORD }}
38 changes: 30 additions & 8 deletions pyfrc/mains/cli_deploy.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,25 +281,47 @@ def _check_requirements(
)
return False

# does startup dlls need to be fixed
with wrap_ssh_error("checking StartupDLLs"):
# See if there's any roboRIO settings we need to adjust
with wrap_ssh_error("checking on-robot settings"):
result = ssh.exec_cmd(
"grep ^StartupDLLs /etc/natinst/share/ni-rt.ini",
get_output=True,
)
assert result.stdout is not None
if result.stdout.strip() != "":
self._fix_startupdlls(ssh)
fix_startupdlls = result.stdout.strip() != ""

result = ssh.exec_cmd(
'grep \\"exec /usr/local/frc/bin/frcRunRobot.sh',
get_output=True,
)
assert result.stdout is not None
fix_runrobot = result.stdout.strip() != ""

if fix_runrobot or fix_startupdlls:
with wrap_ssh_error("Applying patches to roborio"):
self._apply_admin_fixes(ssh, fix_startupdlls, fix_runrobot)

return True

def _fix_startupdlls(self, lvuser_ssh: sshcontroller.SshController):
def _apply_admin_fixes(
self,
lvuser_ssh: sshcontroller.SshController,
fix_startupdlls: bool,
fix_runrobot: bool,
):
# requires admin-level access to fix, so create a new ssh controller
ssh = sshcontroller.SshController(lvuser_ssh.hostname, "admin", "")
with ssh:
ssh.exec_cmd(
'sed -i -e "s/^StartupDLLs/;StartupDLLs/" /etc/natinst/share/ni-rt.ini'
)
if fix_startupdlls:
# Frees up memory on the RIO
ssh.exec_cmd(
'sed -i -e "s/^StartupDLLs/;StartupDLLs/" /etc/natinst/share/ni-rt.ini'
)
if fix_runrobot:
# GradleRIO does this, so we do too
ssh.exec_cmd(
"sed -i -e 's/\\\"exec /\\\"/' /usr/local/frc/bin/frcRunRobot.sh"
)

def _do_deploy(
self,
Expand Down
6 changes: 6 additions & 0 deletions pyfrc/mains/cli_sim.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import os
from os.path import abspath, dirname
import argparse
import inspect
Expand Down Expand Up @@ -56,6 +57,9 @@ def run(self, options, robot_class, **static_options):
else:
halsim_gui.loadExtension()

# Some extensions (gui) changes the current directory
cwd = os.getcwd()

for name, module in self.simexts.items():
if getattr(options, name.replace("-", "_"), False):
try:
Expand All @@ -64,6 +68,8 @@ def run(self, options, robot_class, **static_options):
print(f"Error loading {name}!")
raise

os.chdir(cwd)

# initialize physics, attach to the user robot class
from ..physics.core import PhysicsInterface, PhysicsInitException

Expand Down
4 changes: 2 additions & 2 deletions pyfrc/physics/drivetrains.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ def update_sim(self, now, tm_diff):

from .units import units, Helpers

from wpilib.geometry import Translation2d
from wpimath.geometry import Translation2d

from wpilib.kinematics import (
from wpimath.kinematics import (
ChassisSpeeds,
DifferentialDriveKinematics,
DifferentialDriveWheelSpeeds,
Expand Down
2 changes: 1 addition & 1 deletion pyfrc/physics/tankmodel.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import math
import typing

from wpilib.geometry import Transform2d
from wpimath.geometry import Transform2d

from .motor_cfgs import MotorModelConfig
from .units import units, Helpers
Expand Down
12 changes: 6 additions & 6 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@ install_requires =
pint>=0.11.0
importlib-metadata; python_version < '3.8'

robotpy-wpiutil>=2021,<2022
pyntcore>=2021,<2022
robotpy-hal>=2021,<2022
wpilib>=2021,<2022
robotpy-wpiutil>=2022,<2023
pyntcore>=2022,<2023
robotpy-hal>=2022,<2023
wpilib>=2022,<2023

robotpy-installer>=2021,<2022
robotpy-installer>=2022,<2023
setup_requires =
setuptools_scm == 5.0.*
setuptools_scm > 6
python_requires = >=3.6

[options.entry_points]
Expand Down
1 change: 1 addition & 0 deletions tests/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pytest
13 changes: 13 additions & 0 deletions tests/run_tests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/usr/bin/env python3

import os
from os.path import abspath, dirname
import sys
import subprocess

if __name__ == "__main__":

root = abspath(dirname(__file__))
os.chdir(root)

subprocess.check_call([sys.executable, "-m", "pytest", "-vv"])
17 changes: 0 additions & 17 deletions tests/run_tests.sh

This file was deleted.

0 comments on commit 953e949

Please sign in to comment.