Skip to content

Commit a9c2d69

Browse files
lakshmanaramcoderick14
authored andcommitted
added install_entry to fix setup cache data bug
1 parent 254f364 commit a9c2d69

File tree

2 files changed

+32
-20
lines changed

2 files changed

+32
-20
lines changed

ACedIt/install_entry.py

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import json
2+
import os
3+
from setuptools.command.install import install
4+
5+
class InstallEntry(install):
6+
7+
def run(self):
8+
9+
default_site = 'codeforces'
10+
workdir = os.path.join(os.path.expanduser('~'), 'ACedIt')
11+
cache_dir = os.path.join(os.path.expanduser('~'), '.cache', 'ACedIt')
12+
13+
from main import supported_sites
14+
15+
for site in supported_sites:
16+
# create cache directory and working directory structure
17+
if not os.path.isdir(os.path.join(cache_dir, site)):
18+
os.makedirs(os.path.join(cache_dir, site))
19+
if not os.path.isdir(os.path.join(workdir, site)):
20+
os.makedirs(os.path.join(workdir, site))
21+
22+
data = {'default_site': default_site.strip(), 'workdir': os.path.expanduser('~'),
23+
'cachedir': cache_dir}
24+
with open(os.path.join(cache_dir, 'constants.json'), 'w') as f:
25+
f.write(json.dumps(data, indent=2))

setup.py

+7-20
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
from distutils.core import setup
55

66
import sys
7-
import json
8-
import os
7+
8+
from ACedIt.install_entry import InstallEntry
99

1010
with open('requirements.txt', 'r') as f:
1111
requirements = [line.strip() for line in f.readlines()]
@@ -14,24 +14,6 @@
1414
if sys.version_info >= (3,):
1515
extra['use_2to3'] = True
1616

17-
default_site = 'codeforces'
18-
workdir = os.path.join(os.path.expanduser('~'), 'ACedIt')
19-
cache_dir = os.path.join(os.path.expanduser('~'), '.cache', 'ACedIt')
20-
21-
from ACedIt.main import supported_sites
22-
23-
for site in supported_sites:
24-
# create cache directory and working directory structure
25-
if not os.path.isdir(os.path.join(cache_dir, site)):
26-
os.makedirs(os.path.join(cache_dir, site))
27-
if not os.path.isdir(os.path.join(workdir, site)):
28-
os.makedirs(os.path.join(workdir, site))
29-
30-
data = {'default_site': default_site.strip(), 'workdir': os.path.expanduser('~'),
31-
'cachedir': cache_dir}
32-
with open(os.path.join(cache_dir, 'constants.json'), 'w') as f:
33-
f.write(json.dumps(data, indent=2))
34-
3517
setup(
3618
name='ACedIt',
3719

@@ -57,6 +39,11 @@
5739

5840
keywords=['sample test cases', 'downloader', 'competitive programming'],
5941

42+
cmdclass={
43+
'install': InstallEntry,
44+
'develop': InstallEntry,
45+
},
46+
6047
classifiers=[
6148
'Operating System :: POSIX :: Linux',
6249
'License :: OSI Approved :: MIT License',

0 commit comments

Comments
 (0)