dmart 1.4.40.post20__py3-none-any.whl → 1.4.40.post22__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
dmart/__init__.py CHANGED
@@ -1,7 +0,0 @@
1
- import os
2
- import sys
3
-
4
-
5
- _pkg_dir = os.path.dirname(__file__)
6
- if _pkg_dir not in sys.path:
7
- sys.path.insert(0, _pkg_dir)
dmart/dmart.py CHANGED
@@ -14,15 +14,14 @@ import warnings
14
14
  import webbrowser
15
15
  import re
16
16
  from pathlib import Path
17
+ from multiprocessing import freeze_support
17
18
 
18
19
 
19
20
  script_dir = str(Path(__file__).resolve().parent)
20
- if script_dir not in sys.path:
21
- sys.path.insert(0, script_dir)
22
21
 
23
22
  from hypercorn.config import Config
24
23
  from hypercorn.run import run
25
- from utils.settings import settings
24
+ from dmart.utils.settings import settings
26
25
 
27
26
 
28
27
  commands = """
@@ -49,6 +48,7 @@ sentinel = object()
49
48
 
50
49
 
51
50
  def hypercorn_main(args_list: list[str]) -> int:
51
+ from dmart.utils.settings import settings
52
52
  parser = argparse.ArgumentParser()
53
53
  parser.add_argument(
54
54
  "application",
@@ -261,6 +261,15 @@ def hypercorn_main(args_list: list[str]) -> int:
261
261
  config.backlog = 2000
262
262
  config.workers = 1
263
263
  config.bind = ["localhost:8282"]
264
+ # Allow child processes to find the application
265
+ dmart_dir = os.path.dirname(os.path.abspath(__file__))
266
+ dmart_pkg_parent = os.path.dirname(dmart_dir)
267
+ if dmart_pkg_parent not in sys.path:
268
+ sys.path.insert(0, dmart_pkg_parent)
269
+
270
+ # Ensure dmart_dir itself is NOT in sys.path
271
+ if dmart_dir in sys.path:
272
+ sys.path.remove(dmart_dir)
264
273
  else:
265
274
  config = Config.from_toml(args.config)
266
275
 
@@ -419,6 +428,8 @@ def main():
419
428
 
420
429
  match command:
421
430
  case "hyper":
431
+ from multiprocessing import freeze_support
432
+ freeze_support()
422
433
  hypercorn_main(args_list)
423
434
  case "cli":
424
435
  config_file = None
@@ -485,10 +496,7 @@ def main():
485
496
 
486
497
  last_import_error = None
487
498
  try:
488
- dmart_dir = Path(__file__).resolve().parent
489
- if str(dmart_dir) not in sys.path:
490
- sys.path.append(str(dmart_dir))
491
- import cli # type: ignore
499
+ from dmart import cli # type: ignore
492
500
  cli.main()
493
501
  return
494
502
  except ImportError as e:
@@ -522,6 +530,8 @@ def main():
522
530
  print("Error: cli.py not found.")
523
531
  sys.exit(1)
524
532
  case "serve":
533
+ from dmart.utils.settings import settings
534
+ from dmart.main import main as server
525
535
  open_cxb = False
526
536
  if "--open-cxb" in args_list:
527
537
  open_cxb = True
@@ -546,10 +556,9 @@ def main():
546
556
  import threading
547
557
  threading.Thread(target=open_browser, daemon=True).start()
548
558
 
549
- from main import main as server
550
559
  asyncio.run(server())
551
560
  case "health-check":
552
- from data_adapters.file.health_check import main as health_check
561
+ from dmart.data_adapters.file.health_check import main as health_check
553
562
  parser = argparse.ArgumentParser(
554
563
  description="This created for doing health check functionality",
555
564
  formatter_class=argparse.ArgumentDefaultsHelpFormatter,
@@ -563,7 +572,7 @@ def main():
563
572
  asyncio.run(health_check(args.type, args.space, args.schemas))
564
573
  print(f'total time: {"{:.2f}".format(time.time() - before_time)} sec')
565
574
  case "create-index":
566
- from data_adapters.file.create_index import main as create_index
575
+ from dmart.data_adapters.file.create_index import main as create_index
567
576
  parser = argparse.ArgumentParser(
568
577
  description="Recreate Redis indices based on the available schema definitions",
569
578
  formatter_class=argparse.ArgumentDefaultsHelpFormatter,
@@ -583,7 +592,7 @@ def main():
583
592
 
584
593
  asyncio.run(create_index(args.space, args.schemas, args.subpaths, args.flushall))
585
594
  case "export":
586
- from utils.exporter import main as exporter, exit_with_error, OUTPUT_FOLDER_NAME, validate_config, extract
595
+ from dmart.utils.exporter import main as exporter, exit_with_error, OUTPUT_FOLDER_NAME, validate_config, extract
587
596
  parser = argparse.ArgumentParser()
588
597
  parser.add_argument(
589
598
  "--config", required=True, help="Json config relative path from the script"
@@ -636,11 +645,12 @@ def main():
636
645
  f"Output path: {os.path.abspath(os.path.join(output_path, OUTPUT_FOLDER_NAME))}"
637
646
  )
638
647
  case "settings":
648
+ from dmart.utils.settings import settings
639
649
  print_formatted(settings.model_dump_json())
640
650
  case "set_password":
641
- import set_admin_passwd # noqa: F401
651
+ from dmart import set_admin_passwd # noqa: F401
642
652
  case "archive":
643
- from data_adapters.file.archive import archive
653
+ from dmart.data_adapters.file.archive import archive
644
654
  parser = argparse.ArgumentParser(
645
655
  description="Script for archiving records from different spaces and subpaths."
646
656
  )
@@ -667,10 +677,10 @@ def main():
667
677
  asyncio.run(archive(space, subpath, schema, olderthan))
668
678
  print("Done.")
669
679
  case "json_to_db":
670
- from data_adapters.sql.json_to_db_migration import main as json_to_db_migration
680
+ from dmart.data_adapters.sql.json_to_db_migration import main as json_to_db_migration
671
681
  asyncio.run(json_to_db_migration())
672
682
  case "db_to_json":
673
- from data_adapters.sql.db_to_json_migration import main as db_to_json_migration
683
+ from dmart.data_adapters.sql.db_to_json_migration import main as db_to_json_migration
674
684
  db_to_json_migration()
675
685
  case "help":
676
686
  print("Available commands:")
@@ -741,6 +751,7 @@ def main():
741
751
  import configparser
742
752
  import tempfile
743
753
 
754
+ from dmart.utils.settings import settings
744
755
  dmart_root = Path(__file__).resolve().parent
745
756
  alembic_ini_path = dmart_root / "alembic.ini"
746
757
 
@@ -758,7 +769,7 @@ def main():
758
769
 
759
770
  config.set('alembic', 'sqlalchemy.url', db_url)
760
771
  config.set('alembic', 'script_location', str(dmart_root / "alembic"))
761
- config.set('alembic', 'prepend_sys_path', str(dmart_root))
772
+ config.set('alembic', 'prepend_sys_path', os.path.dirname(dmart_root))
762
773
 
763
774
  temp_config_path = ""
764
775
  try:
@@ -821,4 +832,26 @@ def main():
821
832
  sys.exit(e.returncode)
822
833
 
823
834
  if __name__ == "__main__":
835
+ freeze_support()
836
+ # If we are running as a script (e.g. during multiprocessing spawn),
837
+ # we need to ensure the parent of dmart package is in sys.path
838
+ # so that 'import dmart' works correctly.
839
+ # However, we must NOT add the directory containing dmart.py itself
840
+ # to sys.path, as that would make 'dmart' a module instead of a package.
841
+
842
+ # Path to this file: .../site-packages/dmart/dmart.py
843
+ # dmart_dir: .../site-packages/dmart
844
+ # dmart_pkg_parent: .../site-packages
845
+ dmart_dir = os.path.dirname(os.path.abspath(__file__))
846
+ dmart_pkg_parent = os.path.dirname(dmart_dir)
847
+
848
+ if dmart_pkg_parent not in sys.path:
849
+ sys.path.append(dmart_pkg_parent)
850
+
851
+ # Ensure dmart_dir itself is NOT in sys.path to avoid module/package conflict
852
+ if dmart_dir in sys.path:
853
+ sys.path.remove(dmart_dir)
854
+ if "" in sys.path:
855
+ sys.path.remove("")
856
+
824
857
  main()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: dmart
3
- Version: 1.4.40.post20
3
+ Version: 1.4.40.post22
4
4
  Requires-Python: >=3.11
5
5
  Requires-Dist: fastapi
6
6
  Requires-Dist: pydantic
@@ -1,4 +1,4 @@
1
- dmart/__init__.py,sha256=xHodcATn-JYaoi3_TVDimR_UWG_ux9uLePUNQDzHhsY,122
1
+ dmart/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
2
  dmart/alembic.ini,sha256=wQweByyHQm-EI8BQkE0SHNRjULJ6Xn5jqgvv88IT5Sg,3738
3
3
  dmart/bundler.py,sha256=so8ZJResb1PcOH5vboa_mpFAdYr_T8u8DbbFXd570Lg,1704
4
4
  dmart/cli.py,sha256=TkZVc0bDT32nXJxNd_ZVqwKaq6pbMUOXxYRXfEaKYSI,41611
@@ -8,7 +8,7 @@ dmart/conftest.py,sha256=0ry_zeCmdBNLbm5q115b-pkOrUFYxdsOUXbIMkr7E5Y,362
8
8
  dmart/curl.pypi.sh,sha256=KQ-kgV3_d5mwqoLd4XOwz5s2wRQ7LDVX3z-kvjvp9hA,15631
9
9
  dmart/curl.sh,sha256=lmHSFVr5ft-lc5Aq9LfvKyWfntrfYbnirhzx1EGjp_A,15743
10
10
  dmart/data_generator.py,sha256=CnE-VHEeX7-lAXtqCgbRqR9WHjTuOgeiZcviYrHAmho,2287
11
- dmart/dmart.py,sha256=kXo4X_2owhksqi8AyIy-VnjTil0Ub59kHUEil_h4P-c,32175
11
+ dmart/dmart.py,sha256=AF_9WBX0bJwD7jc4J_w8DykWFfto4CjRIJwINb2RLuY,33668
12
12
  dmart/get_settings.py,sha256=Sbe2WCoiK398E7HY4SNLfDN_GmE8knR4M-YJWF31jcg,153
13
13
  dmart/hypercorn_config.toml,sha256=-eryppEG8HBOM_KbFc4dTQePnpyfoW9ZG5aUATU_6yM,50
14
14
  dmart/info.json,sha256=6Kb7MXzVS0PzDZOUXtBoAA3zpxvtRBR0PJnedjBE-v4,123
@@ -483,8 +483,8 @@ dmart/utils/ticket_sys_utils.py,sha256=9QAlW2iiy8KyxQRBDj_WmzS5kKb0aYJmGwd4qzmGV
483
483
  dmart/utils/web_notifier.py,sha256=QM87VVid2grC5lK3NdS1yzz0z1wXljr4GChJOeK86W4,843
484
484
  dmart/utils/templates/activation.html.j2,sha256=XAMKCdoqONoc4ZQucD0yV-Pg5DlHHASZrTVItNS-iBE,640
485
485
  dmart/utils/templates/reminder.html.j2,sha256=aoS8bTs56q4hjAZKsb0jV9c-PIURBELuBOpT_qPZNVU,639
486
- dmart-1.4.40.post20.dist-info/METADATA,sha256=TGrQyNh7QshaAyxcYzXln6xc5wuTDi_v8XtatAy2bak,839
487
- dmart-1.4.40.post20.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
488
- dmart-1.4.40.post20.dist-info/entry_points.txt,sha256=N832M4wG8d2GDw1xztKRVM3TnxpY2QDzvdFE8XaWaG8,43
489
- dmart-1.4.40.post20.dist-info/top_level.txt,sha256=zJo4qk9fUW0BGIR9f4DCfpxaXbvQXH9izIOom6JsyAo,6
490
- dmart-1.4.40.post20.dist-info/RECORD,,
486
+ dmart-1.4.40.post22.dist-info/METADATA,sha256=9YYBfmV4--BLFQwl3BZAolOVISR06FWRqAfXzn43Qf4,839
487
+ dmart-1.4.40.post22.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
488
+ dmart-1.4.40.post22.dist-info/entry_points.txt,sha256=N832M4wG8d2GDw1xztKRVM3TnxpY2QDzvdFE8XaWaG8,43
489
+ dmart-1.4.40.post22.dist-info/top_level.txt,sha256=zJo4qk9fUW0BGIR9f4DCfpxaXbvQXH9izIOom6JsyAo,6
490
+ dmart-1.4.40.post22.dist-info/RECORD,,