Skip to content

Commit 1c22ae8

Browse files
martin-s-aoierlauzialbertmena
authored
Use of dynamic dependencies (#905)
## Note: This PR needs to be merged after [xmipp-995](I2PC/xmipp3#995). - `xmipp3-installer` will now be automatically installed with the plugin to ease Xmipp's new installation process. - Instead of pointing to a specific Xmipp's version (`v3.24.0`, for example), a new dynamic tag `v3` is used, to avoid needing to release a new version of the plugin just because a new release of xmipp was generated. Now releases in the plugin will only be tiggered by changes in the code of the plugin itself, nothing else. --------- Co-authored-by: Oier Lauzirika Zarrabeitia <[email protected]> Co-authored-by: alberto <[email protected]>
1 parent c83b011 commit 1c22ae8

File tree

6 files changed

+58
-71
lines changed

6 files changed

+58
-71
lines changed

.github/workflows/build.yml

Lines changed: 16 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,11 @@ name: Build plugin
22

33
on:
44
pull_request:
5-
branches: [devel, master]
5+
workflow_dispatch:
66

77
jobs:
88
build:
99
runs-on: ubuntu-22.04
10-
11-
# Avoid send statistics
12-
env:
13-
SEND_INSTALLATION_STATISTICS: OFF
1410

1511
steps:
1612
- name: Checkout repository
@@ -23,14 +19,6 @@ jobs:
2319
sudo apt-get update
2420
sudo apt-get install -y libfftw3-dev libopenmpi-dev libhdf5-dev libtiff5-dev libsqlite3-dev default-jdk git cmake openmpi-bin gcc g++
2521
26-
- name: Install CUDA
27-
uses: Jimver/cuda-toolkit@master
28-
id: cuda-toolkit
29-
with:
30-
cuda: '11.8.0'
31-
method: network
32-
sub-packages: '["nvcc", "toolkit"]'
33-
3422
- name: Install Miniconda
3523
uses: conda-incubator/setup-miniconda@main
3624
with:
@@ -39,41 +27,26 @@ jobs:
3927
auto-activate-base: true
4028
activate-environment: scipion3
4129
python-version: "3.8"
42-
30+
4331
- name: Install Scipion
44-
working-directory: ${{ github.workspace }}
32+
working-directory: ${{ github.workspace }}/../
4533
run: |
46-
pwd
4734
pip install --user scipion-installer
4835
python -m scipioninstaller -conda -noAsk scipion
4936
50-
51-
- name: Cloning scipion-em-xmipp
52-
working-directory: ${{ github.workspace }}/scipion/
37+
- name: Install xmipp3-installer
38+
working-directory: ${{ github.workspace }}
5339
run: |
54-
pwd
55-
rm -rf scipion-em-xmipp
56-
git clone https://github.com/I2PC/scipion-em-xmipp.git
40+
pip install --user xmipp3-installer
5741
58-
- name: Conditionally checkout to ${{ github.head_ref }}
59-
working-directory: ${{ github.workspace }}/scipion/scipion-em-xmipp
60-
env:
61-
BRANCH_NAME: ${{ github.head_ref }}
62-
run: |
63-
pwd
64-
git checkout $BRANCH_NAME
65-
66-
- name: Install and compile Xmipp and show log
67-
working-directory: ${{ github.workspace }}/scipion/
68-
env:
69-
BUILD_TESTS: True
70-
BRANCH_NAME: ${{ github.head_ref }}
71-
SEND_INSTALLATION_STATISTICS: OFF
42+
- name: Cloning xmipp and getting sources
43+
working-directory: ${{ github.workspace }}/../
7244
run: |
73-
pwd
74-
./scipion3 installp -p scipion-em-xmipp --devel || {
75-
echo "First attempt failed. Retrying..."
76-
sleep 10
77-
./scipion3 installp -p scipion-em-xmipp --devel || (cat compilation.log && false)
78-
}
79-
# Duplicated because a defineVariables scipion plugin fails
45+
git clone https://github.com/I2PC/xmipp3.git
46+
./xmipp3/xmipp getSources --keep-output
47+
cd xmipp3/src/
48+
ln -s "${{ github.workspace }}" "${{ github.workspace }}/../xmipp3/src/scipion-em-xmipp"
49+
50+
- name: Installing scipion-em-xmipp
51+
working-directory: ${{ github.workspace}}/../xmipp3/src
52+
run: ../../scipion/scipion3 installp -p scipion-em-xmipp/ --devel

.github/workflows/release.yml

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
name: Release
22
on:
3-
push:
4-
branches: [ master ]
3+
workflow_dispatch:
54

65
jobs:
76
release:
7+
environment:
8+
name: release-approval
9+
810
runs-on: ubuntu-latest
11+
912
steps:
1013
- name: Checkout
1114
uses: actions/checkout@main
@@ -17,37 +20,43 @@ jobs:
1720
uses: actions/setup-python@main
1821
with:
1922
python-version: '3.8'
20-
23+
2124
- name: Install dependencies
2225
run: |
2326
python -m pip install --upgrade pip
2427
pip install setuptools wheel twine build
2528
pip install -r requirements.txt
26-
29+
30+
- name: Switch xmipp from devel to release
31+
run: |
32+
sed -i -E "s/^(type_of_version[[:space:]]*=[[:space:]]*)'devel'/\1'release'/" xmipp3/version.py
33+
git add xmipp3/version.py
34+
git config --global user.name "github-actions"
35+
git config --global user.email "[email protected]"
36+
git commit -m "Switch xmipp from devel to release"
37+
2738
- name: Build and publish
2839
env:
2940
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
3041
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
3142
run: |
3243
python -m build --no-isolation
3344
twine upload dist/* -c "${{ secrets.PYPI_COMMENT }}"
34-
45+
3546
- name: Get changelog, tag name, & release name
3647
id: variables
37-
run: |
38-
awk '/## Release/{if (p) exit; p=1} p' CHANGELOG.md > latest_changelog_with_title.md
39-
cat latest_changelog_with_title.md | tail -n +2 > latest_changelog.md
40-
RELEASE_NAME=$(cat latest_changelog_with_title.md | head -n 1 | sed 's/## Release //' | sed 's/^ *//')
41-
echo "RELEASE_NAME=$RELEASE_NAME" >> $GITHUB_OUTPUT
42-
echo "TAG_NAME=${RELEASE_NAME// /}" >> $GITHUB_OUTPUT
43-
48+
run:
49+
TAG_NAME=$(grep "_pluginVersion" xmipp3/version.py | sed -E 's/.*"([^"]+)".*/\1/')
50+
RELEASE_NAME="Release ${TAG_NAME}"
51+
echo "TAG_NAME=$TAG_NAME" >> $GITHUB_OUTPUT
52+
4453
- name: Generate tag
4554
id: tag_version
4655
uses: mathieudutour/[email protected]
4756
with:
4857
github_token: ${{ secrets.GITHUB_TOKEN }}
4958
custom_tag: ${{ steps.variables.outputs.TAG_NAME }}
50-
59+
5160
- name: Create a GitHub release
5261
uses: ncipollo/release-action@main
5362
with:

requirements.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,5 @@ joblib
88
peppercorn
99
plotter
1010
PyWavelets
11-
11+
xmipp3-installer==2.*
12+
numpy==1.*

xmipp3/__init__.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,6 @@
4545

4646
type_of_version = version.type_of_version
4747
_logo = version._logo
48-
_binTagVersion = version._binTagVersion
49-
_pluginTagVersion= version._pluginTagVersion
5048
_currentDepVersion = version._currentDepVersion
5149
__version__ = version.__version__
5250

@@ -199,16 +197,15 @@ def defineBinaries(cls, env):
199197
default=False
200198
)
201199
else:
202-
xmippSrc = f'xmippSrc-{version._binTagVersion}'
200+
xmippSrc = f'xmipp3-{version._binVersion}'
203201
installCommands = [
204202
(f'cd .. && rm -rf {xmippSrc} && '
205-
f'git clone {XMIPP_GIT_URL} {xmippSrc} && '
203+
f'git clone {XMIPP_GIT_URL} -b {version._binVersion} {xmippSrc} && '
206204
f'cd {xmippSrc} && '
207-
f'git checkout {version._binTagVersion} && '
208205
f'./xmipp --production True ', COMPILE_TARGETS)
209206
]
210207
env.addPackage(
211-
'xmippSrc', version=version._binTagVersion,
208+
'xmipp3', version=version._binVersion,
212209
tar='void.tgz',
213210
commands=installCommands,
214211
neededProgs=['git', 'gcc', 'g++', 'cmake', 'make'],
@@ -228,7 +225,7 @@ def __getBundleDirectory(cls):
228225

229226
isBundle = (os.path.isdir(os.path.join(bundleDir, 'src')) and
230227
os.path.isfile(os.path.join(bundleDir, 'xmipp')))
231-
228+
print(f'pluginDir: {pluginDir}\n, bundleDir: {bundleDir}\n, isBundle: {isBundle}')
232229
return bundleDir if isBundle else None
233230

234231
def getNvidiaDriverVersion(plugin):

xmipp3/constants.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
"""
2929

3030
# ------------------ Constants values --------------------------------------
31-
XMIPP_GIT_URL = 'https://github.com/I2PC/xmipp.git'
31+
XMIPP_GIT_URL = 'https://github.com/I2PC/xmipp3.git'
3232
XMIPP_URL = 'https://github.com/i2pc/scipion-em-xmipp'
3333
XMIPP_HOME = 'XMIPP_HOME'
3434
NMA_HOME = 'NMA_HOME'

xmipp3/version.py

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,18 @@
2828
type_of_version = 'devel' #'release' 'devel'
2929
_logo = "xmipp_logo" + ("" if type_of_version == 'release' else '_devel') + '.png'
3030

31-
_binVersion = 'v3.25.06.0' # Increase it if hotfix in binaries (xmipp, xmippCore and/or XmippViz)
32-
_pluginVersion = 'v3.25.06.0' # Increase it if hotfix in binaries (xmipp, xmippCore and/or XmippViz) or in scipion-em-xmipp
33-
34-
_binTagVersion = _binVersion + '-Rhea' #'devel' or _binVersion + '-Poseidon'
35-
_pluginTagVersion = _pluginVersion + '-Rhea' #'devel' or _pluginVersion + '-Poseidon'
31+
_binVersion = 'v4' # Increase it if major release is generated in xmipp
32+
# Increase according to SemVer rules:
33+
# Rules with initial package version of vX.Y.Z
34+
# - If the change consists of fixing a bug (that does not change at all
35+
# how the protocols are used), increase Z by 1.
36+
# - If the change is adding new functionality (extra params for a protocol,
37+
# or new protocols), increase Y by 1.
38+
# - If the change deprecates existing functionality (remove a protocol,
39+
# or a param), increase X by 1
40+
# - If several of the above are true, only change the biggest one applicable (
41+
# for example, if a fix is made and a new protocol are included in the same
42+
# pull request, increase the one related to the new protocol).
43+
__version__ = 'v4.0.0'
3644

3745
_currentDepVersion = '1.0'
38-
__version__ = _pluginVersion[3:] # Name of the pypi package

0 commit comments

Comments
 (0)