diff --git a/setup.py b/setup.py index 92ca43a..4e56ac5 100644 --- a/setup.py +++ b/setup.py @@ -1,8 +1,11 @@ import sys from cx_Freeze import setup, Executable +# After running the setup file (python setup.py build) the scrapy/VERSION file has to be manually put into the +# library.zip, also the FourmiCrawler map has to be copied to both the library and the exe.win32-2.7 folder. after +# putting the files in the library the library has to be zipped and replace the old library. # Dependencies are automatically detected, but it might need fine tuning. -build_exe_options = {"packages": ["os", "scrapy", "lxml._elementpath"], "excludes": ["tkinter"]} +build_exe_options = {"packages": ["os", "scrapy", "lxml", "w3lib", "pkg_resources", "zope.interface"], "excludes": []} # GUI applications require a different base on Windows (the default is for a # console application). diff --git a/sourceloader.py b/sourceloader.py index 78cbd91..67efe63 100644 --- a/sourceloader.py +++ b/sourceloader.py @@ -1,4 +1,5 @@ import inspect +import sys import os import re from FourmiCrawler.sources.source import Source @@ -8,17 +9,24 @@ class SourceLoader: sources = [] def __init__(self, rel_dir="FourmiCrawler\\sources"): - path = os.path.dirname(os.path.abspath(__file__)) - path += "\\" + rel_dir - known_parser = set() + + if hasattr(sys,'frozen'): + path = os.path.dirname(sys.executable) + path += "\\" + rel_dir + known_parser = set() + + else: + path = os.path.dirname(os.path.abspath(__file__)) + path += "\\" + rel_dir + known_parser = set() for py in [f[:-3] for f in os.listdir(path) if f.endswith('.py') and f != '__init__.py']: mod = __import__('.'.join([rel_dir.replace('\\', "."), py]), fromlist=[py]) classes = [getattr(mod, x) for x in dir(mod) if inspect.isclass(getattr(mod, x))] for cls in classes: if issubclass(cls, Source) and cls not in known_parser: - self.sources.append(cls()) # [review] - Would we ever need arguments for the parsers? - known_parser.add(cls) + self.sources.append(cls()) # [review] - Would we ever need arguments for the parsers? + # known_parser.add(cls) def include(self, source_names): new = set()