Skip to content
Draft
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
mLRS/Common/mavlink/out/*
mLRS/Common/dronecan/out/*
mLRS/Common/dronecan/venv
esp/mlrs-wifi-bridge/*.cfg
esp/mlrs-wifi-bridge/*.json
esp/mlrs-wifi-bridge/*.svd
Expand Down
17 changes: 16 additions & 1 deletion mLRS/Common/dronecan/dronecan_generate_c_library.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,22 @@
import shutil
import re
import sys
import venv
import pathlib
import subprocess

script_folder = pathlib.Path(__file__).parent.resolve()
venv_folder = os.path.join(script_folder, 'venv')
venv.create(venv_folder, with_pip=True)
python_path = os.path.join(venv_folder, "bin", "python")
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

To resolve the issue of differents folder name containing python between Unix/MAC and Windows OS, same-ish code as in the original virtualenv commit (here) can be used.

Suggested change
python_path = os.path.join(venv_folder, "bin", "python")
bin_dir = "bin"
if sys.platform == 'win32':
bin_dir = "Scripts"
python_path = os.path.join(venv_folder, bin_dir, "python")


def pip_install(package):
res = subprocess.call([python_path, "-m", "pip", "install", package])

pip_install("setuptools")
pip_install("empy==3.3.4")
pip_install("pexpect")
pip_install("dronecan")

mLRSProjectdirectory = os.path.dirname(os.path.abspath(__file__))
mLRSdirectory = os.path.join(mLRSProjectdirectory,'mLRS')
Expand All @@ -33,7 +48,7 @@ def kill_outdir():


def os_system(arg):
res = os.system(arg)
res = os.system(f"{python_path} {arg}")
if res != 0:
print('# ERROR (errno =',res,') DONE #')
os.system("pause")
Expand Down