Repository navigation
Expand file tree
/
Copy pathsetup.py
More file actions
126 lines (109 loc) · 4.19 KB
/
Copy pathsetup.py
File metadata and controls
126 lines (109 loc) · 4.19 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
import glob
import os
import sys
from setuptools import setup, find_packages
from setuptools.command.install import install
from setuptools.command.develop import develop
def rebuild_journal_registry():
"""Rebuild the journal registry database after installation."""
try:
import subprocess
import sys
from pathlib import Path
# Find the registry builder script
package_root = Path(__file__).parent
registry_script = package_root / 'metapub' / 'scripts' / 'build_registry_from_yaml.py'
if not registry_script.exists():
raise FileNotFoundError(f"Registry builder script not found at {registry_script}")
print("Rebuilding journal registry from YAML configuration...")
# Run the registry builder
result = subprocess.run([
sys.executable, str(registry_script),
'--yaml-dir', str(package_root / 'metapub' / 'findit' / 'journals_yaml' / 'publishers'),
'--output-db', str(package_root / 'metapub' / 'findit' / 'data' / 'registry.db')
], capture_output=True, text=True, cwd=str(package_root))
if result.returncode == 0:
print("Journal registry rebuilt successfully!")
if result.stdout:
print(result.stdout.strip())
else:
raise RuntimeError(f"Registry build failed: {result.stderr}")
except Exception as e:
print(f"Warning: Could not rebuild journal registry: {e}")
print("You can manually rebuild it later with: python scripts/build_registry_from_yaml.py")
class PostInstallCommand(install):
"""Custom install command that rebuilds the journal registry."""
def run(self):
install.run(self)
self.execute(rebuild_journal_registry, [], msg="Rebuilding journal registry...")
class PostDevelopCommand(develop):
"""Custom develop command that rebuilds the journal registry."""
def run(self):
develop.run(self)
self.execute(rebuild_journal_registry, [], msg="Rebuilding journal registry...")
setup(
name="metapub",
version="0.7.4",
description="Pubmed / NCBI / eutils interaction library, handling the metadata of pubmed papers.",
long_description=open("README.rst").read(),
long_description_content_type="text/x-rst",
url="https://metapub.org",
author="Naomi Most",
maintainer="Naomi Most",
author_email="naomi@nthmost.com",
maintainer_email="naomi@nthmost.com",
license="Apache 2.0",
packages=find_packages(),
cmdclass={
'install': PostInstallCommand,
'develop': PostDevelopCommand,
},
entry_points={
"console_scripts": [
"pubmed_article = metapub.pubmedfetcher_cli:main",
"convert = metapub.convert:main",
"ncbi_health_check = metapub.ncbi_health_check:main",
"metapub_build_registry = metapub.scripts.build_registry_from_yaml:main",
"metapub-registry = metapub.findit.cli:main",
]
},
# Include all Python files in the package
include_package_data=True,
extras_require={
"test": [
"tox",
"pytest",
],
},
install_requires=[
"setuptools",
"lxml",
"lxml_html_clean",
"requests",
"brotli",
"habanero",
"tabulate",
"cssselect",
"unidecode",
"docopt",
"coloredlogs",
"python-Levenshtein",
"pyyaml",
],
classifiers=[
"Development Status :: 4 - Beta",
"Intended Audience :: Developers",
"Intended Audience :: Science/Research",
"License :: OSI Approved :: Apache Software License",
"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 :: 3.13",
"Topic :: Scientific/Engineering :: Bio-Informatics",
"Topic :: Software Development :: Libraries :: Python Modules",
],
python_requires=">=3.8",
)