From 1df5a940ad6a3cbcd8d84c6eef6b39f2b94759bd Mon Sep 17 00:00:00 2001 From: Waylan Limberg Date: Fri, 8 Dec 2017 19:48:08 -0500 Subject: [PATCH 1/2] Switch to setuptools. Use console_scripts entry_point instead of manually built script. --- MANIFEST.in | 1 - bin/markdown_py | 34 ------------------------ setup.py | 70 ++++++++++++++----------------------------------- 3 files changed, 19 insertions(+), 86 deletions(-) delete mode 100755 bin/markdown_py diff --git a/MANIFEST.in b/MANIFEST.in index 95a3ce28e..b60fb3bff 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,4 +1,3 @@ -recursive-include bin * recursive-include markdown *.py recursive-include docs * recursive-include tests *.txt *.html *.cfg *.py diff --git a/bin/markdown_py b/bin/markdown_py deleted file mode 100755 index 220c666a0..000000000 --- a/bin/markdown_py +++ /dev/null @@ -1,34 +0,0 @@ -#!/usr/bin/env python -""" -Python Markdown, the Command Line Script -======================================== - -This is the command line script for Python Markdown. - -Basic use from the command line: - - markdown source.txt > destination.html - -Run "markdown --help" to see more options. - -See markdown/__init__.py for information on using Python Markdown as a module. - -## Authors and License - -Started by [Manfred Stienstra](http://www.dwerg.net/). Continued and -maintained by [Yuri Takhteyev](http://www.freewisdom.org), [Waylan -Limberg](http://achinghead.com/) and [Artem Yunusov](http://blog.splyer.com). - -Contact: markdown@freewisdom.org - -Copyright 2007, 2008 The Python Markdown Project (v. 1.7 and later) -Copyright 200? Django Software Foundation (OrderedDict implementation) -Copyright 2004, 2005, 2006 Yuri Takhteyev (v. 0.2-1.6b) -Copyright 2004 Manfred Stienstra (the original version) - -License: BSD (see docs/LICENSE for details). -""" - -if __name__ == '__main__': - from markdown.__main__ import run - run() diff --git a/setup.py b/setup.py index fba517215..a356d8d3d 100755 --- a/setup.py +++ b/setup.py @@ -1,10 +1,7 @@ #!/usr/bin/env python -from __future__ import with_statement -import sys +from setuptools import setup import os -from distutils.core import setup -from distutils.command.install_scripts import install_scripts import imp @@ -14,54 +11,23 @@ def get_version(): fp, pathname, desc = imp.find_module('__version__', [path]) try: v = imp.load_module('__version__', fp, pathname, desc) - return v.version, v.version_info finally: fp.close() + dev_status_map = { + 'alpha': '3 - Alpha', + 'beta': '4 - Beta', + 'rc': '4 - Beta', + 'final': '5 - Production/Stable' + } + if v.version_info[3] == 'alpha' and v.version_info[4] == 0: + status = '2 - Pre-Alpha' + else: + status = dev_status_map[v.version_info[3]] + return v.version, v.version_info, status -version, version_info = get_version() -# Get development Status for classifiers -dev_status_map = { - 'alpha': '3 - Alpha', - 'beta': '4 - Beta', - 'rc': '4 - Beta', - 'final': '5 - Production/Stable' -} -if version_info[3] == 'alpha' and version_info[4] == 0: - DEVSTATUS = '2 - Pre-Alpha' -else: - DEVSTATUS = dev_status_map[version_info[3]] - -# The command line script name. Currently set to "markdown_py" so as not to -# conflict with the perl implimentation (which uses "markdown"). We can't use -# "markdown.py" as the default config on some systems will cause the script to -# try to import itself rather than the library which will raise an error. -SCRIPT_NAME = 'markdown_py' - - -class md_install_scripts(install_scripts): - - """ Customized install_scripts. Create markdown_py.bat for win32. """ - - def run(self): - install_scripts.run(self) - - if sys.platform == 'win32': - try: - script_dir = os.path.join(sys.prefix, 'Scripts') - script_path = os.path.join(script_dir, SCRIPT_NAME) - bat_str = '@"%s" "%s" %%*' % (sys.executable, script_path) - bat_path = os.path.join( - self.install_dir, '%s.bat' % SCRIPT_NAME - ) - f = open(bat_path, 'w') - f.write(bat_str) - f.close() - print('Created: %s' % bat_path) - except Exception: - _, err, _ = sys.exc_info() # for both 2.x & 3.x compatability - print('ERROR: Unable to create %s: %s' % (bat_path, err)) +version, version_info, DEVSTATUS = get_version() long_description = ''' @@ -72,7 +38,7 @@ def run(self): supported by the `Available Extensions`_. .. _Markdown: http://daringfireball.net/projects/markdown/ -.. _Features: https://Python-Markdown.github.io#Features +.. _Features: https://Python-Markdown.github.io#features .. _`Available Extensions`: https://Python-Markdown.github.io/extensions/ Support @@ -85,6 +51,7 @@ def run(self): .. _`bug tracker`: http://github.com/Python-Markdown/markdown/issues ''' + setup( name='Markdown', version=version, @@ -98,9 +65,10 @@ def run(self): maintainer_email='waylan.limberg@icloud.com', license='BSD License', packages=['markdown', 'markdown.extensions'], - scripts=['bin/%s' % SCRIPT_NAME], - cmdclass={ - 'install_scripts': md_install_scripts + entry_points={ + 'console_scripts': [ + 'markdown = markdown.__main__:run', + ] }, classifiers=[ 'Development Status :: %s' % DEVSTATUS, From a0c8d1bc330426b1331d99a68f171dc96b67b605 Mon Sep 17 00:00:00 2001 From: Waylan Limberg Date: Fri, 8 Dec 2017 20:13:06 -0500 Subject: [PATCH 2/2] Build and upload wheels for releases. Update install docs. --- docs/install.md | 63 +++++++++---------------------------------------- makefile | 6 +++-- setup.cfg | 6 +++++ setup.py | 2 +- 4 files changed, 22 insertions(+), 55 deletions(-) diff --git a/docs/install.md b/docs/install.md index d7997973b..25530d60c 100644 --- a/docs/install.md +++ b/docs/install.md @@ -1,64 +1,25 @@ -title: Installation +title: Installation -Installing Python-Markdown -========================== +# Installing Python-Markdown -The Easy Way ------------- +## The Easy Way -The easiest way to install Python-Markdown is simply to type one of the -following commands from the command line as an Admin/Root user: +The easiest way to install Python-Markdown is simply to type the +following command from the command line: ```bash pip install markdown ``` -or - -```bash -easy_install markdown -``` - That's it! You're ready to [use](reference.md) Python-Markdown. Enjoy! -Installing on Windows {: #windows } ------------------------------------ - -Download the Windows installer (`.exe`) from -[PyPI](http://pypi.python.org/pypi/Markdown) - -Double-click the file and follow the instructions. - -If you prefer to manually install Python-Markdown in Windows, download the -Zip file, unzip it, and on the command line in the directory you unzipped to, -run the following command: - -```text -C://path/to/python.exe setup.py install -``` - -If you plan to use the provided command line script, you need to make sure your -script directory is on your system path. On a typical Python install of Windows -the Scripts directory is `C:\PythonXX\Scripts\` (were "XX" is the Python version -number, i.e., "27"). Adjust the path according to your system and add to your -system path. - -Installing on \*nix Systems {: #linux } ---------------------------------------- - -From the command line do the following (where 2.x is the version number): - -```bash -wget http://pypi.python.org/packages/source/M/Markdown/Markdown-2.x.tar.gz -tar xvzf Markdown-2.x.tar.gz -cd markdown-2.x/ -sudo python setup.py install -``` +For more detailed instructions on installing Python packages, see the +[Installing Packages] tutorial in the [Python Packaging User Guide]. -See [PyPI](http://pypi.python.org/pypi/Markdown) for all available versions. +[Installing Packages]: https://packaging.python.org/tutorials/installing-packages/ +[Python Packaging User Guide]: https://packaging.python.org/ -Using the Git Repository {: #git } ----------------------------------- +## Using the Git Repository {: #git } If you're the type that likes to live on the edge, you may want to keep up with the latest additions and bug fixes in the repository between releases. @@ -67,7 +28,5 @@ get a copy of Python-Markdown from the repository do the following from the command line: ```bash -git clone git://github.com/Python-Markdown/markdown.git python-markdown -cd python-markdown -python setup.py install +pip install git+https://github.com/Python-Markdown/markdown.git ``` diff --git a/makefile b/makefile index ef1349e41..8cfd0eaee 100644 --- a/makefile +++ b/makefile @@ -20,11 +20,13 @@ install: .PHONY : deploy deploy: - python setup.py sdist --formats gztar upload + rm -rf dist + python setup.py bdist_wheel sdist --formats gztar + twine upload dist/* .PHONY : build build: - python setup.py sdist --formats gztar + python setup.py bdist_wheel sdist --formats gztar .PHONY : build-win build-win: diff --git a/setup.cfg b/setup.cfg index b0695bbf5..81482a994 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1 +1,7 @@ [nosetests] + +[bdist_wheel] +universal=1 + +[metadata] +license_file = LICENSE.md diff --git a/setup.py b/setup.py index a356d8d3d..668696a61 100755 --- a/setup.py +++ b/setup.py @@ -56,7 +56,7 @@ def get_version(): name='Markdown', version=version, url='https://Python-Markdown.github.io/', - download_url='http://pypi.python.org/packages/source/M/Markdown/Markdown-%s.tar.gz' % version, + download_url='http://pypi.python.org/packages/source/M/Markdown/Markdown-%s-py2.py3-none-any.whl' % version, description='Python implementation of Markdown.', long_description=long_description, author='Manfred Stienstra, Yuri takhteyev and Waylan limberg',