fix: data path inside package
This commit is contained in:
1
MANIFEST.in
Normal file
1
MANIFEST.in
Normal file
@@ -0,0 +1 @@
|
||||
recursive-include src/epub2go/data *
|
||||
15
README.md
15
README.md
@@ -7,18 +7,11 @@ Requires:
|
||||
## Usage
|
||||
Invoke the script using the url of any page of the book you would like to download:
|
||||
```
|
||||
python convert.py https://example.com
|
||||
epub2go https://www.projekt-gutenberg.org/ibsen/solness/
|
||||
```
|
||||
## Installation
|
||||
1. Assuming you have a recent version of [Python](https://www.python.org/downloads/) and Pip installed, create virtual environment using
|
||||
Assuming you have a recent version of python installed, run
|
||||
```
|
||||
python -m venv .venv
|
||||
```
|
||||
2. Activate your new venv using
|
||||
```
|
||||
source .venv/bin/activate
|
||||
```
|
||||
3. Install the requirements for this script using
|
||||
```
|
||||
pip install -r requirements.txt
|
||||
pip install git+https://github.com/eneller/epub2go.py
|
||||
```
|
||||
This will provide the 'epub2go' command.
|
||||
|
||||
@@ -15,8 +15,8 @@ epub2go = "epub2go.convert:main"
|
||||
[tool.setuptools]
|
||||
include-package-data = true
|
||||
|
||||
[tool.setuptools.packages.find]
|
||||
where = ["src"]
|
||||
[build-system]
|
||||
requires = ["setuptools>=64", "setuptools_scm>=8"]
|
||||
|
||||
[tool.setuptools.package-data]
|
||||
"epub2go" = ["blocklist.txt", "drama.css"]
|
||||
[tool.setuptools_scm]
|
||||
# can be empty if no extra settings are needed, presence enables setuptools-scm
|
||||
0
src/epub2go/__init__.py
Normal file
0
src/epub2go/__init__.py
Normal file
@@ -12,10 +12,9 @@ class GBConvert():
|
||||
def __init__(self,
|
||||
url:str,
|
||||
):
|
||||
dir_root = os.path.dirname(os.path.dirname(os.path.dirname(os.path.realpath(__file__))))
|
||||
dir_data = os.path.join(dir_root, "data/")
|
||||
self.style_path_drama = os.path.join(dir_data, "drama.css")
|
||||
self.blocklist = open(os.path.join(dir_data, "blocklist.txt"), 'r').read().splitlines()
|
||||
# NOTE move non-code files to data folder
|
||||
self.style_path_drama = pkg_resources.files('epub2go').joinpath("drama.css")
|
||||
self.blocklist = open(pkg_resources.files('epub2go').joinpath('blocklist.txt')).read().splitlines()
|
||||
self.root = os.path.dirname(url)
|
||||
self.url = urlparse(self.root)
|
||||
self.output = self.url.netloc + self.url.path
|
||||
|
||||
Reference in New Issue
Block a user