Loading setup.py +30 −11 Changes for setup.py: 30 added lines, 11 removed lines. Original line number Diff line number Diff line Loading @@ -9,6 +9,7 @@ from typing import List # Modules libraries from setuptools import find_packages, setup from setuptools.command.build import build as BuildCommand from setuptools.command.sdist import sdist as SourcesCommand # Requirements Loading Loading @@ -36,8 +37,8 @@ PROJECT_SCRIPTS = [ ] PROJECT_URL = f'https://gitlab.com/{PROJECT_NAMESPACE}/{PROJECT_NAME}' # Setup sources class SetupSources(SourcesCommand): # Setup assets, pylint: disable=too-few-public-methods class SetupAssets: # Assets constants GIT_CONFIGURATION_ALIAS: str = 'alias.gitconfig' Loading @@ -57,19 +58,20 @@ class SetupSources(SourcesCommand): section_last: str = '' # Prepare profiles sources profiles: Path = Path.cwd() / SetupSources.SOURCES_ASSETS profiles: Path = Path.cwd() / SetupAssets.SOURCES_ASSETS profiles.mkdir(parents=True, exist_ok=True) # Write configuration file with open(profiles / SetupSources.GIT_CONFIGURATION_ALIAS, encoding='utf8', with open(profiles / SetupAssets.GIT_CONFIGURATION_ALIAS, encoding='utf8', mode='w') as asset: # Register assets list SetupSources.assets_list += [asset.name] if asset.name not in SetupAssets.assets_list: SetupAssets.assets_list += [asset.name] # Configuration file header asset.writelines([ f'{line}{SetupSources.GIT_CONFIGURATION_SEPARATOR}' for line in [ f'{line}{SetupAssets.GIT_CONFIGURATION_SEPARATOR}' for line in [ '#####', f'# {PROJECT_NAME}: Generated configuration maintained automatically', '###', Loading @@ -79,7 +81,7 @@ class SetupSources(SourcesCommand): ]) # Iterate through profiles files for root, _, _ in sorted(walk(SetupSources.PROFILES)): for root, _, _ in sorted(walk(SetupAssets.PROFILES)): for alias_file in sorted(glob(join(root, '*.alias'))): # Parse profile section Loading @@ -87,7 +89,7 @@ class SetupSources(SourcesCommand): if section_last != section_current: section_last = section_current asset.writelines([ f'{line}{SetupSources.GIT_CONFIGURATION_SEPARATOR}' f'{line}{SetupAssets.GIT_CONFIGURATION_SEPARATOR}' for line in [ '', '\t#####', Loading @@ -106,7 +108,7 @@ class SetupSources(SourcesCommand): # Inject alias configuration asset.writelines([ f'{line}{SetupSources.GIT_CONFIGURATION_SEPARATOR}' f'{line}{SetupAssets.GIT_CONFIGURATION_SEPARATOR}' for line in [ '\t#', f'\t# {comment}', Loading @@ -114,15 +116,30 @@ class SetupSources(SourcesCommand): ] ]) # Setup sources, pylint: disable=too-few-public-methods class SetupSources(SourcesCommand): # Sources entrypoint def run(self) -> None: # Git alias configuration SetupSources.git_configuration_alias() SetupAssets.git_configuration_alias() # Inherited entrypoint SourcesCommand.run(self) # Setup build, pylint: disable=too-few-public-methods class SetupBuild(BuildCommand): # Build entrypoint def run(self) -> None: # Git alias configuration SetupAssets.git_configuration_alias() # Inherited entrypoint BuildCommand.run(self) # Setup configurations setup( name=PROJECT_PACKAGE, Loading Loading @@ -187,6 +204,7 @@ setup( ]), cmdclass={ 'sdist': SetupSources, 'build': SetupBuild, }, entry_points={ 'console_scripts': PROJECT_SCRIPTS, Loading @@ -194,5 +212,6 @@ setup( ) # Assets cleanup for asset_file in SetupSources.assets_list: for asset_file in SetupAssets.assets_list: if Path(asset_file).is_file(): Path(asset_file).unlink() Loading
setup.py +30 −11 Changes for setup.py: 30 added lines, 11 removed lines. Original line number Diff line number Diff line Loading @@ -9,6 +9,7 @@ from typing import List # Modules libraries from setuptools import find_packages, setup from setuptools.command.build import build as BuildCommand from setuptools.command.sdist import sdist as SourcesCommand # Requirements Loading Loading @@ -36,8 +37,8 @@ PROJECT_SCRIPTS = [ ] PROJECT_URL = f'https://gitlab.com/{PROJECT_NAMESPACE}/{PROJECT_NAME}' # Setup sources class SetupSources(SourcesCommand): # Setup assets, pylint: disable=too-few-public-methods class SetupAssets: # Assets constants GIT_CONFIGURATION_ALIAS: str = 'alias.gitconfig' Loading @@ -57,19 +58,20 @@ class SetupSources(SourcesCommand): section_last: str = '' # Prepare profiles sources profiles: Path = Path.cwd() / SetupSources.SOURCES_ASSETS profiles: Path = Path.cwd() / SetupAssets.SOURCES_ASSETS profiles.mkdir(parents=True, exist_ok=True) # Write configuration file with open(profiles / SetupSources.GIT_CONFIGURATION_ALIAS, encoding='utf8', with open(profiles / SetupAssets.GIT_CONFIGURATION_ALIAS, encoding='utf8', mode='w') as asset: # Register assets list SetupSources.assets_list += [asset.name] if asset.name not in SetupAssets.assets_list: SetupAssets.assets_list += [asset.name] # Configuration file header asset.writelines([ f'{line}{SetupSources.GIT_CONFIGURATION_SEPARATOR}' for line in [ f'{line}{SetupAssets.GIT_CONFIGURATION_SEPARATOR}' for line in [ '#####', f'# {PROJECT_NAME}: Generated configuration maintained automatically', '###', Loading @@ -79,7 +81,7 @@ class SetupSources(SourcesCommand): ]) # Iterate through profiles files for root, _, _ in sorted(walk(SetupSources.PROFILES)): for root, _, _ in sorted(walk(SetupAssets.PROFILES)): for alias_file in sorted(glob(join(root, '*.alias'))): # Parse profile section Loading @@ -87,7 +89,7 @@ class SetupSources(SourcesCommand): if section_last != section_current: section_last = section_current asset.writelines([ f'{line}{SetupSources.GIT_CONFIGURATION_SEPARATOR}' f'{line}{SetupAssets.GIT_CONFIGURATION_SEPARATOR}' for line in [ '', '\t#####', Loading @@ -106,7 +108,7 @@ class SetupSources(SourcesCommand): # Inject alias configuration asset.writelines([ f'{line}{SetupSources.GIT_CONFIGURATION_SEPARATOR}' f'{line}{SetupAssets.GIT_CONFIGURATION_SEPARATOR}' for line in [ '\t#', f'\t# {comment}', Loading @@ -114,15 +116,30 @@ class SetupSources(SourcesCommand): ] ]) # Setup sources, pylint: disable=too-few-public-methods class SetupSources(SourcesCommand): # Sources entrypoint def run(self) -> None: # Git alias configuration SetupSources.git_configuration_alias() SetupAssets.git_configuration_alias() # Inherited entrypoint SourcesCommand.run(self) # Setup build, pylint: disable=too-few-public-methods class SetupBuild(BuildCommand): # Build entrypoint def run(self) -> None: # Git alias configuration SetupAssets.git_configuration_alias() # Inherited entrypoint BuildCommand.run(self) # Setup configurations setup( name=PROJECT_PACKAGE, Loading Loading @@ -187,6 +204,7 @@ setup( ]), cmdclass={ 'sdist': SetupSources, 'build': SetupBuild, }, entry_points={ 'console_scripts': PROJECT_SCRIPTS, Loading @@ -194,5 +212,6 @@ setup( ) # Assets cleanup for asset_file in SetupSources.assets_list: for asset_file in SetupAssets.assets_list: if Path(asset_file).is_file(): Path(asset_file).unlink()