-
Notifications
You must be signed in to change notification settings - Fork 108
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
pip: Add support for pyproject.toml #332
Open
JakobDev
wants to merge
5
commits into
flatpak:master
Choose a base branch
from
JakobDev:pyproject
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
003603c
pip: Add support for pyproject.toml
JakobDev d3c2cb8
pip: Add support for pyproject.toml
JakobDev 9f7a089
pip: Add support for pyproject.toml
ENDrain 92b0b0f
Merge branch 'pyproject' into pyproject
ENDrain dafe58b
Merge pull request #1 from ENDrain/pyproject
JakobDev File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,6 +28,8 @@ parser.add_argument('--cleanup', choices=['scripts', 'all'], | |
help='Select what to clean up after build') | ||
parser.add_argument('--requirements-file', '-r', | ||
help='Specify requirements.txt file') | ||
parser.add_argument('--pyproject-file', | ||
help='Specify pyproject.toml file') | ||
parser.add_argument('--build-only', action='store_const', | ||
dest='cleanup', const='all', | ||
help='Clean up all files after build') | ||
|
@@ -57,6 +59,18 @@ parser.add_argument('--ignore-errors', action='store_true', | |
help='Ignore errors when downloading packages') | ||
opts = parser.parse_args() | ||
|
||
if opts.requirements_file and opts.pyproject_file: | ||
exit('Can\'t use both requirements and pyproject files at the same time') | ||
|
||
if opts.pyproject_file: | ||
try: | ||
from tomllib import load as toml_load | ||
except ModuleNotFoundError: | ||
try: | ||
from tomli import load as toml_load | ||
except ModuleNotFoundError: | ||
exit('tomli modules is not installed. Run "pip install tomli"') | ||
|
||
if opts.yaml: | ||
try: | ||
import yaml | ||
|
@@ -167,6 +181,16 @@ if opts.requirements_file: | |
except FileNotFoundError: | ||
pass | ||
|
||
elif opts.pyproject_file: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe it should error if both |
||
pyproject_file = os.path.expanduser(opts.pyproject_file) | ||
with open(pyproject_file, "rb") as f: | ||
pyproject_data = toml_load(f) | ||
dependencies = pyproject_data.get("project", {}).get("dependencies", []) | ||
packages = list(requirements.parse('\n'.join(dependencies))) | ||
with tempfile.NamedTemporaryFile('w', delete=False, prefix='requirements.') as req_file: | ||
req_file.write('\n'.join(dependencies)) | ||
requirements_file = req_file.name | ||
|
||
elif opts.packages: | ||
packages = list(requirements.parse('\n'.join(opts.packages))) | ||
with tempfile.NamedTemporaryFile('w', delete=False, prefix='requirements.') as req_file: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Please rebase and update
README.md
to include this option.