Skip to content

Commit a14b449

Browse files
committed
create a pufferlib-core pypi package
1 parent dcd597e commit a14b449

File tree

9 files changed

+529
-1
lines changed

9 files changed

+529
-1
lines changed

packages/pufferlib-core/README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# PufferLib Core
2+
3+
Minimal PufferLib core functionality with vectorized environments.
4+
5+
This package contains only the essential components:
6+
- `spaces`: Observation/action space handling
7+
- `emulation`: Environment compatibility layer for Gym/Gymnasium/PettingZoo
8+
- `vector`: Vectorized environment implementations
9+
10+
For the full PufferLib with training capabilities and environments, see the main `pufferlib` package.
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
"""
2+
PufferLib Core - Minimal vectorized environment functionality
3+
"""
4+
5+
import sys
6+
7+
# Import individual modules with delayed loading to avoid circular imports
8+
def _import_modules():
9+
from . import spaces
10+
from . import pufferlib
11+
12+
# Temporarily add pufferlib to the current module namespace to resolve imports
13+
current_module = sys.modules[__name__]
14+
current_module.PufferEnv = pufferlib.PufferEnv
15+
current_module.set_buffers = pufferlib.set_buffers
16+
17+
from . import emulation
18+
from . import vector
19+
20+
return spaces, pufferlib, emulation, vector
21+
22+
# Perform the imports
23+
spaces, pufferlib, emulation, vector = _import_modules()
24+
25+
__version__ = "3.0.3"
26+
__all__ = ["spaces", "emulation", "vector", "pufferlib"]
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../../pufferlib/emulation.py
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../../pufferlib/pufferlib.py
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../../pufferlib/spaces.py
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../../pufferlib/vector.py
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
[build-system]
2+
requires = ["setuptools>=45", "wheel"]
3+
build-backend = "setuptools.build_meta"
4+
5+
[project]
6+
name = "pufferlib-core"
7+
version = "3.0.3"
8+
description = "Minimal PufferLib core functionality with vectorized environments"
9+
readme = "README.md"
10+
requires-python = ">=3.8"
11+
license = {text = "MIT"}
12+
authors = [
13+
{name = "Joseph Suarez", email = "[email protected]"},
14+
]
15+
keywords = [
16+
"reinforcement-learning",
17+
"machine-learning",
18+
"multi-agent",
19+
"vectorized-environments",
20+
]
21+
classifiers = [
22+
"Development Status :: 5 - Production/Stable",
23+
"Environment :: Console",
24+
"Intended Audience :: Developers",
25+
"Intended Audience :: Education",
26+
"Intended Audience :: Science/Research",
27+
"License :: OSI Approved :: MIT License",
28+
"Operating System :: OS Independent",
29+
"Programming Language :: Python :: 3",
30+
"Programming Language :: Python :: 3.8",
31+
"Programming Language :: Python :: 3.9",
32+
"Programming Language :: Python :: 3.10",
33+
"Programming Language :: Python :: 3.11",
34+
"Programming Language :: Python :: 3.12",
35+
"Topic :: Scientific/Engineering :: Artificial Intelligence",
36+
"Topic :: Software Development :: Libraries :: Python Modules",
37+
]
38+
dependencies = [
39+
"numpy",
40+
"gymnasium",
41+
"psutil"
42+
]
43+
44+
[project.urls]
45+
Homepage = "https://github.com/PufferAI/PufferLib"
46+
Documentation = "https://puffer.ai"
47+
Repository = "https://github.com/PufferAI/PufferLib"
48+
Issues = "https://github.com/PufferAI/PufferLib/issues"
49+
50+
[tool.setuptools.packages.find]
51+
include = ["pufferlib*"]
52+
53+
[tool.setuptools.package-data]
54+
pufferlib = ["*.py"]

packages/pufferlib-core/uv.lock

Lines changed: 429 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pufferlib/spaces.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
import numpy as np
2-
import gym
32
import gymnasium
43

4+
try:
5+
import gym
6+
except ImportError:
7+
# Alias gymnasium as gym when gym is not available
8+
gym = gymnasium
9+
510
Box = (gym.spaces.Box, gymnasium.spaces.Box)
611
Dict = (gym.spaces.Dict, gymnasium.spaces.Dict)
712
Discrete = (gym.spaces.Discrete, gymnasium.spaces.Discrete)

0 commit comments

Comments
 (0)