-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathSetup.py
More file actions
992 lines (777 loc) · 31.2 KB
/
Copy pathSetup.py
File metadata and controls
992 lines (777 loc) · 31.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
AutoERP Setup Configuration
==========================
Professional setup.py for the AutoERP Enterprise Resource Planning System.
This setup script provides comprehensive configuration for package distribution,
installation, and development workflows.
Features:
- Dynamic version detection from multiple sources
- Flexible dependency management with extras
- Development tools integration
- Plugin system support
- Cross-platform compatibility
- Professional package metadata
Author: AutoERP Development Team
License: MIT
Version: 1.0.0
"""
import os
import sys
import re
import ast
import subprocess
import codecs
from pathlib import Path
from typing import Dict, List, Optional, Union, Any
import warnings
# Core setup tools imports
from setuptools import setup, find_packages, Command
from setuptools.command.build_py import build_py
from setuptools.command.install import install
from setuptools.command.develop import develop
from setuptools.command.test import test as TestCommand
# Distutils imports for custom commands
from distutils.command.clean import clean
from distutils.util import convert_path
from distutils import log
# Suppress setuptools warnings
warnings.filterwarnings('ignore', category=UserWarning, module='setuptools')
# ==================== PACKAGE METADATA ====================
# Basic package information
PACKAGE_NAME = "autoerp"
PACKAGE_DIR = Path(__file__).parent
SOURCE_DIR = PACKAGE_DIR / PACKAGE_NAME
README_FILE = PACKAGE_DIR / "README.md"
CHANGES_FILE = PACKAGE_DIR / "CHANGES.md"
REQUIREMENTS_DIR = PACKAGE_DIR / "requirements"
# Package URLs and contact information
PACKAGE_URL = "https://github.com/autoerp/autoerp"
DOCUMENTATION_URL = "https://docs.autoerp.com"
REPOSITORY_URL = "https://github.com/autoerp/autoerp.git"
BUG_TRACKER_URL = "https://github.com/autoerp/autoerp/issues"
CHANGELOG_URL = "https://github.com/autoerp/autoerp/blob/main/CHANGES.md"
# Author information
AUTHOR_NAME = "AutoERP Development Team"
AUTHOR_EMAIL = "dev@autoerp.com"
MAINTAINER_NAME = "AutoERP Development Team"
MAINTAINER_EMAIL = "maintainer@autoerp.com"
# License information
LICENSE_NAME = "MIT"
LICENSE_FILE = PACKAGE_DIR / "LICENSE"
# Package description
SHORT_DESCRIPTION = "Modern Enterprise Resource Planning System with Hexagonal Architecture"
LONG_DESCRIPTION_CONTENT_TYPE = "text/markdown"
# ==================== UTILITY FUNCTIONS ====================
def read_file(file_path: Union[str, Path], encoding: str = 'utf-8') -> str:
"""
Read content from a file safely with proper error handling.
Args:
file_path: Path to the file to read
encoding: Character encoding to use (default: utf-8)
Returns:
str: File content or empty string if file not found
Example:
>>> content = read_file("README.md")
>>> print(len(content))
"""
file_path = Path(file_path)
try:
with codecs.open(file_path, 'r', encoding=encoding) as f:
content = f.read()
log.info(f"Successfully read {file_path} ({len(content)} characters)")
return content
except (IOError, OSError, FileNotFoundError) as e:
log.warn(f"Could not read {file_path}: {e}")
return ""
except UnicodeDecodeError as e:
log.warn(f"Unicode decode error in {file_path}: {e}")
try:
# Fallback to latin-1 encoding
with codecs.open(file_path, 'r', encoding='latin-1') as f:
return f.read()
except Exception:
return ""
def load_requirements(filename: str, requirements_dir: Optional[Path] = None) -> List[str]:
"""
Load requirements from a requirements file.
Handles comments, empty lines, and git+https URLs properly.
Supports both absolute and relative paths.
Args:
filename: Name of the requirements file (e.g., 'base.txt')
requirements_dir: Directory containing requirements files
Returns:
List[str]: List of requirement specifications
Example:
>>> reqs = load_requirements('base.txt')
>>> print(f"Found {len(reqs)} requirements")
"""
if requirements_dir is None:
requirements_dir = REQUIREMENTS_DIR
req_file = requirements_dir / filename
if not req_file.exists():
log.warn(f"Requirements file not found: {req_file}")
return []
requirements = []
try:
with open(req_file, 'r', encoding='utf-8') as f:
for line_num, line in enumerate(f, 1):
line = line.strip()
# Skip empty lines and comments
if not line or line.startswith('#'):
continue
# Handle -r includes (recursive requirements files)
if line.startswith('-r '):
include_file = line[3:].strip()
included_reqs = load_requirements(include_file, requirements_dir)
requirements.extend(included_reqs)
continue
# Handle -e editable installs
if line.startswith('-e '):
line = line[3:].strip()
# Handle inline comments
if ' #' in line:
line = line.split(' #')[0].strip()
# Skip lines with environment markers we can't handle
if ';' in line and ('python_version' in line or 'sys_platform' in line):
# For now, include all conditional requirements
line = line.split(';')[0].strip()
if line:
requirements.append(line)
log.info(f"Loaded {len(requirements)} requirements from {req_file}")
return requirements
except Exception as e:
log.warn(f"Error loading requirements from {req_file}: {e}")
return []
def get_version_from_init() -> Optional[str]:
"""
Extract version from package __init__.py file using AST parsing.
This method is safer than importing the module during setup.
Returns:
Optional[str]: Version string if found, None otherwise
Example:
>>> version = get_version_from_init()
>>> print(f"Package version: {version}")
"""
init_file = SOURCE_DIR / "__init__.py"
if not init_file.exists():
log.warn(f"__init__.py not found at {init_file}")
return None
try:
with open(init_file, 'r', encoding='utf-8') as f:
tree = ast.parse(f.read())
for node in ast.walk(tree):
if isinstance(node, ast.Assign):
for target in node.targets:
if isinstance(target, ast.Name) and target.id == '__version__':
if isinstance(node.value, ast.Str):
version = node.value.s
log.info(f"Found version in __init__.py: {version}")
return version
elif isinstance(node.value, ast.Constant):
version = node.value.value
log.info(f"Found version in __init__.py: {version}")
return version
log.warn("No __version__ found in __init__.py")
return None
except Exception as e:
log.warn(f"Error parsing __init__.py for version: {e}")
return None
def get_version_from_git() -> Optional[str]:
"""
Get version from git tags.
Looks for tags in the format 'v1.2.3' or '1.2.3' and returns
the latest semantic version.
Returns:
Optional[str]: Git tag version if available, None otherwise
Example:
>>> git_version = get_version_from_git()
>>> if git_version:
... print(f"Git version: {git_version}")
"""
try:
# Get the latest git tag
result = subprocess.run(
['git', 'describe', '--tags', '--abbrev=0'],
capture_output=True,
text=True,
cwd=PACKAGE_DIR,
timeout=10
)
if result.returncode == 0:
tag = result.stdout.strip()
# Remove 'v' prefix if present
version = tag.lstrip('v')
# Validate version format (basic semantic versioning)
if re.match(r'^\d+\.\d+\.\d+', version):
log.info(f"Found git version: {version}")
return version
else:
log.warn(f"Invalid version format in git tag: {tag}")
return None
else:
log.warn("No git tags found or git not available")
return None
except (subprocess.TimeoutExpired, subprocess.CalledProcessError, FileNotFoundError) as e:
log.warn(f"Error getting version from git: {e}")
return None
def get_dynamic_version() -> str:
"""
Get package version from multiple sources with fallback strategy.
Priority order:
1. __init__.py __version__ attribute
2. Git tags
3. Environment variable AUTOERP_VERSION
4. Fallback to default version
Returns:
str: Package version string
Example:
>>> version = get_dynamic_version()
>>> print(f"Dynamic version: {version}")
"""
# Try to get version from __init__.py first
version = get_version_from_init()
if version:
return version
# Try to get version from git tags
version = get_version_from_git()
if version:
return version
# Try environment variable
version = os.environ.get('AUTOERP_VERSION')
if version:
log.info(f"Using version from environment: {version}")
return version
# Fallback version
fallback_version = "1.0.0"
log.warn(f"Using fallback version: {fallback_version}")
return fallback_version
def get_long_description() -> str:
"""
Generate long description by combining README and CHANGES files.
Returns:
str: Combined long description for PyPI
Example:
>>> desc = get_long_description()
>>> print(f"Description length: {len(desc)}")
"""
readme_content = read_file(README_FILE)
changes_content = read_file(CHANGES_FILE)
# Combine README and CHANGES with proper formatting
long_desc_parts = []
if readme_content:
long_desc_parts.append(readme_content)
if changes_content:
long_desc_parts.append("\n\n## Changelog\n\n")
long_desc_parts.append(changes_content)
if not long_desc_parts:
# Fallback description
long_desc_parts.append(SHORT_DESCRIPTION)
long_desc_parts.append("\n\nA comprehensive Enterprise Resource Planning system built with modern Python technologies.")
return "".join(long_desc_parts)
# ==================== DEPENDENCY MANAGEMENT ====================
def get_core_requirements() -> List[str]:
"""
Get core runtime requirements for the package.
Returns:
List[str]: List of core requirements
"""
# Try to load from requirements file first
requirements = load_requirements('base.txt')
if not requirements:
# Fallback to hardcoded core requirements
requirements = [
"fastapi>=0.104.0",
"uvicorn[standard]>=0.24.0",
"streamlit>=1.28.0",
"pydantic>=2.4.0",
"sqlalchemy>=2.0.0",
"alembic>=1.12.0",
"pandas>=2.0.0",
"plotly>=5.16.0",
"numpy>=1.24.0",
"python-multipart>=0.0.6",
"python-jose[cryptography]>=3.3.0",
"passlib[bcrypt]>=1.7.4",
"aiofiles>=23.2.1",
"jinja2>=3.1.2",
"openpyxl>=3.1.0",
"celery>=5.3.0",
"redis>=5.0.0",
"psycopg2-binary>=2.9.7"
]
return requirements
def get_development_requirements() -> List[str]:
"""
Get development dependencies.
Returns:
List[str]: List of development requirements
"""
dev_requirements = load_requirements('dev.txt')
if not dev_requirements:
dev_requirements = [
"pytest>=7.4.0",
"pytest-cov>=4.1.0",
"pytest-asyncio>=0.21.1",
"black>=23.7.0",
"isort>=5.12.0",
"flake8>=6.0.0",
"mypy>=1.5.0",
"pre-commit>=3.4.0",
"tox>=4.11.0",
"coverage>=7.3.0",
"bandit>=1.7.5",
"safety>=2.3.0"
]
return dev_requirements
def get_test_requirements() -> List[str]:
"""
Get testing dependencies.
Returns:
List[str]: List of test requirements
"""
test_requirements = load_requirements('test.txt')
if not test_requirements:
test_requirements = [
"pytest>=7.4.0",
"pytest-cov>=4.1.0",
"pytest-asyncio>=0.21.1",
"pytest-mock>=3.11.1",
"factory-boy>=3.3.0",
"faker>=19.6.0",
"httpx>=0.24.0",
"pytest-xdist>=3.3.1"
]
return test_requirements
def get_documentation_requirements() -> List[str]:
"""
Get documentation dependencies.
Returns:
List[str]: List of documentation requirements
"""
docs_requirements = load_requirements('docs.txt')
if not docs_requirements:
docs_requirements = [
"sphinx>=7.1.0",
"sphinx-rtd-theme>=1.3.0",
"sphinxcontrib-openapi>=0.8.1",
"myst-parser>=2.0.0",
"sphinx-autodoc-typehints>=1.24.0",
"sphinx-copybutton>=0.5.2"
]
return docs_requirements
# ==================== CUSTOM SETUP COMMANDS ====================
class CustomBuildPy(build_py):
"""Custom build command with additional processing."""
description = "Build Python modules with custom processing"
def run(self):
"""Run the build process with custom steps."""
log.info("Running custom build process...")
# Run standard build first
super().run()
# Add custom build steps here
self._process_templates()
self._generate_version_file()
log.info("Custom build process completed")
def _process_templates(self):
"""Process any template files."""
log.info("Processing template files...")
# Template processing logic would go here
def _generate_version_file(self):
"""Generate version information file."""
version = get_dynamic_version()
version_file = Path(self.build_lib) / PACKAGE_NAME / '_version.py'
version_content = f'''"""
Version information for {PACKAGE_NAME}.
This file is automatically generated during build.
"""
__version__ = "{version}"
__build_date__ = "{subprocess.getoutput('date')}"
__build_system__ = "setuptools"
'''
try:
version_file.parent.mkdir(parents=True, exist_ok=True)
with open(version_file, 'w') as f:
f.write(version_content)
log.info(f"Generated version file: {version_file}")
except Exception as e:
log.warn(f"Could not generate version file: {e}")
class CustomInstall(install):
"""Custom install command with post-installation steps."""
description = "Install package with custom post-install steps"
def run(self):
"""Run installation with custom steps."""
log.info("Running custom installation...")
# Run standard installation
super().run()
# Post-installation steps
self._post_install()
log.info("Custom installation completed")
def _post_install(self):
"""Execute post-installation tasks."""
log.info("Running post-installation tasks...")
# Print ASCII logo
self._print_logo()
# Create default configuration
self._create_default_config()
def _print_logo(self):
"""Print AutoERP ASCII logo."""
logo = """
█████╗ ██╗ ██╗████████╗ ██████╗ ███████╗██████╗ ██████╗
██╔══██╗██║ ██║╚══██╔══╝██╔═══██╗██╔════╝██╔══██╗██╔══██╗
███████║██║ ██║ ██║ ██║ ██║█████╗ ██████╔╝██████╔╝
██╔══██║██║ ██║ ██║ ██║ ██║██╔══╝ ██╔══██╗██╔═══╝
██║ ██║╚██████╔╝ ██║ ╚██████╔╝███████╗██║ ██║██║
╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═════╝ ╚══════╝╚═╝ ╚═╝╚═╝
Enterprise Resource Planning System v{version}
🎉 Installation completed successfully!
Quick Start:
• python -m autoerp serve # Start API server
• python -m autoerp ui # Launch web interface
• python -m autoerp help # Show help
Documentation: https://docs.autoerp.com
Support: https://github.com/autoerp/autoerp/issues
""".format(version=get_dynamic_version())
print(logo)
def _create_default_config(self):
"""Create default configuration directory."""
try:
config_dir = Path.home() / '.autoerp'
config_dir.mkdir(exist_ok=True)
config_file = config_dir / 'config.json'
if not config_file.exists():
default_config = {
"database": {
"engine": "sqlite",
"database": str(config_dir / "autoerp.db")
},
"security": {
"secret_key": "change-me-in-production"
}
}
with open(config_file, 'w') as f:
import json
json.dump(default_config, f, indent=2)
log.info(f"Created default config at: {config_file}")
except Exception as e:
log.warn(f"Could not create default config: {e}")
class CustomDevelop(develop):
"""Custom develop command for development installations."""
description = "Install package in development mode"
def run(self):
"""Run development installation."""
log.info("Installing in development mode...")
super().run()
self._setup_development_environment()
def _setup_development_environment(self):
"""Setup development environment."""
log.info("Setting up development environment...")
# Install pre-commit hooks if available
try:
subprocess.run(['pre-commit', 'install'], check=True)
log.info("Pre-commit hooks installed")
except (subprocess.CalledProcessError, FileNotFoundError):
log.warn("Could not install pre-commit hooks")
class CustomTest(TestCommand):
"""Custom test command with additional options."""
description = "Run test suite with coverage"
user_options = [
('pytest-args=', 'a', "Arguments to pass to pytest"),
('coverage', 'c', "Run with coverage reporting"),
]
def initialize_options(self):
"""Initialize command options."""
TestCommand.initialize_options(self)
self.pytest_args = []
self.coverage = False
def finalize_options(self):
"""Finalize command options."""
TestCommand.finalize_options(self)
self.test_args = []
self.test_suite = True
def run_tests(self):
"""Run the test suite."""
import pytest
args = ['tests/']
if self.coverage:
args.extend(['--cov=autoerp', '--cov-report=html', '--cov-report=term'])
if self.pytest_args:
args.extend(self.pytest_args.split())
errno = pytest.main(args)
sys.exit(errno)
class CustomClean(clean):
"""Enhanced clean command."""
description = "Clean build files and directories"
def run(self):
"""Run cleaning process."""
super().run()
# Additional directories to clean
clean_dirs = [
'build',
'dist',
'*.egg-info',
'.pytest_cache',
'.coverage',
'htmlcov',
'.tox',
'__pycache__'
]
for pattern in clean_dirs:
self._remove_pattern(pattern)
def _remove_pattern(self, pattern: str):
"""Remove files matching pattern."""
import glob
import shutil
for path in glob.glob(pattern):
try:
if os.path.isdir(path):
shutil.rmtree(path)
log.info(f"Removed directory: {path}")
else:
os.remove(path)
log.info(f"Removed file: {path}")
except OSError as e:
log.warn(f"Could not remove {path}: {e}")
class BuildPackage(Command):
"""Command to build distribution packages."""
description = "Build source and wheel distributions"
user_options = []
def initialize_options(self):
"""Initialize options."""
pass
def finalize_options(self):
"""Finalize options."""
pass
def run(self):
"""Build packages."""
log.info("Building distribution packages...")
# Clean previous builds
self._clean_dist()
# Build source distribution
self.run_command('sdist')
# Build wheel distribution
try:
self.run_command('bdist_wheel')
except SystemExit:
log.warn("Wheel build failed, continuing with source distribution only")
log.info("Package building completed")
def _clean_dist(self):
"""Clean dist directory."""
import shutil
dist_dir = PACKAGE_DIR / 'dist'
if dist_dir.exists():
shutil.rmtree(dist_dir)
log.info("Cleaned dist directory")
class PublishPackage(Command):
"""Command to publish package to PyPI."""
description = "Publish package to PyPI"
user_options = [
('test-pypi', 't', 'Upload to test PyPI instead'),
('username=', 'u', 'PyPI username'),
('password=', 'p', 'PyPI password'),
]
def initialize_options(self):
"""Initialize options."""
self.test_pypi = False
self.username = None
self.password = None
def finalize_options(self):
"""Finalize options."""
pass
def run(self):
"""Publish package."""
log.info("Publishing package...")
# Build package first
self.run_command('build_package')
# Upload to PyPI
try:
import twine.commands.upload
repository = 'testpypi' if self.test_pypi else 'pypi'
upload_args = [
'--repository', repository,
'dist/*'
]
if self.username:
upload_args.extend(['--username', self.username])
if self.password:
upload_args.extend(['--password', self.password])
twine.commands.upload.main(upload_args)
log.info("Package published successfully")
except ImportError:
log.error("Twine not installed. Install with: pip install twine")
except Exception as e:
log.error(f"Publishing failed: {e}")
# ==================== SETUP CONFIGURATION ====================
def get_package_data() -> Dict[str, List[str]]:
"""
Get package data files to include in distribution.
Returns:
Dict[str, List[str]]: Package data specification
"""
return {
PACKAGE_NAME: [
'*.json',
'*.yaml',
'*.yml',
'*.ini',
'*.conf',
'*.cfg',
'templates/*',
'templates/**/*',
'static/*',
'static/**/*',
'migrations/*',
'migrations/**/*',
'locale/*/LC_MESSAGES/*'
]
}
def get_classifiers() -> List[str]:
"""
Get comprehensive PyPI classifiers.
Returns:
List[str]: List of classifier strings
"""
return [
# Development Status
'Development Status :: 4 - Beta',
# Intended Audience
'Intended Audience :: Developers',
'Intended Audience :: End Users/Desktop',
'Intended Audience :: Financial and Insurance Industry',
'Intended Audience :: Manufacturing',
# Topic Classification
'Topic :: Office/Business',
'Topic :: Office/Business :: Financial',
'Topic :: Office/Business :: Financial :: Accounting',
'Topic :: Office/Business :: Financial :: Investment',
'Topic :: Software Development :: Libraries :: Python Modules',
'Topic :: Internet :: WWW/HTTP :: Dynamic Content',
'Topic :: Database',
# License
'License :: OSI Approved :: MIT License',
# Programming Language
'Programming Language :: Python',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: 3.11',
'Programming Language :: Python :: 3.12',
'Programming Language :: Python :: Implementation :: CPython',
# Operating System
'Operating System :: OS Independent',
'Operating System :: POSIX',
'Operating System :: Microsoft :: Windows',
'Operating System :: MacOS',
# Framework
'Framework :: FastAPI',
'Framework :: AsyncIO',
# Environment
'Environment :: Web Environment',
'Environment :: Console',
# Natural Language
'Natural Language :: English',
# Typing
'Typing :: Typed'
]
def get_entry_points() -> Dict[str, Any]:
"""
Get entry points for console scripts, GUI scripts, and plugins.
Returns:
Dict[str, Any]: Entry points specification
"""
return {
'console_scripts': [
'autoerp = autoerp.__main__:main',
'autoerp-server = autoerp.api:run_server',
'autoerp-migrate = autoerp.cli:migrate_command',
'autoerp-admin = autoerp.cli:admin_command',
],
'gui_scripts': [
'autoerp-ui = autoerp.ui:main_ui',
'autoerp-dashboard = autoerp.ui:dashboard_main',
],
'autoerp.plugins': [
'core = autoerp.plugins.core:CorePlugin',
'accounting = autoerp.plugins.accounting:AccountingPlugin',
'inventory = autoerp.plugins.inventory:InventoryPlugin',
'crm = autoerp.plugins.crm:CRMPlugin',
]
}
def get_extras_require() -> Dict[str, List[str]]:
"""
Get optional dependencies for different use cases.
Returns:
Dict[str, List[str]]: Extra requirements specification
"""
return {
'dev': get_development_requirements(),
'test': get_test_requirements(),
'docs': get_documentation_requirements(),
'postgres': ['psycopg2-binary>=2.9.7'],
'mysql': ['pymysql>=1.1.0'],
'redis': ['redis>=5.0.0', 'hiredis>=2.2.0'],
'async': ['aioredis>=2.0.0', 'asyncpg>=0.28.0'],
'monitoring': ['prometheus-client>=0.17.0', 'sentry-sdk>=1.32.0'],
'all': (
get_development_requirements() +
get_test_requirements() +
get_documentation_requirements() +
['psycopg2-binary>=2.9.7', 'redis>=5.0.0', 'prometheus-client>=0.17.0']
)
}
# ==================== MAIN SETUP CALL ====================
def main():
"""Main setup function."""
# Get dynamic values
version = get_dynamic_version()
long_description = get_long_description()
core_requirements = get_core_requirements()
setup(
# Basic package information
name=PACKAGE_NAME,
version=version,
author=AUTHOR_NAME,
author_email=AUTHOR_EMAIL,
maintainer=MAINTAINER_NAME,
maintainer_email=MAINTAINER_EMAIL,
description=SHORT_DESCRIPTION,
long_description=long_description,
long_description_content_type=LONG_DESCRIPTION_CONTENT_TYPE,
license=LICENSE_NAME,
# URLs
url=PACKAGE_URL,
project_urls={
'Documentation': DOCUMENTATION_URL,
'Repository': REPOSITORY_URL,
'Bug Tracker': BUG_TRACKER_URL,
'Changelog': CHANGELOG_URL,
},
# Package discovery and data
packages=find_packages(exclude=['tests*', 'docs*', 'examples*']),
package_data=get_package_data(),
include_package_data=True,
zip_safe=False,
# Requirements and compatibility
python_requires='>=3.8',
install_requires=core_requirements,
extras_require=get_extras_require(),
# Entry points
entry_points=get_entry_points(),
# Classification
classifiers=get_classifiers(),
keywords=['erp', 'enterprise', 'resource', 'planning', 'business', 'management', 'fastapi', 'streamlit'],
# Custom commands
cmdclass={
'build_py': CustomBuildPy,
'install': CustomInstall,
'develop': CustomDevelop,
'test': CustomTest,
'clean': CustomClean,
'build_package': BuildPackage,
'publish': PublishPackage,
},
)
if __name__ == '__main__':
main()