Convert Figma logo to code with AI

pypa logosetuptools

Official project repository for the Setuptools build system

2,709
1,286
2,709
641

Top Related Projects

🛠 Python project template generator with batteries included

2,208

Simplified packaging of Python modules

6,672

Modern, extensible Python project management

25,068

Python Development Workflow for Humans.

Quick Overview

Setuptools is a Python library that facilitates packaging Python projects, making it easier to build and distribute Python packages. It extends the functionality of Python's distutils, providing developers with more powerful tools for creating, managing, and distributing Python packages.

Pros

  • Simplifies the process of creating and distributing Python packages
  • Offers a wide range of customization options for package configuration
  • Integrates well with other Python packaging tools like pip and wheel
  • Provides automatic discovery of package data and scripts

Cons

  • Can be complex for beginners or simple projects
  • Documentation can be overwhelming due to the extensive feature set
  • Some features may be considered legacy or outdated
  • Occasional compatibility issues with certain Python versions or other packaging tools

Code Examples

  1. Basic setup.py file:
from setuptools import setup, find_packages

setup(
    name="my_package",
    version="0.1",
    packages=find_packages(),
    install_requires=[
        "requests>=2.25.1",
        "pandas>=1.2.0",
    ],
)

This example shows a basic setup.py file that defines a package name, version, automatically discovers packages, and specifies dependencies.

  1. Using entry points:
setup(
    # ...
    entry_points={
        'console_scripts': [
            'my_command=my_package.module:main_function',
        ],
    },
)

This snippet demonstrates how to define console script entry points, allowing users to run your package's functions as command-line tools.

  1. Including package data:
setup(
    # ...
    package_data={
        'my_package': ['data/*.json', 'templates/*.html'],
    },
    include_package_data=True,
)

This example shows how to include non-Python files (like data or templates) in your package distribution.

Getting Started

To use setuptools in your project:

  1. Install setuptools:

    pip install setuptools
    
  2. Create a setup.py file in your project root:

    from setuptools import setup, find_packages
    
    setup(
        name="your_package_name",
        version="0.1",
        packages=find_packages(),
        install_requires=[
            # List your dependencies here
        ],
    )
    
  3. Build your package:

    python setup.py sdist bdist_wheel
    
  4. Install your package locally (for testing):

    pip install .
    

These steps will help you get started with using setuptools to package and distribute your Python project.

Competitor Comparisons

🛠 Python project template generator with batteries included

Pros of PyScaffold

  • Provides a more comprehensive project structure and setup out-of-the-box
  • Includes tools for documentation, testing, and continuous integration
  • Offers easy customization through command-line options and extensions

Cons of PyScaffold

  • Steeper learning curve for beginners compared to setuptools
  • Less flexibility for highly customized project structures
  • Potentially adds unnecessary complexity for simple projects

Code Comparison

PyScaffold project creation:

putup my_project

setuptools basic setup.py:

from setuptools import setup, find_packages

setup(
    name="my_project",
    packages=find_packages(),
)

PyScaffold focuses on providing a complete project structure with a single command, while setuptools offers a more minimal approach, requiring manual configuration for additional features. PyScaffold is better suited for larger projects or those following best practices, while setuptools provides more flexibility for simple or unconventional project structures.

2,208

Simplified packaging of Python modules

Pros of Flit

  • Simpler and more straightforward configuration
  • Faster build process for pure Python packages
  • Better support for modern Python packaging standards (e.g., PEP 517)

Cons of Flit

  • Limited support for complex build scenarios (e.g., C extensions)
  • Smaller ecosystem and less widespread adoption
  • Fewer advanced features compared to Setuptools

Code Comparison

Flit configuration (pyproject.toml):

[build-system]
requires = ["flit_core >=3.2,<4"]
build-backend = "flit_core.buildapi"

[project]
name = "example"
version = "0.1.0"
description = "An example package"

Setuptools configuration (setup.py):

from setuptools import setup, find_packages

setup(
    name="example",
    version="0.1.0",
    description="An example package",
    packages=find_packages(),
)

Flit offers a more concise configuration in pyproject.toml, while Setuptools uses a Python script (setup.py) with more flexibility but potentially more complexity. Flit's approach aligns better with modern Python packaging standards, while Setuptools provides more extensive customization options for complex projects.

6,672

Modern, extensible Python project management

Pros of Hatch

  • Simpler and more modern project configuration with pyproject.toml
  • Built-in support for environments, testing, and publishing
  • Faster build times for complex projects

Cons of Hatch

  • Less widespread adoption compared to Setuptools
  • Steeper learning curve for developers familiar with Setuptools
  • Some advanced features of Setuptools may not be available

Code Comparison

Setuptools (setup.py):

from setuptools import setup, find_packages

setup(
    name="myproject",
    version="0.1",
    packages=find_packages(),
)

Hatch (pyproject.toml):

[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

[project]
name = "myproject"
version = "0.1"

Hatch simplifies project configuration by using a standardized pyproject.toml file, while Setuptools traditionally uses a Python-based setup.py. Hatch's approach is more declarative and easier to parse, but Setuptools offers more flexibility for complex build scenarios. Both tools serve the same purpose of managing Python project builds and distributions, but Hatch aims to provide a more streamlined and modern experience.

25,068

Python Development Workflow for Humans.

Pros of pipenv

  • Simplifies dependency management with a single file (Pipfile) for both development and production dependencies
  • Automatically creates and manages a virtual environment for projects
  • Provides a lockfile (Pipfile.lock) for deterministic builds and dependency resolution

Cons of pipenv

  • Slower package installation compared to setuptools
  • Less flexible for complex project structures or custom build processes
  • Steeper learning curve for developers familiar with traditional Python packaging tools

Code comparison

pipenv:

[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"

[packages]
requests = "*"

[dev-packages]
pytest = "*"

setuptools:

from setuptools import setup, find_packages

setup(
    name="myproject",
    version="0.1",
    packages=find_packages(),
    install_requires=["requests"],
    extras_require={"dev": ["pytest"]}
)

Both pipenv and setuptools are popular tools for Python project management and packaging. pipenv offers a more modern approach with integrated virtual environment management, while setuptools provides greater flexibility and is more widely used in traditional Python projects. The choice between them depends on project requirements and team preferences.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

.. |pypi-version| image:: https://img.shields.io/pypi/v/setuptools.svg :target: https://pypi.org/project/setuptools

.. |py-version| image:: https://img.shields.io/pypi/pyversions/setuptools.svg

.. |test-badge| image:: https://github.com/pypa/setuptools/actions/workflows/main.yml/badge.svg :target: https://github.com/pypa/setuptools/actions?query=workflow%3A%22tests%22 :alt: tests

.. |ruff-badge| image:: https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/charliermarsh/ruff/main/assets/badge/v2.json :target: https://github.com/astral-sh/ruff :alt: Ruff

.. |docs-badge| image:: https://img.shields.io/readthedocs/setuptools/latest.svg :target: https://setuptools.pypa.io

.. |skeleton-badge| image:: https://img.shields.io/badge/skeleton-2025-informational :target: https://blog.jaraco.com/skeleton

.. |codecov-badge| image:: https://img.shields.io/codecov/c/github/pypa/setuptools/master.svg?logo=codecov&logoColor=white :target: https://codecov.io/gh/pypa/setuptools

.. |tidelift-badge| image:: https://tidelift.com/badges/github/pypa/setuptools?style=flat :target: https://tidelift.com/subscription/pkg/pypi-setuptools?utm_source=pypi-setuptools&utm_medium=readme

.. |discord-badge| image:: https://img.shields.io/discord/803025117553754132 :target: https://discord.com/channels/803025117553754132/815945031150993468 :alt: Discord

|pypi-version| |py-version| |test-badge| |ruff-badge| |docs-badge| |skeleton-badge| |codecov-badge| |discord-badge|

See the Quickstart <https://setuptools.pypa.io/en/latest/userguide/quickstart.html>_ and the User's Guide <https://setuptools.pypa.io/en/latest/userguide/>_ for instructions on how to use Setuptools.

Questions and comments should be directed to GitHub Discussions <https://github.com/pypa/setuptools/discussions>. Bug reports and especially tested patches may be submitted directly to the bug tracker <https://github.com/pypa/setuptools/issues>.

Code of Conduct

Everyone interacting in the setuptools project's codebases, issue trackers, chat rooms, and fora is expected to follow the PSF Code of Conduct <https://github.com/pypa/.github/blob/main/CODE_OF_CONDUCT.md>_.

For Enterprise

Available as part of the Tidelift Subscription.

Setuptools and the maintainers of thousands of other packages are working with Tidelift to deliver one enterprise subscription that covers all of the open source you use.

Learn more <https://tidelift.com/subscription/pkg/pypi-setuptools?utm_source=pypi-setuptools&utm_medium=referral&utm_campaign=github>_.