##// END OF EJS Templates
refactor: Use pathlib in tools/
Martin Matějek -
Show More
@@ -7,28 +7,29 b' from __future__ import print_function'
7
7
8 import os
8 import os
9 from glob import glob
9 from glob import glob
10 from pathlib import Path
10 from subprocess import call
11 from subprocess import call
11 import sys
12 import sys
12
13
13 from toollib import (get_ipdir, pjoin, cd, execfile, sh, archive,
14 from toollib import (get_ipdir, cd, execfile, sh, archive,
14 archive_user, archive_dir)
15 archive_user, archive_dir)
15
16
16 # Get main ipython dir, this will raise if it doesn't pass some checks
17 # Get main ipython dir, this will raise if it doesn't pass some checks
17 ipdir = get_ipdir()
18 ipdir = get_ipdir()
18 tooldir = pjoin(ipdir, 'tools')
19 tooldir = ipdir / 'tools'
19 distdir = pjoin(ipdir, 'dist')
20 distdir = ipdir / 'dist'
20
21
21 # Where I keep static backups of each release
22 # Where I keep static backups of each release
22 ipbackupdir = os.path.expanduser('~/ipython/backup')
23 ipbackupdir = Path('~/ipython/backup').expanduser()
23 if not os.path.exists(ipbackupdir):
24 if not ipbackupdir.exists():
24 os.makedirs(ipbackupdir)
25 ipbackupdir.mkdir(parents=True, exist_ok=True)
25
26
26 # Start in main IPython dir
27 # Start in main IPython dir
27 cd(ipdir)
28 cd(ipdir)
28
29
29 # Load release info
30 # Load release info
30 version = None
31 version = None
31 execfile(pjoin('IPython','core','release.py'), globals())
32 execfile(Path('IPython','core','release.py'), globals())
32
33
33 # Build site addresses for file uploads
34 # Build site addresses for file uploads
34 release_site = '%s/release/%s' % (archive, version)
35 release_site = '%s/release/%s' % (archive, version)
@@ -5,8 +5,9 b''
5 import os
5 import os
6 import sys
6 import sys
7
7
8 from pathlib import Path
9
8 # Useful shorthands
10 # Useful shorthands
9 pjoin = os.path.join
10 cd = os.chdir
11 cd = os.chdir
11
12
12 # Constants
13 # Constants
@@ -34,13 +35,12 b' def get_ipdir():'
34 """Get IPython directory from command line, or assume it's the one above."""
35 """Get IPython directory from command line, or assume it's the one above."""
35
36
36 # Initialize arguments and check location
37 # Initialize arguments and check location
37 ipdir = pjoin(os.path.dirname(__file__), os.pardir)
38 ipdir = Path(__file__).parent / os.pardir
38
39 ipdir = ipdir.resolve()
39 ipdir = os.path.abspath(ipdir)
40
40
41 cd(ipdir)
41 cd(ipdir)
42 if not os.path.isdir('IPython') and os.path.isfile('setup.py'):
42 if not Path("IPython").is_dir() and Path("setup.py").is_file():
43 raise SystemExit('Invalid ipython directory: %s' % ipdir)
43 raise SystemExit("Invalid ipython directory: %s" % ipdir)
44 return ipdir
44 return ipdir
45
45
46 def execfile(fname, globs, locs=None):
46 def execfile(fname, globs, locs=None):
General Comments 0
You need to be logged in to leave comments. Login now