forked from PostHog/posthog-python
- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup_analytics.py
More file actions
Latest commit
68 lines (57 loc) · 2.07 KB
/
Copy pathsetup_analytics.py
File metadata and controls
68 lines (57 loc) · 2.07 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
importos
importsys
importtomli
importtomli_w
importshutil
try:
fromsetuptoolsimportsetup
exceptImportError:
fromdistutils.coreimportsetup
# Don't import analytics-python module here, since deps may not be installed
sys.path.insert(0, os.path.join(os.path.dirname(__file__), "posthoganalytics"))
fromversionimportVERSION# noqa: E402
# Copy the original pyproject.toml as backup
shutil.copy("pyproject.toml", "pyproject.toml.backup")
# Read the original pyproject.toml
withopen("pyproject.toml", "rb") asf:
config=tomli.load(f)
# Override specific values
config["project"]["name"] ="posthoganalytics"
config["tool"]["setuptools"]["dynamic"]["version"] = {
"attr": "posthoganalytics.version.VERSION"
}
# Rename packages from posthog.* to posthoganalytics.*
if"packages"inconfig["tool"]["setuptools"]:
new_packages= []
forpackageinconfig["tool"]["setuptools"]["packages"]:
ifpackage=="posthog":
new_packages.append("posthoganalytics")
elifpackage.startswith("posthog."):
new_packages.append(package.replace("posthog.", "posthoganalytics.", 1))
else:
new_packages.append(package)
config["tool"]["setuptools"]["packages"] =new_packages
# Overwrite the original pyproject.toml
withopen("pyproject.toml", "wb") asf:
tomli_w.dump(config, f)
long_description="""
PostHog is developer-friendly, self-hosted product analytics.
posthog-python is the python package.
This package requires Python 3.9 or higher.
"""
# Minimal setup.py for backward compatibility
# Most configuration is now in pyproject.toml
setup(
name="posthoganalytics",
version=VERSION,
# Basic fields for backward compatibility
url="https://github.com/posthog/posthog-python",
author="Posthog",
author_email="hey@posthog.com",
maintainer="PostHog",
maintainer_email="hey@posthog.com",
license="MIT License",
description="Integrate PostHog into any python application.",
long_description=long_description,
# This will fallback to pyproject.toml for detailed configuration
)