Skip to content

Commit 2c74c16

Browse files
author
rocky
committed
Revise setup.py to test Python version at install time.
1 parent 38085d6 commit 2c74c16

File tree

4 files changed

+42
-17
lines changed

4 files changed

+42
-17
lines changed

README.rst

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ Installation
6161

6262
pip install xdis
6363

64-
*For Python releases before 3.11*, do not install using PyPI, but instead install using a file in the [GitHub Releases section](https://github.com/rocky/python-xdis/releases). Older Python used to use `easy_install <https://python101.pythonlibrary.org/chapter29_pip.html#using-easy-install>`_. But this is no longer supported in PyPi.
64+
*For Python releases before 3.11*, do not install using PyPI, but instead install using a file in the [GitHub Releases section](https://github.com/rocky/python-xdis/releases). Older Python used to use `easy_install <https://python101.pythonlibrary.org/chapter29_pip.html#using-easy-install>`_. But this is no longer supported in PyPi or newer Python versions. And vice versa, *poetry* nor *pip*, (the newer ways) are not supported on older Pythons.
6565

6666
If the Python version you are running xdis is between Python 2.4 through 2.7, use a tarball called xdis_24-*x.y.z*.tar.gz.
6767

@@ -75,31 +75,28 @@ If the Python version you are running xdis is 3.11 or later, use a called xdis-*
7575

7676
You can also try eggs or wheels that have the same version designation, e.g., xdis-*x.y.z*-py39-none-any.whl for a Python 3.9 installation. *However, note that *the version without the designation means Python 3.11 or greater*.
7777

78+
You can also try eggs or wheels that have the same version designation, e.g., xdis-*x.y.z*-py39-none-any.whl for a Python 3.9 installation. *However, note that *the version without the designation means Python 3.11 or greater*.
79+
7880
Similarly a tarball with without `_`*xx* works only from Python 3.11 or greater.
7981

82+
Rationale for using Git Branches
83+
++++++++++++++++++++++++++++++++
84+
85+
It is currently impossible (if not impractical) to have one Python source code of this complexity and with this many features that can run both Python 2.7 and Python 3.13+. The languages have drifted so much, and Packing is vastly different. In fact, the packaging practice for Python 3.11+ is incompatible with Python 2.7 (and before back to Python 2.4), which favored "easy_install".
86+
87+
8088
Installation from source text
8189
++++++++++++++++++++++++++++++
8290

83-
The standard Python routine:
91+
To install from source code, make sure you have the right Git
92+
branch. See the Requirements section for the Git branch names.
8493

85-
::
94+
After setting the right branch::
8695

8796
$ pip install -e . # or pip install -e .[dev] to include testing package
8897

8998
A GNU makefile is also provided so ``make install`` (possibly as root or sudo) will do the steps above.
9099

91-
To install older versions from source in git, use the branch
92-
``python-2.4-to-2.7`` for Python versions from 2.4 to 2.7,
93-
``python-3.1-to-3.2`` for Python versions from 3.1 to 3.2,
94-
``python-3.3-to-3.5`` for Python versions from 3.3 to 3.5. The master
95-
``python-3.6-to-3.10`` for Python versions from 3.6 to 3.10. The master
96-
branch handles Python 3.11 and later.
97-
98-
Rationale for using Git Branches
99-
++++++++++++++++++++++++++++++++
100-
101-
It is currently impossible (if not impractical) to have one Python source code of this complexity and with this many features that can run both Python 2.7 and Python 3.13+. The languages have drifted so much, and Packing is vastly different. In fact, the packaging practice for Python 3.11+ is incompatible with Python 2.7 (and before back to Python 2.4), which favored "easy_install".
102-
103100

104101
Disassembler Example
105102
--------------------

__pkginfo__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
# Things that change more often go here.
2424
copyright = """
25-
Copyright (C) 2015-2020, 2023-204 Rocky Bernstein <[email protected]>.
25+
Copyright (C) 2015-2020, 2023-2025 Rocky Bernstein <[email protected]>.
2626
"""
2727

2828
classifiers = [

pyproject.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,3 +61,6 @@ pydisasm = "xdis.bin.pydisasm:main"
6161

6262
[tool.setuptools.dynamic]
6363
version = {attr = "xdis.version.__version__"}
64+
65+
[tool.setuptools.packages.find]
66+
include = ["xdis*"] # Include all subpackages

setup.py

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,31 @@
11
#!/usr/bin/env python
2-
"""Setup script for the 'xdis' distribution."""
2+
"""
3+
Check that the Python version running this is compatible with this installation medium.
4+
Note: that we use 2.x compatible Python code here.
5+
"""
6+
7+
import sys
38

49
from setuptools import setup
510

11+
major = sys.version_info[0]
12+
minor = sys.version_info[1]
13+
14+
if major != 3 or not minor >= 11:
15+
sys.stderr.write("This installation medium is only for Python 3.11 and later. You are running Python %s.%s.\n" % (major, minor))
16+
17+
if major == 3 and 6 <= minor <= 10:
18+
sys.stderr.write("Please install using xdis_36-x.y.z.tar.gz from https://github.com/rocky/python-xdis/releases\n")
19+
sys.exit(1)
20+
elif major == 3 and 3 <= minor <= 5:
21+
sys.stderr.write("Please install using xdis_33-x.y.z.tar.gz from https://github.com/rocky/python-xdis/releases\n")
22+
sys.exit(1)
23+
if major == 3 and 0 <= minor <= 2:
24+
sys.stderr.write("Please install using xdis_30-x.y.z.tar.gz from https://github.com/rocky/python-xdis/releases\n")
25+
sys.exit(1)
26+
elif major == 2:
27+
sys.stderr.write("Please install using xdis_24-x.y.z.tar.gz from https://github.com/rocky/python-xdis/releases\n")
28+
sys.exit(1)
29+
30+
631
setup(packages=["xdis"])

0 commit comments

Comments
 (0)