-
Notifications
You must be signed in to change notification settings - Fork 3
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
fix pip check for optional dependencies #405
Changes from all commits
f6ba2dd
be106ca
3893454
49bb62e
5850d4a
256ecfc
8485643
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import tomlkit | ||
|
||
|
||
if __name__ == "__main__": | ||
with open("pyproject.toml", "r") as f: | ||
data = tomlkit.load(f) | ||
|
||
lst = [] | ||
for sub_lst in data["project"]["optional-dependencies"].values(): | ||
for el in sub_lst: | ||
lst.append(el) | ||
|
||
data["project"]["dependencies"] += [el for el in set(lst) if not el.startswith("pwtools")] | ||
|
||
with open("pyproject.toml", "w") as f: | ||
f.writelines(tomlkit.dumps(data)) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,4 @@ channels: | |
- conda-forge | ||
dependencies: | ||
- pymace =0.3.6 | ||
- pytorch =2.5.1 |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,4 @@ channels: | |
- conda-forge | ||
dependencies: | ||
- qe =7.2 | ||
- pwtools =1.2.3 | ||
- pwtools =1.2.3 |
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -134,18 +134,24 @@ jobs: | |||||||||||||||||||||||||||||||||||||||||||||||
steps: | ||||||||||||||||||||||||||||||||||||||||||||||||
- uses: actions/checkout@v4 | ||||||||||||||||||||||||||||||||||||||||||||||||
- name: Conda config | ||||||||||||||||||||||||||||||||||||||||||||||||
run: echo -e "channels:\n - conda-forge\n" > .condarc | ||||||||||||||||||||||||||||||||||||||||||||||||
run: | | ||||||||||||||||||||||||||||||||||||||||||||||||
cp .ci_support/environment.yml environment.yml | ||||||||||||||||||||||||||||||||||||||||||||||||
tail --lines=+4 .ci_support/environment-lammps.yml >> environment.yml | ||||||||||||||||||||||||||||||||||||||||||||||||
tail --lines=+4 .ci_support/environment-gpaw.yml >> environment.yml | ||||||||||||||||||||||||||||||||||||||||||||||||
echo -e "channels:\n - conda-forge\n" > .condarc | ||||||||||||||||||||||||||||||||||||||||||||||||
- name: Setup Mambaforge | ||||||||||||||||||||||||||||||||||||||||||||||||
uses: conda-incubator/setup-miniconda@v3 | ||||||||||||||||||||||||||||||||||||||||||||||||
with: | ||||||||||||||||||||||||||||||||||||||||||||||||
python-version: '3.12' | ||||||||||||||||||||||||||||||||||||||||||||||||
miniforge-version: latest | ||||||||||||||||||||||||||||||||||||||||||||||||
condarc-file: .condarc | ||||||||||||||||||||||||||||||||||||||||||||||||
environment-file: .ci_support/environment.yml | ||||||||||||||||||||||||||||||||||||||||||||||||
environment-file: environment.yml | ||||||||||||||||||||||||||||||||||||||||||||||||
- name: Pip check | ||||||||||||||||||||||||||||||||||||||||||||||||
shell: bash -l {0} | ||||||||||||||||||||||||||||||||||||||||||||||||
run: | | ||||||||||||||||||||||||||||||||||||||||||||||||
pip install versioneer[toml]==0.29 | ||||||||||||||||||||||||||||||||||||||||||||||||
pip install versioneer[toml]==0.29 tomlkit | ||||||||||||||||||||||||||||||||||||||||||||||||
python .ci_support/check.py | ||||||||||||||||||||||||||||||||||||||||||||||||
cat pyproject.toml | ||||||||||||||||||||||||||||||||||||||||||||||||
Comment on lines
+152
to
+154
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. 🛠️ Refactor suggestion Add error handling for script execution. The script execution should be validated to ensure it completes successfully. Apply this diff to add error handling: - pip install versioneer[toml]==0.29 tomlkit
- python .ci_support/check.py
- cat pyproject.toml
+ pip install versioneer[toml]==0.29 tomlkit || {
+ echo "Error: Failed to install dependencies"
+ exit 1
+ }
+
+ if [ ! -f ".ci_support/check.py" ]; then
+ echo "Error: check.py not found"
+ exit 1
+ fi
+
+ python .ci_support/check.py || {
+ echo "Error: Failed to process dependencies"
+ exit 1
+ }
+
+ if [ ! -f "pyproject.toml" ]; then
+ echo "Error: pyproject.toml not found after processing"
+ exit 1
+ fi
+ cat pyproject.toml 📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||
pip install . --no-deps --no-build-isolation | ||||||||||||||||||||||||||||||||||||||||||||||||
pip check | ||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||
|
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.
Add error handling for file operations and TOML parsing.
The script should handle potential file operation errors and TOML parsing exceptions to prevent crashes and data loss.
Apply this diff to add error handling:
Don't forget to add the required import:
Also applies to: 15-16
🧰 Tools
🪛 Ruff (0.8.2)
5-5: Unnecessary open mode parameters
Remove open mode parameters
(UP015)