Skip to content

Commit

Permalink
Use flit to distribute pex.
Browse files Browse the repository at this point in the history
This gets rid of the tricky setup.py setuptools and wheel bootstrapping
we were doing using pex vendored versions and gives us non-deprecated
publishing support. In the course of adding a pyproject.toml for flit,
also update pex distribution metadata to officially support Python 3.8
with 1 test tweak. CI for Python 3.8 will come in a follow-up change.

Fixes #805
Fixes #807
  • Loading branch information
jsirois committed Dec 12, 2019
1 parent 087d2e0 commit d32f3e4
Show file tree
Hide file tree
Showing 10 changed files with 127 additions and 133 deletions.
41 changes: 22 additions & 19 deletions RELEASE.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,18 @@ local commit:

::

$ git log --stat -1
commit 8ffb208eb8cc597a4a486b212e0f6d3a12416a09 (HEAD -> master, tag: v1.6.5, origin/master, origin/HEAD)
$ git log --stat -1 v2.0.3
commit 6b3e12a86ae98682f1f1df468a960be6911d6557 (HEAD -> master, tag: v2.0.3, origin/master, origin/HEAD)
Author: John Sirois <john.sirois@gmail.com>
Date: Fri Mar 29 17:53:00 2019 -0700
Date: Thu Dec 5 23:51:41 2019 -0800

Prepare the 1.6.5 release. (#697)
Prepare the 2.0.3 release. (#822)

CHANGES.rst | 8 ++++++++
pex/version.py | 2 +-
2 files changed, 9 insertions(+), 1 deletion(-)
Fixes #814

CHANGES.rst | 20 ++++++++++++++++++++
pex/version.py | 2 +-
2 files changed, 21 insertions(+), 1 deletion(-)

Push to Master
--------------
Expand All @@ -33,7 +35,7 @@ Tag, push and watch Travis CI go green:

::

$ git tag --sign -am 'Release 1.6.5' v1.6.5
$ git tag --sign -am 'Release 2.0.3' v2.0.3
$ git push --tags origin HEAD

PyPI Release
Expand All @@ -44,7 +46,7 @@ Upload to PyPI

::

$ python setup.py bdist_wheel sdist upload --sign
$ tox -e publish

Dogfood
-------
Expand All @@ -54,7 +56,7 @@ Dogfood
$ pip install --no-cache-dir --upgrade pex
...
$ pex --version
pex 1.6.5
pex 2.0.3

Github Release
==============
Expand All @@ -67,20 +69,20 @@ Prepare binary assets
$ tox -e package
...
$ ./dist/pex --version
pex 1.6.5
pex 2.0.3

Craft the Release
-----------------

Open a tab on prior release as a template:

- https://github.com/pantsbuild/pex/releases/edit/v1.6.4
- https://github.com/pantsbuild/pex/releases/edit/v2.0.2

Open a tab to construct the current:

- https://github.com/pantsbuild/pex/releases/new?tag=v1.6.5
- https://github.com/pantsbuild/pex/releases/new?tag=v2.0.3

1. Use "Release <VERSION>" as the release name (e.g. "Release 1.6.5")
1. Use "Release <VERSION>" as the release name (e.g. "Release 2.0.3")
2. Copy and paste the most recent CHANGES.rst section.
3. Adapt the syntax from RestructuredText to Markdown (e.g. ``#ID <links>`` -> ``#ID``).
4. Upload the ``pex`` artifact.
Expand All @@ -90,10 +92,11 @@ Check your work

::

$ curl -L https://github.com/pantsbuild/pex/releases/download/v1.6.5/pex -O
$ curl -L https://github.com/pantsbuild/pex/releases/download/v2.0.3/pex > /tmp/pex
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 578 0 578 0 0 525 0 --:--:-- 0:00:01 --:--:-- 525
100 1450k 100 1450k 0 0 128k 0 0:00:11 0:00:11 --:--:-- 139k
$ ./pex --version
pex 1.6.5
100 593 0 593 0 0 1222 0 --:--:-- --:--:-- --:--:-- 1222
100 2370k 100 2370k 0 0 962k 0 0:00:02 0:00:02 --:--:-- 1383k
$ chmod +x /tmp/pex
$ /tmp/pex --version
pex 2.0.3
3 changes: 2 additions & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,13 @@
import sys
from datetime import datetime

from pex.version import __version__ as PEX_VERSION

# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
sys.path.insert(0, os.path.abspath('..'))

from pex.version import __version__ as PEX_VERSION

# -- General configuration ------------------------------------------------

Expand Down
41 changes: 41 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
[build-system]
requires = ["flit_core >=2,<3"]
build-backend = "flit_core.buildapi"

[tool.flit.metadata]
module = "pex"
author = "The PEX developers"
author-email = "pantsbuild@gmail.com"
home-page = "https://github.com/pantsbuild/pex"
description-file = "README.rst"
classifiers = [
"Intended Audience :: Developers",
"License :: OSI Approved :: Apache Software License",
"Operating System :: Unix",
"Operating System :: POSIX :: Linux",
"Operating System :: MacOS :: MacOS X",
"Programming Language :: Python",
"Programming Language :: Python :: 2",
"Programming Language :: Python :: 2.7",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.5",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
]
requires-python = ">=2.7,<3.9,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*"

[tool.flit.metadata.requires-extra]
# For improved subprocess robustness under python2.7.
subprocess = ["subprocess32>=3.2.7"]

[tool.flit.scripts]
pex = "pex.bin.pex:main"

[tool.flit.entrypoints."distutils.commands"]
# Make bdist_pex available for folks who install the pex distribution.
bdist_pex = "pex.commands.bdist_pex:bdist_pex"

[tool.flit.sdist]
include = ["CHANGES.rst"]

4 changes: 3 additions & 1 deletion scripts/combine_coverage.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import sys

from coverage.data import CoverageData

from pex.pex_builder import BOOTSTRAP_DIR


Expand Down Expand Up @@ -36,7 +37,8 @@ def combine_pex_coverage(root_dir, coverage_file_iter, unlink=True):
cov.read()
combined.add_line_data(dict(_iter_filter(root_dir, cov.line_data())))
combined.add_arc_data(dict(_iter_filter(root_dir, cov.arc_data())))
os.unlink(filename)
if unlink:
os.unlink(filename)

# filter out non-pex files
prefix = os.path.join(root_dir, 'pex/')
Expand Down
2 changes: 1 addition & 1 deletion scripts/coverage.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env bash

coverage run -p -m py.test tests
coverage run -p -m pytest tests
coverage run -p -m pex.bin.pex -v --help >&/dev/null
coverage run -p -m pex.bin.pex -v -- scripts/do_nothing.py
coverage run -p -m pex.bin.pex -v requests -- scripts/do_nothing.py
Expand Down
1 change: 1 addition & 0 deletions scripts/list_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from __future__ import absolute_import, print_function

import sys

import pytest


Expand Down
2 changes: 0 additions & 2 deletions setup.cfg

This file was deleted.

70 changes: 0 additions & 70 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,70 +0,0 @@
# Copyright 2014 Pants project contributors (see CONTRIBUTORS.md).
# Licensed under the Apache License, Version 2.0 (see LICENSE).

import os


# We may be executed from outside the project dir: `python pex/setup.py ...`, so ensure the
# `setup.py` dir is on the path and we're working from here so that dist/ and build/ dirs get
# created here and all files indicated by MANIFEST.in are found.
__HERE = os.path.realpath(os.path.dirname(__file__))
os.chdir(__HERE)


with open(os.path.join(__HERE, 'README.rst')) as fp:
LONG_DESCRIPTION = fp.read() + '\n'


with open(os.path.join(__HERE, 'CHANGES.rst')) as fp:
LONG_DESCRIPTION += fp.read()


from pex import third_party
third_party.install(expose=['setuptools', 'wheel'])


from pex.third_party.setuptools import find_packages, setup
from pex.commands.bdist_pex import bdist_pex
from pex.version import __version__


setup(
name='pex',
version=__version__,
description="The PEX packaging toolchain.",
long_description=LONG_DESCRIPTION,
long_description_content_type="text/x-rst",
url='https://github.com/pantsbuild/pex',
license='Apache License, Version 2.0',
zip_safe=False,
classifiers=[
'Intended Audience :: Developers',
'License :: OSI Approved :: Apache Software License',
'Operating System :: Unix',
'Operating System :: POSIX :: Linux',
'Operating System :: MacOS :: MacOS X',
'Programming Language :: Python',
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
],
packages=find_packages(),
include_package_data=True,
extras_require={
# For improved subprocess robustness under python2.7.
'subprocess': ['subprocess32>=3.2.7'],
},
cmdclass={'bdist_pex': bdist_pex}, # Make bdist_pex available for _this_ setup.py.
entry_points={
'distutils.commands': [
# Make bdist_pex available for folks who install the pex distribution.
'bdist_pex = pex.commands.bdist_pex:bdist_pex',
],
'console_scripts': [
'pex = pex.bin.pex:main',
],
},
)
5 changes: 5 additions & 0 deletions tests/test_pep425tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ def abi_tag_unicode(self, flags, config_vars):
assert abi_tag == base + flags + 'u'

else:
if sys.version_info >= (3, 8):
# On Python >= 3.8, the m flag is no longer used: https://bugs.python.org/issue36707
flags = flags.replace('m', '')

# On Python >= 3.3, UCS-4 is essentially permanently enabled, and
# Py_UNICODE_SIZE is None. SOABI on these builds does not include
# the 'u' so manual SOABI detection should not do so either.
Expand All @@ -58,6 +62,7 @@ def abi_tag_unicode(self, flags, config_vars):
abi_tag = pex.pep425tags.get_abi_tag()
assert abi_tag == base + flags


def test_broken_sysconfig(self):
"""
Test that pep425tags still works when sysconfig is broken.
Expand Down
Loading

0 comments on commit d32f3e4

Please sign in to comment.