removing blobs and adjusting automations (#1299)

* removing blobs and adjusting automations

* .gitignore

* clearing upo .gitignore

* including in build-folder (fix setup.py) and in bdist-packages (MANIFEST.in)

* remove print

Co-authored-by: benk10 <ben.kaufman10@gmail.com>
This commit is contained in:
Kim Neunert 2021-07-15 19:09:18 +02:00 committed by GitHub
parent ce1e516440
commit 130a68242a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
30 changed files with 57 additions and 2 deletions

1
.gitignore vendored
View file

@ -32,3 +32,4 @@ tests/bitcoin
tests/bitcoin.binary
tests/bitcoin.compile
token.sh
src/cryptoadvance/specter/translations/**/messages.mo

View file

@ -54,6 +54,7 @@ check:
- pip3 install -r requirements.txt
- pip3 install -e .
- pip3 install -r test_requirements.txt
- python3 setup.py install # compiles babel stuff as well (might make pip install obsolete)
# pytest --docker not working? Uncomment this for better debugging:
# - python3 tests/conftest.py
- py.test --cov-report term --cov cryptoadvance --docker
@ -65,6 +66,7 @@ check:
# start the server in the background
- pip3 install -e .
- pip3 install -r test_requirements.txt
- python3 setup.py install # compiles babel stuff as well (might make pip install obsolete)
- npm i
- ./utils/test-cypress.sh --docker --debug run
- docker ps || echo "probably no docker available anyway"

View file

@ -76,6 +76,7 @@ virtualenv --python=python3 .env
source .env/bin/activate
pip3 install -r requirements.txt --require-hashes
pip3 install -e .
python3 setup.py install # also compiles the babel translation-files
```
_note: invoking commands in the Windows PowerShell is slightly different:_

View file

@ -1,3 +1,4 @@
recursive-include src/cryptoadvance/specter/templates *
recursive-include src/cryptoadvance/specter/static *
recursive-include src/cryptoadvance/specter/translations/*/LC_MESSAGES *.mo
include requirements.txt

View file

@ -176,3 +176,18 @@ The only other step is to add the new language to the LANGUAGES list in `config.
# right:
"he": "עברית",
```
## For Packagers:
The mo-files are not checked into the repository as (large) binary (large) objects ("BLOBs") should not be checked into git to reduce repo-size bloat. So effectively they need to be generated before the user is using the software. Effectively what has been described above:
```
pybabel compile -d src/cryptoadvance/specter/translations
```
In order to make that as transparent as possible, that procedure has been integrated into the setup-process. So it will be executed by:
```
python3 setup.py install
```
Unfortunately, it won't be executed by `pip3 install -e .` even though that has been propagated very long to be the developement-env installation procedure. So in the various installation procedures (mainly in `.gitlab-ci.yml`) this has been changed. For more special packaging mechanism, this needs to be respected as well.

3
setup.cfg Normal file
View file

@ -0,0 +1,3 @@
[compile_catalog]
directory=src/cryptoadvance/specter/translations
domain=messages

34
setup.py Normal file → Executable file
View file

@ -1,11 +1,30 @@
from babel.messages import frontend as babel
from glob import glob
from setuptools import find_namespace_packages, setup
from setuptools.command.install import install
class InstallWithBabelCompile(install):
"""from this stackoverflow question
https://stackoverflow.com/questions/40051076/compile-translation-files-when-calling-setup-py-install
"""
def run(self):
from babel.messages.frontend import compile_catalog
compiler = compile_catalog(self.distribution)
option_dict = self.distribution.get_option_dict("compile_catalog")
compiler.domain = [option_dict["domain"][1]]
compiler.directory = option_dict["directory"][1]
compiler.run()
super().run()
with open("requirements.txt") as f:
install_reqs = f.read().strip().split("\n")
# Filter out comments/hashes
reqs = []
for req in install_reqs:
@ -28,6 +47,11 @@ setup(
url="https://github.com/cryptoadvance/specter-desktop",
packages=find_namespace_packages("src", include=["cryptoadvance.*"]),
package_dir={"": "src"},
package_data={
"": [
"translations/*/LC_MESSAGES/messages.mo",
]
},
# take METADATA.in into account, include that stuff as well (static/templates)
include_package_data=True,
install_requires=reqs,
@ -38,4 +62,12 @@ setup(
"Framework :: Flask",
],
python_requires=">=3.6,<3.10",
cmdclass={
"install": InstallWithBabelCompile,
# The rest is convenience but not strictly necessary for the automation:
"compile_catalog": babel.compile_catalog,
"extract_messages": babel.extract_messages,
"init_catalog": babel.init_catalog,
"update_catalog": babel.update_catalog,
},
)