Skip to content

Commit cbe5502

Browse files
Merge pull request #284 from guzman-raphael/package-main
Add Toolbox packaging
2 parents 34c51d0 + 089051f commit cbe5502

21 files changed

+174
-313
lines changed

+dj/+lib/compareVersions.m

Lines changed: 0 additions & 100 deletions
This file was deleted.

+dj/Connection.m

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,7 @@
2727
% specify the connection to the database.
2828
% initQuery is the SQL query to be executed at the start
2929
% of each new session.
30-
setupDJ(true);
31-
try
32-
mymVersion = mym('version');
33-
assert(mymVersion.major > 2 || mymVersion.major==2 && mymVersion.minor>=6)
34-
catch
35-
error 'Outdated version of mYm. Please upgrade to version 2.6 or later'
36-
end
37-
if verLessThan('matlab', '8.6')
38-
error 'MATLAB version 8.6 (R2015b) or greater is required'
39-
end
30+
dj.setup('prompt', ~dj.set('suppressPrompt'));
4031
self.host = host;
4132
self.user = username;
4233
self.password = password;

+dj/conn.m

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@
4545
end
4646
end
4747
else
48-
% invoke setupDJ
4948
% optional environment variables specifying the connection.
5049
env = struct(...
5150
'host', 'DJ_HOST', ...

+dj/setup.m

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
function setup(varargin)
2+
p = inputParser;
3+
addOptional(p, 'force', false);
4+
addOptional(p, 'prompt', true);
5+
parse(p, varargin{:});
6+
force = p.Results.force;
7+
prompt = p.Results.prompt;
8+
persistent INVOKED
9+
if ~isempty(INVOKED) && ~force
10+
return
11+
end
12+
% check MATLAB
13+
if verLessThan('matlab', '9.1')
14+
error('DataJoint:System:UnsupportedMatlabVersion', ...
15+
'MATLAB version 9.1 (R2016b) or greater is required');
16+
end
17+
% require certain toolboxes
18+
requiredToolboxes = {...
19+
struct(...
20+
'Name', 'GHToolbox', ...
21+
'ResolveTarget', 'datajoint/GHToolbox'...
22+
), ...
23+
struct(...
24+
'Name', 'mym', ...
25+
'ResolveTarget', 'guzman-raphael/mym', ...
26+
'Version', '2.7.3'...
27+
)...
28+
};
29+
try
30+
ghtb.require(requiredToolboxes, 'prompt', prompt);
31+
catch ME
32+
if strcmp(ME.identifier, 'MATLAB:undefinedVarOrClass')
33+
GHToolboxMsg = {
34+
'Toolbox ''GHToolbox'' did not meet the minimum minimum requirements.'
35+
'Please install it via instructions in '
36+
'''https://github.com/datajoint/GHToolbox'''.'
37+
};
38+
error('DataJoint:verifyGHToolbox:Failed', ...
39+
sprintf('%s\n', GHToolboxMsg{:}));
40+
else
41+
rethrow(ME)
42+
end
43+
end
44+
% check mym
45+
mymVersion = mym('version');
46+
assert(mymVersion.major > 2 || mymVersion.major==2 && mymVersion.minor>=6, ...
47+
'DataJoint:System:mYmIncompatible', ...
48+
'Outdated version of mYm. Please upgrade to version 2.6 or later');
49+
% set cache
50+
INVOKED = true;
51+
end

+dj/version.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
function varargout = version
22
% report DataJoint version
33

4-
v = struct('major',3,'minor',3,'bugfix',1);
4+
v = struct('major',3,'minor',3,'bugfix',2);
55

66
if nargout
77
varargout{1}=v;

+tests/+lib/compareVersions.m

Lines changed: 0 additions & 100 deletions
This file was deleted.

+tests/Main.m

Lines changed: 0 additions & 5 deletions
This file was deleted.

.gitignore

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
*.m~
22
mym/
3-
*.mltbx
43
*.env
54
notebook
65
*getSchema.m
76
docker-compose.yml
87
.vscode
98
matlab.prf
109
win.*
11-
macos.*
10+
macos.*
11+
package.prj

.gitmodules

Whitespace-only changes.

.travis.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,8 @@ jobs:
3636
- <<: *slim
3737
env:
3838
- MATLAB_VERSION: R2018b
39+
- MYSQL_TAG: 5.7
40+
- <<: *slim
41+
env:
42+
- MATLAB_VERSION: R2016b
3943
- MYSQL_TAG: 5.7

0 commit comments

Comments
 (0)