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

Added the ability to pass arguments to as a string #726

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

Neizvestnyj
Copy link
Contributor

@Neizvestnyj Neizvestnyj commented Jul 8, 2022

Previously, if you read dependencies from a file and passed "$requirements" from toolchain build, then the script accepted dependencies with one line (['kivy python3']), now this is fixed

Example:

we have file requirements.txt with (python3, kivy, openssl pillow)
although we have double spaces and commas in the file, the libraries are read and assembled correctly

requirements="$(cat requirements.txt)"
toolchain build "$requirements"
toolchain pip install ecdsa, bcrypt, cryptography
req = 'python3 kivy, openssl   pillow'
recipe = ''.join(req).replace(',', '').replace('  ', ' ').split()
print(recipe)  # ['python3', 'kivy', 'openssl', 'pillow']

test_req.txt

Previously, if you read dependencies from a file and passed `"$requirements"` from toolchain build, then the script accepted dependencies with one line (`['kivy python3']`), now this is fixed
Copy link
Member

@misl6 misl6 left a comment

Choose a reason for hiding this comment

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

Left a couple of comments.

@@ -1511,7 +1512,8 @@ def pip3(self):
self.pip()

def pip(self):
_pip(sys.argv[2:])
args = ' '.join(sys.argv[2:]).replace(',', '').replace(' ', ' ').split()
Copy link
Member

Choose a reason for hiding this comment

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

_pip is a "redirector" to an actual pip, so the arguments should be pip-compatible.

Why not using a requirements.txt file here?
toolchain pip install -r app-req.txt, would just work 😃

(Maybe we want to document it?)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

hm, yes, it must be documented

@@ -1365,7 +1365,8 @@ def build(self):
if ctx.use_pbzip2:
logger.info("Using pbzip2 to decompress bzip2 data")

build_recipes(args.recipe, ctx)
recipe = ' '.join(args.recipe).replace(',', '').replace(' ', ' ').split()
Copy link
Member

Choose a reason for hiding this comment

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

Easy and effective, but looks quite hacky and I don't feel super-confident about merging it. (And should be handled on the argparser side instead)

How about an argument -r or --requirement which parses a requirements.txt file as pip does ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sounds good, why not, I'll try to implement

@Neizvestnyj Neizvestnyj requested a review from misl6 July 16, 2022 18:16
@Neizvestnyj
Copy link
Contributor Author

Look, maybe we can change the argument parser, now it works like this: toolchain build '' --r "$build_requirements"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants