Skip to content

Commit

Permalink
- Move sources of the archive package into the new src directory
Browse files Browse the repository at this point in the history
- Do not auto generate __init__.py
- Add a static __init__.py that imports version from _meta
  • Loading branch information
RKrahl committed Dec 29, 2023
1 parent 04d614d commit f3b2c99
Show file tree
Hide file tree
Showing 24 changed files with 14 additions and 25 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,5 @@ __pycache__/
/.env
/MANIFEST
/_meta.py
/archive/__init__.py
/build/
/dist/
1 change: 0 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ clean:

distclean: clean
rm -f MANIFEST _meta.py
rm -f archive/__init__.py
rm -rf dist
rm -rf tests/.pytest_cache

Expand Down
26 changes: 3 additions & 23 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,43 +37,22 @@ class meta(setuptools.Command):

description = "generate meta files"
user_options = []
init_template = '''"""%(doc)s"""
__version__ = "%(version)s"
from archive.archive import Archive
from archive.exception import *
'''
meta_template = '''
version = "%(version)s"
'''

def initialize_options(self):
self.package_dir = None
pass

def finalize_options(self):
self.package_dir = {}
if self.distribution.package_dir:
for name, path in self.distribution.package_dir.items():
self.package_dir[name] = convert_path(path)
pass

def run(self):
version = self.distribution.get_version()
log.info("version: %s", version)
values = {
'version': version,
'doc': docstring,
}
try:
pkgname = self.distribution.packages[0]
except IndexError:
log.warn("warning: no package defined")
else:
pkgdir = Path(self.package_dir.get(pkgname, pkgname))
if not pkgdir.is_dir():
pkgdir.mkdir()
with (pkgdir / "__init__.py").open("wt") as f:
print(self.init_template % values, file=f)
with Path("_meta.py").open("wt") as f:
print(self.meta_template % values, file=f)

Expand Down Expand Up @@ -139,6 +118,7 @@ def run(self):
Download="https://github.com/RKrahl/archive-tools/releases/latest",
),
packages = ["archive", "archive.cli", "archive.bt"],
package_dir = {"": "src"},
python_requires = ">=3.6",
install_requires = ["PyYAML", "packaging", "lark"],
scripts = ["scripts/archive-tool.py", "scripts/backup-tool.py",
Expand Down
11 changes: 11 additions & 0 deletions src/archive/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
"""Tools for managing archives
This package provides tools for managing archives. An archive in
terms of this package is a (compressed) tar archive file with some
embedded metadata on the included files. This metadata include the
name, file stats, and checksums of the file.
"""

from ._meta import version as __version__
from .archive import Archive
from .exception import *
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit f3b2c99

Please sign in to comment.