Skip to content

Commit f7060b6

Browse files
committed
Fix source build issues.
Paths need to be tweaked for pyproject.toml build process.
1 parent b63368b commit f7060b6

File tree

2 files changed

+43
-4
lines changed

2 files changed

+43
-4
lines changed

.github/workflows/python-package.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,3 +65,39 @@ jobs:
6565
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
6666
run: |
6767
twine upload --skip-existing dist/*
68+
- uses: actions/upload-artifact@v2
69+
if: runner.os == 'Linux'
70+
with:
71+
name: sdist
72+
path: dist/tcod-*.tar.gz
73+
retention-days: 3
74+
75+
isolated: # Test installing the package from source.
76+
needs: build
77+
runs-on: ${{ matrix.os }}
78+
strategy:
79+
matrix:
80+
os: ['ubuntu-20.04', 'windows-2019']
81+
steps:
82+
- name: Set up Python
83+
uses: actions/setup-python@v2
84+
with:
85+
python-version: 3.x
86+
- name: Install Python dependencies
87+
run: |
88+
python -m pip install --upgrade pip
89+
pip install wheel
90+
- name: Install APT dependencies
91+
if: runner.os == 'Linux'
92+
run: |
93+
sudo apt-get update
94+
sudo apt-get install libsdl2-dev
95+
- uses: actions/download-artifact@v2
96+
with:
97+
name: sdist
98+
- name: Build package in isolation
99+
run: |
100+
pip install -v tcod-*.tar.gz
101+
- name: Confirm package import
102+
run: |
103+
python -c "import tcod"

setup.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#!/usr/bin/env python3
22

33
import os
4+
import pathlib
45
import platform
56
import sys
67
import warnings
@@ -11,6 +12,8 @@
1112

1213
SDL_VERSION_NEEDED = (2, 0, 5)
1314

15+
PATH = pathlib.Path(__file__).parent # setup.py current directory
16+
1417

1518
def get_version() -> str:
1619
"""Get the current version from a git tag, or by reading tcod/version.py"""
@@ -29,13 +32,13 @@ def get_version() -> str:
2932
version += ".dev%i" % commits_since_tag
3033

3134
# update tcod/version.py
32-
with open("tcod/version.py", "w") as version_file:
35+
with open(PATH / "tcod/version.py", "w") as version_file:
3336
version_file.write('__version__ = "%s"\n' % version)
3437
return version
3538
except CalledProcessError:
3639
try:
3740
__version__ = "0.0.0"
38-
with open("tcod/version.py") as version_file:
41+
with open(PATH / "tcod/version.py") as version_file:
3942
exec(version_file.read(), globals()) # Update __version__
4043
except FileNotFoundError:
4144
warnings.warn("Unknown version: " "Not in a Git repository and not from a sdist bundle or wheel.")
@@ -66,7 +69,7 @@ def get_package_data() -> List[str]:
6669

6770
def get_long_description() -> str:
6871
"""Return this projects description."""
69-
with open("README.rst", "r") as readme_file:
72+
with open(PATH / "README.rst", "r") as readme_file:
7073
return readme_file.read()
7174

7275

@@ -89,7 +92,7 @@ def check_sdl_version() -> None:
8992
raise RuntimeError("SDL version must be at least %s, (found %s)" % (needed_version, sdl_version_str))
9093

9194

92-
if not os.path.exists("libtcod/src"):
95+
if not os.path.exists(PATH / "libtcod/src"):
9396
print("Libtcod submodule is uninitialized.")
9497
print("Did you forget to run 'git submodule update --init'?")
9598
sys.exit(1)

0 commit comments

Comments
 (0)