Skip to content

Commit 3b2053e

Browse files
committed
add setup.py & tox.ini, files reorganisation
1 parent 8532f4f commit 3b2053e

File tree

9 files changed

+88
-8
lines changed

9 files changed

+88
-8
lines changed

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,3 +54,8 @@ data/ref/territoire.shx
5454
.idea/
5555

5656
.vscode
57+
58+
.coverage
59+
.tox
60+
*.swp
61+
*.swo

MANIFEST.in

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
include VERSION
2+
include README.txt
3+
include LICENCE.txt
4+
include requirements.in
5+
include tox.ini

initAtlas.py renamed to atlas/app.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def create_app():
4747
# configuration publique
4848
valid_config = read_and_validate_conf(config, AtlasConfig)
4949

50-
app = Flask(__name__, template_folder=APP_DIR)
50+
app = Flask(__name__, template_folder='../' + APP_DIR)
5151
# push the config in app config at 'PUBLIC' key
5252
app.config.update(valid_config)
5353

@@ -77,9 +77,9 @@ def pretty(val):
7777
return app
7878

7979

80-
app = create_app()
8180
if __name__ == "__main__":
8281
# validation de la configuration secrète
82+
app = create_app()
8383
secret_conf = read_and_validate_conf(config, SecretSchemaConf)
8484
app.run(
8585
host="0.0.0.0", port=secret_conf["GUNICORN_PORT"], debug=app.config["modeDebug"]

atlas/configuration/config.py.example

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ AFFICHAGE_EN_CE_MOMENT = True
107107

108108
AFFICHAGE_RANG_STAT = True
109109
COLONNES_RANG_STAT = 3
110-
RANG_STAT = [{'phylum': ["Arthropoda", "Mollusca", "Annelida", "Cnidaria", "Platyhelminthes"]]}, {'phylum': ["Chordata"]}, {'regne': ["Plantae"]}]
110+
RANG_STAT = [{'phylum': ["Arthropoda", "Mollusca", "Annelida", "Cnidaria", "Platyhelminthes"]}, {'phylum': ["Chordata"]}, {'regne': ["Plantae"]}]
111111
RANG_STAT_FR = ['Faune invertébrée', 'Faune vertébrée', 'Flore']
112112

113113

gunicorn_start.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@ export PYTHONPATH=$FLASKDIR:$PYTHONPATH
1616

1717

1818
# Start your unicorn
19-
exec gunicorn initAtlas:app --error-log $FLASKDIR/log/errors_atlas.log --pid="${app_name}.pid" -w "${gun_num_workers}" -b "${gun_host}:${gun_port}" -n "${app_name}"
19+
exec gunicorn "atlas.app:create_app()" --error-log $FLASKDIR/log/errors_atlas.log --pid="${app_name}.pid" -w "${gun_num_workers}" -b "${gun_host}:${gun_port}" -n "${app_name}"

requirements.in

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
Click
2+
dominate
3+
Flask-Compress
4+
Flask-Script
5+
Flask-SQLAlchemy
6+
Flask<2
7+
GeoAlchemy2
8+
geojson
9+
gunicorn
10+
itsdangerous
11+
Jinja2
12+
MarkupSafe
13+
marshmallow
14+
psycopg2
15+
SQLAlchemy
16+
visitor
17+
Werkzeug
18+

setup.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import setuptools
2+
from pathlib import Path
3+
4+
root_dir = Path(__file__).absolute().parent
5+
with (root_dir / 'VERSION').open() as f:
6+
version = f.read()
7+
with (root_dir / 'README.rst').open() as f:
8+
long_description = f.read()
9+
with (root_dir / 'requirements.in').open() as f:
10+
requirements = f.read().splitlines()
11+
12+
13+
setuptools.setup(
14+
name='geonature-atlas',
15+
version=version,
16+
description="Atlas WEB dynamique Faune-Flore basé sur les données présentes dans la synthèse de GeoNature",
17+
long_description=long_description,
18+
long_description_content_type='text/x-rst',
19+
maintainer='Parcs nationaux des Écrins et des Cévennes',
20+
maintainer_email='[email protected]',
21+
url='https://github.com/PnX-SI/GeoNature-Atlas',
22+
packages=setuptools.find_packages('.'),
23+
#package_dir={'': 'src'},
24+
install_requires=requirements,
25+
classifiers=['Development Status :: 1 - Planning',
26+
'Intended Audience :: Developers',
27+
'Natural Language :: English',
28+
'Programming Language :: Python :: 3',
29+
'License :: OSI Approved :: GNU General Public License v3',
30+
'Operating System :: OS Independent'],
31+
)
32+

tests/conftest.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
# pylint: disable=redefined-outer-name
22
import pytest
33

4-
from initAtlas import app as flask_app
4+
from atlas.app import create_app
55

6-
@pytest.fixture
6+
@pytest.fixture(scope='session')
77
def app():
8-
yield flask_app
8+
app = create_app()
9+
app.testing = True
10+
app.config['SERVER_NAME'] = 'test.atlas.local' # required by url_for
11+
with app.app_context():
12+
yield app
913

1014
@pytest.fixture
1115
def client(app):
12-
return app.test_client()
16+
return app.test_client()

tox.ini

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
[tox]
2+
envlist = clean,py37
3+
4+
[testenv]
5+
deps =
6+
-r requirements.txt
7+
pytest
8+
pytest-cov
9+
pytest-flask
10+
commands =
11+
pytest --cov=atlas
12+
13+
[testenv:clean]
14+
deps = coverage
15+
skip_install = true
16+
commands = coverage erase

0 commit comments

Comments
 (0)