To install the latest version of setuptools, use::
- pip install -U setuptools
+ pip install --upgrade setuptools
Refer to `Installing Packages`_ guide for more information.
Note that you can also apply setuptools commands to non-setuptools projects,
using commands like this::
- python -c "import setuptools; execfile('setup.py')" develop
+ python -c "import setuptools; with open('setup.py') as f: exec(compile(f.read(), 'setup.py', 'exec'))" develop
That is, you can simply list the normal setup commands and options following
the quoted part.
Before you begin, make sure you have the latest versions of setuptools and wheel::
- python3 -m pip install --user --upgrade setuptools wheel
+ pip install --upgrade setuptools wheel
To build a setuptools project, run this command from the same directory where
setup.py is located::
to be able to upload any packages.
You should install twine to be able to upload packages::
- python3 -m pip install --user --upgrade setuptools wheel
+ pip install --upgrade twine
Now, to upload these archives, run::
- twine upload --repository-url https://test.pypi.org/legacy/ dist/*
+ twine upload --repository-url https://test.pypi.org/simple/ dist/*
To install your newly uploaded package ``example_pkg``, you can use pip::
- python3 -m pip install --index-url https://test.pypi.org/simple/ example_pkg
+ pip install --index-url https://test.pypi.org/simple/ example_pkg
If you have issues at any point, please refer to `Packaging project tutorials`_
for clarification.
[metadata]
name = setuptools
-version = 43.0.0
+version = 44.0.0
description = Easily download, build, install, upgrade, and uninstall Python packages
author = Python Packaging Authority
author_email = distutils-sig@python.org
Programming Language :: Python :: 2
Programming Language :: Python :: 2.7
Programming Language :: Python :: 3
- Programming Language :: Python :: 3.4
Programming Language :: Python :: 3.5
Programming Language :: Python :: 3.6
Programming Language :: Python :: 3.7
[options]
zip_safe = True
-python_requires = >=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*
+python_requires = >=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*
py_modules = easy_install
packages = find:
# -*- coding: utf-8 -*-
"""sdist tests"""
-from __future__ import print_function
+from __future__ import print_function, unicode_literals
import os
-import shutil
import sys
import tempfile
import unicodedata
)
+def touch(path):
+ path.write_text('', encoding='utf-8')
+
+
class TestSdistTest:
- def setup_method(self, method):
- self.temp_dir = tempfile.mkdtemp()
- with open(os.path.join(self.temp_dir, 'setup.py'), 'w') as f:
- f.write(SETUP_PY)
+ @pytest.fixture(autouse=True)
+ def source_dir(self, tmpdir):
+ (tmpdir / 'setup.py').write_text(SETUP_PY, encoding='utf-8')
# Set up the rest of the test package
- test_pkg = os.path.join(self.temp_dir, 'sdist_test')
- os.mkdir(test_pkg)
- data_folder = os.path.join(self.temp_dir, "d")
- os.mkdir(data_folder)
+ test_pkg = tmpdir / 'sdist_test'
+ test_pkg.mkdir()
+ data_folder = tmpdir / 'd'
+ data_folder.mkdir()
# *.rst was not included in package_data, so c.rst should not be
# automatically added to the manifest when not under version control
- for fname in ['__init__.py', 'a.txt', 'b.txt', 'c.rst',
- os.path.join(data_folder, "e.dat")]:
- # Just touch the files; their contents are irrelevant
- open(os.path.join(test_pkg, fname), 'w').close()
+ for fname in ['__init__.py', 'a.txt', 'b.txt', 'c.rst']:
+ touch(test_pkg / fname)
+ touch(data_folder / 'e.dat')
- self.old_cwd = os.getcwd()
- os.chdir(self.temp_dir)
-
- def teardown_method(self, method):
- os.chdir(self.old_cwd)
- shutil.rmtree(self.temp_dir)
+ with tmpdir.as_cwd():
+ yield
def test_package_data_in_sdist(self):
"""Regression test for pull request #4: ensures that files listed in
manifest = cmd.filelist.files
assert 'setup.py' not in manifest
- def test_defaults_case_sensitivity(self):
+ def test_defaults_case_sensitivity(self, tmpdir):
"""
Make sure default files (README.*, etc.) are added in a case-sensitive
way to avoid problems with packages built on Windows.
"""
- open(os.path.join(self.temp_dir, 'readme.rst'), 'w').close()
- open(os.path.join(self.temp_dir, 'SETUP.cfg'), 'w').close()
+ touch(tmpdir / 'readme.rst')
+ touch(tmpdir / 'SETUP.cfg')
dist = Distribution(SETUP_ATTRS)
# the extension deliberately capitalized for this test
u_contents = contents.decode('UTF-8')
# The manifest should contain the UTF-8 filename
- if six.PY2:
- fs_enc = sys.getfilesystemencoding()
- filename = filename.decode(fs_enc)
-
assert posix(filename) in u_contents
@py3_only
@fail_on_latin1_encoded_filenames
def test_sdist_with_utf8_encoded_filename(self):
# Test for #303.
- dist = Distribution(SETUP_ATTRS)
+ dist = Distribution(self.make_strings(SETUP_ATTRS))
dist.script_name = 'setup.py'
cmd = sdist(dist)
cmd.ensure_finalized()
else:
assert filename in cmd.filelist.files
+ @classmethod
+ def make_strings(cls, item):
+ if isinstance(item, dict):
+ return {
+ key: cls.make_strings(value) for key, value in item.items()}
+ if isinstance(item, list):
+ return list(map(cls.make_strings, item))
+ return str(item)
+
@fail_on_latin1_encoded_filenames
def test_sdist_with_latin1_encoded_filename(self):
# Test for #303.
- dist = Distribution(SETUP_ATTRS)
+ dist = Distribution(self.make_strings(SETUP_ATTRS))
dist.script_name = 'setup.py'
cmd = sdist(dist)
cmd.ensure_finalized()
except UnicodeDecodeError:
filename not in cmd.filelist.files
- def test_pyproject_toml_in_sdist(self):
+ def test_pyproject_toml_in_sdist(self, tmpdir):
"""
Check if pyproject.toml is included in source distribution if present
"""
- open(os.path.join(self.temp_dir, 'pyproject.toml'), 'w').close()
+ touch(tmpdir / 'pyproject.toml')
dist = Distribution(SETUP_ATTRS)
dist.script_name = 'setup.py'
cmd = sdist(dist)
manifest = cmd.filelist.files
assert 'pyproject.toml' in manifest
- def test_pyproject_toml_excluded(self):
+ def test_pyproject_toml_excluded(self, tmpdir):
"""
Check that pyproject.toml can excluded even if present
"""
- open(os.path.join(self.temp_dir, 'pyproject.toml'), 'w').close()
+ touch(tmpdir / 'pyproject.toml')
with open('MANIFEST.in', 'w') as mts:
print('exclude pyproject.toml', file=mts)
dist = Distribution(SETUP_ATTRS)