Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
Deployment
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
freva
Deployment
Commits
6fa99778
Commit
6fa99778
authored
2 years ago
by
Martin Bergemann
Browse files
Options
Downloads
Patches
Plain Diff
Improve packaging
parent
d9e0a069
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!44
Better packaging
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
.gitlab-ci.yml
+1
-1
1 addition, 1 deletion
.gitlab-ci.yml
MANIFEST.in
+1
-1
1 addition, 1 deletion
MANIFEST.in
setup.py
+38
-13
38 additions, 13 deletions
setup.py
src/freva_deployment/utils.py
+32
-3
32 additions, 3 deletions
src/freva_deployment/utils.py
with
72 additions
and
18 deletions
.gitlab-ci.yml
+
1
−
1
View file @
6fa99778
...
...
@@ -45,7 +45,7 @@ release_job:
-
pip install twine
-
chmod +x /usr/local/bin/release-cli
script
:
-
python setup.py sdist
-
python setup.py sdist
bdist_wheel
-
TWINE_PASSWORD=${CI_JOB_TOKEN}
TWINE_USERNAME=gitlab-ci-token
python -m twine upload --skip-existing --verbose --repository-url
...
...
This diff is collapsed.
Click to expand it.
MANIFEST.in
+
1
−
1
View file @
6fa99778
graft
./
assets/*
graft assets/*
This diff is collapsed.
Click to expand it.
setup.py
+
38
−
13
View file @
6fa99778
...
...
@@ -7,6 +7,8 @@ import urllib.request
from
setuptools
import
setup
,
find_packages
from
setuptools.command.develop
import
develop
from
setuptools.command.install
import
install
import
sys
from
typing
import
List
THIS_DIR
=
Path
(
__file__
).
parent
...
...
@@ -14,6 +16,20 @@ CONFIG_DIR = Path("freva") / "deployment"
ASSET_DIR
=
THIS_DIR
/
"
assets
"
INSTALL_REQUIRES
=
[
"
appdirs
"
,
"
npyscreen
"
,
"
numpy
"
,
"
PyMySQL
"
,
"
pyncclient
"
,
"
pyyml
"
,
"
rich
"
,
"
toml
"
,
"
tomlkit
"
,
"
requests
"
,
]
def
find_version
(
*
parts
):
vers_file
=
read
(
*
parts
)
match
=
re
.
search
(
r
'
^__version__ =
"
(\d+.\d+.\d+)
"'
,
vers_file
,
re
.
M
)
...
...
@@ -90,6 +106,26 @@ def read(*parts: str) -> str:
return
f
.
read
()
def
get_packages
()
->
List
[
str
]:
"""
Get the packages needed to install.
"""
plf
=
sys
.
platform
if
plf
.
startswith
(
"
win
"
)
or
plf
.
startswith
(
"
cygwin
"
)
or
plf
.
startswith
(
"
ms
"
):
return
INSTALL_REQUIRES
INSTALL_REQUIRES
.
append
(
"
ansible
"
)
return
INSTALL_REQUIRES
def
get_data_files
()
->
List
[
str
]:
dirs
=
[
d
for
d
in
ASSET_DIR
.
rglob
(
"
*
"
)
if
d
.
is_dir
()]
files
=
[]
for
d
in
dirs
:
target_dir
=
Path
(
"
share
"
)
/
"
freva
"
/
"
deployment
"
/
d
.
relative_to
(
ASSET_DIR
)
add_files
=
[
str
(
f
)
for
f
in
d
.
rglob
(
"
*
"
)
if
f
.
is_file
()]
if
add_files
:
files
.
append
((
str
(
target_dir
),
add_files
))
return
files
setup
(
name
=
"
freva_deployment
"
,
version
=
find_version
(
"
src
"
,
"
freva_deployment
"
,
"
__init__.py
"
),
...
...
@@ -101,7 +137,7 @@ setup(
long_description
=
read
(
"
README.md
"
),
long_description_content_type
=
"
text/markdown
"
,
include_package_data
=
True
,
packa
ge_data
=
{
"
assets
"
:
[
"
assets
"
]}
,
data_files
=
ge
t
_data
_files
()
,
license
=
"
GPLv3
"
,
packages
=
find_packages
(
"
src
"
),
package_dir
=
{
""
:
"
src
"
},
...
...
@@ -119,18 +155,7 @@ setup(
]
},
setup_requires
=
[
"
appdirs
"
],
install_requires
=
[
"
appdirs
"
,
"
npyscreen
"
,
"
numpy
"
,
"
PyMySQL
"
,
"
pyncclient
"
,
"
pyyml
"
,
"
rich
"
,
"
toml
"
,
"
tomlkit
"
,
"
requests
"
,
],
install_requires
=
get_packages
(),
extras_require
=
{
"
docs
"
:
[
"
sphinx
"
,
...
...
This diff is collapsed.
Click to expand it.
src/freva_deployment/utils.py
+
32
−
3
View file @
6fa99778
...
...
@@ -5,7 +5,9 @@ import logging
import
json
from
pathlib
import
Path
import
re
from
subprocess
import
run
,
PIPE
from
subprocess
import
PIPE
import
sys
import
shutil
from
typing
import
cast
,
NamedTuple
import
appdirs
...
...
@@ -18,8 +20,7 @@ logging.basicConfig(format="%(name)s - %(levelname)s - %(message)s", level=loggi
logger
=
logging
.
getLogger
(
"
freva-deployment
"
)
RichConsole
=
Console
(
markup
=
True
,
force_terminal
=
True
)
config_dir
=
Path
(
appdirs
.
user_config_dir
())
/
"
freva
"
/
"
deployment
"
asset_dir
=
Path
(
appdirs
.
user_data_dir
())
/
"
freva
"
/
"
deployment
"
password_prompt
=
(
"
[green]Choose[/] a [b]master password[/], this password will be used to:
\n
"
"
- create the [magenta]mysql root[/] password
\n
"
...
...
@@ -33,6 +34,34 @@ ServiceInfo = NamedTuple(
)
class
AssetDir
:
def
__init__
(
self
):
self
.
_user_asset_dir
=
Path
(
appdirs
.
user_data_dir
())
/
"
freva
"
/
"
deployment
"
self
.
_user_config_dir
=
Path
(
appdirs
.
user_config_dir
())
/
"
freva
"
/
"
deployment
"
self
.
_central_asset_dir
=
Path
(
sys
.
exec_prefix
)
/
"
freva
"
/
"
deployment
"
@property
def
asset_dir
(
self
):
if
self
.
_user_asset_dir
.
exists
():
return
self
.
_user_asset_dir
return
self
.
_central_asset_dir
@property
def
config_dir
(
self
):
inventory_file
=
self
.
_user_config_dir
/
"
inventory.toml
"
if
inventory_file
.
exists
():
return
self
.
_user_config_dir
self
.
_user_config_dir
.
mkdir
(
exist_ok
=
True
,
parents
=
True
)
shutil
.
copy
(
self
.
asset_dir
/
"
config
"
/
"
inventory.toml
"
,
inventory_file
)
return
self
.
_user_config_dir
AD
=
AssetDir
()
asset_dir
=
AD
.
asset_dir
config_dir
=
AD
.
config_dir
def
guess_map_server
(
inp_server
:
str
|
None
,
default_port
:
int
=
6111
,
mandatory
:
bool
=
True
)
->
str
:
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment