-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Replace make + Makefile file with Python Invoke library + tasks.py file #1239
Conversation
Fixes #701 WIP
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.
Finally a brave soul decided to tackle it!
@nazar-pc you know what this is doing exactly? ifeq ($(OS),Windows_NT)
ifeq ($(MESON_ARGS),"")
MESON_ARGS = $(subst $\",,"--vsenv")
endif
endif As per my understanding it's basically doing this: "If this is Windows and MESON_ARGS env is not set, set "--vsenv" value to it". But I don't understand that "subst" thing at all... |
I vaguely remembered that simple assigning was adding quotes around the value, so it wasn't setting |
…y since `--upgrafe` and `--target` are not compatible because Python (and hence) PIP sucks a lot
Why not installing all dependencies at once rather than separately if you know you'll need them? Then yo should not hit that issue and shouldn't need to have multiple directories. |
Because I prefer to not having to install As a solution for TODO 1 (see updated PR description) I'm about to suggest that npm |
…eep Makefile as a proxy to invoke (WIP)
CI is gonna fail now due to this (on purpose): 36a5e90 |
…able (example in Alpine Linux)
To play with CI I've created a separate branch https://github.com/versatica/mediasoup/tree/replace-make-with-pip-invoke-ci-playground |
Interesting. The "ModuleNotFoundError: No module named 'imp'" in macOS 12 CI tasks happens with these versions in the CI host:
And it works in my macOS:
Same pip version, which is the latest one: https://pypi.org/project/pip/ UPDATE: The problem is that Python 3.12 doesn't have |
So the only remaining thing is installing I need to replicate in Rust this code: const PYTHON = getPython();
function getPython()
{
let python = process.env.PYTHON;
if (!python)
{
try
{
execSync('python3 --version', { stdio: [ 'ignore', 'ignore', 'ignore' ] });
python = 'python3';
}
catch (error)
{
python = 'python';
}
}
return python;
}
if (fs.existsSync(PIP_INVOKE_DIR))
{
return;
}
// Install pip invoke into custom location, so we don't depend on system-wide
// installation.
executeCmd(
`${PYTHON} -m pip install --upgrade --target=${PIP_INVOKE_DIR} invoke==${INVOKE_VERSION}`, /* exitOnError */ true
); Any help please? Specially getting the python3 executable (unless it's ok if we assume |
PR completely ready for review. |
…) directly installing Invoke using pip3
- Plus cosmetic changes in CI files
# Conflicts: # npm-scripts.mjs
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.
💯
…rker.yaml CI directly use Invoke commands instead of npm commands
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.
Looked through most things briefly.
I think that needs to change is Makefile
. I think we should remove it or mention it in Building.md
The fact that we still have it (and you, @ibc, plan to use it) while we're documenting that users need to install and use invoke
instead (whose version doesn't guarantee to match actually) is odd. It feels inconsistent right now.
On a similar note I'd say we should remove numerous scripts from package.json
too and make users call invoke/make instead there too for consistency. Otherwise right now we have 3 ways to format worker, which makes little sense to me to have.
let mut pythonpath = if env::var("PYTHONPATH").is_ok() { | ||
let original_pythonpath = env::var("PYTHONPATH").unwrap(); |
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.
This is not idiomatic, you should do this instead:
let mut pythonpath = if env::var("PYTHONPATH").is_ok() { | |
let original_pythonpath = env::var("PYTHONPATH").unwrap(); | |
let mut pythonpath = if let Ok(original_pythonpath) = env::var("PYTHONPATH") { |
); | ||
// Install Python invoke package in custom folder | ||
let pip_invoke_dir = format!("{out_dir}/pip_invoke"); | ||
let invoke_version = "2.2.0"; |
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.
Is there a good reason why we need this specific version? By not specifying a version we'll get support for future Python versions and bugfixes for free.
If we do need it, this should be a constant at the top of the file instead.
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 don't know yet how Invoke library behaves regarding compatibility or breaking changes. I think it's ok to force version 2.2.0 which we know it works in all archs. This doesn't mean we should never upgrade it. But I'm not confident enough to say ·any future version will work without changes anywhere".
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 checking their changelog is a pretty good indicator
.arg("pip") | ||
.arg("install") | ||
.arg("--upgrade") | ||
.arg(format!("--target={pip_invoke_dir}")) |
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.
Shouldn't this be two separate arguments instead?:
.arg(format!("--target={pip_invoke_dir}")) | |
.arg("--target") | |
.arg(pip_invoke_dir) |
"worker/test/include", | ||
"worker/test/src", | ||
"worker/deps/libwebrtc", | ||
"worker/tasks.py", |
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'm not sure why most of the files here were changed, they were in alphabetical order before and now they are in random order instead (worker/src
is now before worker/include
, etc.).
Also Makefile
should be removed from this list and similar changes need to be done in worker/Cargo.toml
too.
I'm honoring all comments in a separate branch, but I don't want to git rid of Makefile. It's a simple additional file. It's just a convenient thing in case people don't want to deal with Invoke yet. |
Fixes #701
Details
make
.Invoke
is automatically installed in a local path during mediasoup installation (in Node and Rust).worker/Makefile
as a proxy toInvoke
tasks defined inworker/tasks.py
.Bonus Tracks
Minor Details
getmake.py
andcpu_cores.sh
scripts.Building.md
.